Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh -e
- ### BEGIN INIT INFO
- # Provides: Pokemon-Showdown Server
- # Required-Start: networking
- # Default-Start: 3 4 5
- # Default-Stop: 0 6
- ### END INIT INFO
- # Specify where Pokemon showdown is at
- PKMONPATH="/home/pokemon/Pokemon-Showdown/"
- PATH="$PATH:$PKMONPATH"
- # The Username:Group that will run Pokemon-Showdown server
- export USER="pokemon"
- #${RUNAS}
- . /lib/lsb/init-functions
- case "$1" in
- start)
- log_action_begin_msg "Starting Pokemon Showdown Server"
- cd $PKMONPATH
- # Probably unnecessary, but just in case we will set up the log file
- touch /var/log/psd
- chown ${USER} /var/log/psd
- chmod o+rw /var/log/psd
- # As the user specified earlier, run pokemon showdown with node.js, log it to /var/log/psd and detach it from the init process
- su ${USER} -c "/usr/bin/nodejs $PKMONPATH/app.js" > /var/log/psd &
- # Lets spit out some of the log, and a little message about where to find the rest
- log_action_begin_msg $(cat /var/log/psd) "Rest of the log can be found at /var/log/psd"
- ;;
- stop)
- log_action_begin_msg "Stoping Pokemon Showdown Server"
- # Yes... I am lazy
- pkill nodejs
- ;;
- restart)
- # For people who don't want to stop and start themselves
- $0 stop
- $0 start
- ;;
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment