Advertisement
Guest User

Pyload init script

a guest
Jan 6th, 2011
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.28 KB | None | 0 0
  1. #! /bin/bash
  2. # Author: Alexander Winkler
  3. # http://www.dermute.de
  4.  
  5. DESC="PyLoad Download-Manager"
  6. NAME="pyLoadCore.py"
  7. SHORT="pyload"
  8. DAEMON=/usr/share/pyload/$NAME
  9. DAEMON_ARGS=""
  10. INSTALL_DIR=/usr/share/
  11. UPDATE_SOURCE=https://bitbucket.org/spoob/pyload/get/tip.zip
  12.  
  13. do_start()
  14. {
  15.     echo "Starting $DESC ..."
  16.     if [ -e $DAEMON ]; then
  17.         if [ $(which screen) > /dev/null ]; then
  18.             screen -dmS $SHORT $DAEMON
  19.             echo "... successfully!"
  20.         else
  21.             echo "screen has not been installed correctly!"
  22.         fi
  23.     else
  24.         echo "$DESC has not been installed correctly!"
  25.     fi
  26. }
  27.  
  28. do_stop()
  29. {
  30.     $DAEMON -q
  31. }
  32.  
  33. do_restart() {
  34.         do_stop
  35.         sleep 5
  36.         do_start
  37. }
  38.  
  39. do_update() {
  40.     do_stop
  41.     sleep 5
  42.     cd $INSTALL_DIR
  43.     wget $UPDATE_SOURCE
  44.     unzip -o tip.zip
  45.     rm tip.zip
  46.     do_start
  47. }
  48.  
  49. case "$1" in
  50.   start)
  51.     do_start
  52.     ;;
  53.   stop)
  54.     do_stop
  55.     ;;
  56.   status)
  57.     if [ $(pidof python $DAEMON) > /dev/null ]; then
  58.         echo "$DESC is running."
  59.     else
  60.         echo "$DESC is NOT running."
  61.     fi
  62.     ;;
  63.   restart)
  64.     do_restart
  65.     ;;
  66.   watch)
  67.     echo "Press CTRL+A D to stop watching and CTRL+C to kill $DESC."
  68.     read -p "[Press any key to watch pyload now...]"
  69.     screen -r $SHORT
  70.     ;;
  71.   update)
  72.     do_update
  73.     ;;
  74.   *)
  75.     echo "Usage: $0 {start|stop|status|restart|watch}"
  76.     exit 1
  77.     ;;
  78. esac
  79.  
  80. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement