#nmcli con down id VPN1 LOGFILE=/home/lucas/.LOG/deluged-log.log exec >>$LOGFILE 2>&1 if [ "$(pgrep deluge)" != "" ]; then date VPN="$(nmcli con show --active | grep -i vpn) " ret=$? echo "${VPN}Status: $ret" | sed 's/ */ /g' if [ $ret -ne 0 ]; then echo "No VPN active. Starting VPN" nmcli con up id VPN1 sleep 1 VPN="$(nmcli con show --active | grep vpn)" ret=$? echo "STATUS:$ret $VPN" if [ $ret -ne 0 ]; then echo "Starting VPN failed. Start killing all Deluge processes" pkill deluged pkill deluge-gtk echo "Kill VPN and Restart network" nmcli radio all off nmcli radio all on fi else echo "All in Order. Proceed as usual." fi fi filesize=$(stat -c%s $LOGFILE) if [ $filesize -gt 1000000 ]; then line=$(( $(cat $LOGFILE | wc -l)/2 )) echo "Filesize: $filesize: Delete Line 1 - $line" sed -i "1,${line}d" $LOGFILE fi