torrent-cron 818 B

123456789101112131415161718192021222324252627282930313233343536
  1. #! /bin/sh
  2. UPUSER=`pgrep xinit | xargs ps -o uname= -p`
  3. source /home/$UPUSER/.profile
  4. TMCONFIGPATH_NRM=/home/$UPUSER/.config/transmission-daemon
  5. TMCONFIGPATH_AUX=/home/$UPUSER/.config/transmission-daemon_no-manual
  6. try_run()
  7. {
  8. [[ $TORPART == $TORPART_NRM ]] && nohup transmission-daemon -g $TMCONFIGPATH_NRM && echo "Transmisson (normal) is starting..."
  9. [[ $TORPART == $TORPART_AUX ]] && nohup transmission-daemon -g $TMCONFIGPATH_AUX && echo "Transmisson (auxilliary) is starting..."
  10. transmission-remote -U
  11. transmission-remote -D
  12. return 0
  13. }
  14. cycle()
  15. {
  16. [ -z "`ifconfig tun0`" ] && echo "[`date`] VPN isn't up" && return 0
  17. [ -n "`pgrep transmission`" ] && echo "[`date`] Transmission is already running, skipping..." && return 0
  18. try_run ""
  19. }
  20. cycle ""
  21. # while :
  22. # do
  23. # cycle ""
  24. # sleep 180s
  25. # done
  26. exit 0