dtalley11

pokemonshowdown init.d

Feb 20th, 2014
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.22 KB | None | 0 0
  1. #!/bin/sh -e
  2. ### BEGIN INIT INFO
  3. # Provides:          Pokemon-Showdown Server
  4. # Required-Start:    networking
  5. # Default-Start:     3 4 5
  6. # Default-Stop:      0 6
  7. ### END INIT INFO
  8.  
  9. # Specify where Pokemon showdown is at
  10. PKMONPATH="/home/pokemon/Pokemon-Showdown/"
  11. PATH="$PATH:$PKMONPATH"
  12.  
  13. # The Username:Group that will run Pokemon-Showdown server
  14. export USER="pokemon"
  15. #${RUNAS}
  16.  
  17. . /lib/lsb/init-functions
  18.  
  19. case "$1" in
  20. start)
  21. log_action_begin_msg "Starting Pokemon Showdown Server"
  22. cd $PKMONPATH
  23. # Probably unnecessary, but just in case we will set up the log file
  24. touch /var/log/psd
  25. chown ${USER} /var/log/psd
  26. chmod o+rw /var/log/psd
  27. # As the user specified earlier, run pokemon showdown with node.js, log it to /var/log/psd and detach it from the init process
  28. su ${USER} -c "/usr/bin/nodejs $PKMONPATH/app.js" > /var/log/psd &
  29. # Lets spit out some of the log, and a little message about where to find the rest
  30. log_action_begin_msg $(cat /var/log/psd) "Rest of the log can be found at /var/log/psd"
  31. ;;
  32.  
  33. stop)
  34. log_action_begin_msg "Stoping Pokemon Showdown Server"
  35. # Yes... I am lazy
  36. pkill nodejs
  37. ;;
  38.  
  39. restart)
  40. # For people who don't want to stop and start themselves
  41. $0 stop
  42. $0 start
  43. ;;
  44. esac
  45.  
  46. exit 0
Advertisement
Add Comment
Please, Sign In to add comment