Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
#! /bin/sh
### BEGIN INIT INFO
# Provides:          odysseus
# Required-Start:    $all        
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop Odysseus Server
### END INIT INFO
USERNAME=odysseus
do_start() {
	# TODO: prevent starting odysseus a bunch of times
	su $USERNAME -l -c "screen -dmS odysseus odysseus"
}
do_stop() {
	# TODO: if you have started odysseus a bunch of times without stopping it before, stopping doesn't work
	su $USERNAME -c  "screen -p 0 -S odysseus -X quit"
}
case "$1" in
    start)
		echo "Starting Odysseus ..."
		do_start
        ;;
    stop)
		echo "Stopping Odysseus ..."
		do_stop
        ;;
	restart)
		echo "Restarting Odysseus ..."
		do_stop
		do_start
		;;
    *)
        echo "Usage: /etc/init.d/odysseus {start|stop}"
        ;;
esac
exit 0

...