torrent-service 860 B

12345678910111213141516171819202122232425262728293031323334
  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. [[ -n `ifconfig tun0 | grep -q "00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00"` ]] && 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. while :
  21. do
  22. cycle ""
  23. sleep 180s
  24. done
  25. exit 0