#! /bin/sh
# This file is a simple PokemonOnline deamonfile for OpenSuse
# If you are going to use it, please change the BIN-dir
# and store this file (or a symbolic link) as /usr/sbin/rcpokemononline
#
# Note that you have to compile Pokemon Online for OpenSuse yourself.
### BEGIN INIT INFO
# Provides:          pokemononline
# Required-Start:    $syslog $remote_fs
# Required-Stop:     $syslog $remote_fs
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Description:       Pokemon Online is an online Pokemon battle simulator.
# Short-Description: Pokemon Online
### END INIT INFO
# Note on runlevels:
# 0 - halt/poweroff 			6 - reboot
# 1 - single user			2 - multiuser without network exported
# 3 - multiuser w/ network (text mode)  5 - multiuser w/ network and X11 (xdm)
# 
# http://www.novell.com/coolsolutions/feature/15380.html
#
# Please use the names already registered or register one or use a
# vendor prefix.

POKEMON_ONLINE_BIN=/srv/pokemononline/Server

test -x $POKEMON_ONLINE_BIN || { echo "$POKEMON_ONLINE_BIN not present";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

. /etc/rc.status

rc_reset

case "$1" in
    start)
	echo -n "Starting Pokemon Online server "
	/sbin/startproc -l /var/log/rcpokemononline.log $POKEMON_ONLINE_BIN --headless
	rc_status -v
	;;
    stop)
	echo -n "Pokemon Online server "
	/sbin/killproc -TERM $POKEMON_ONLINE_BIN
	rc_status -v
	;;
    restart)
	$0 stop
	$0 start
	rc_status
	;;
    reload)
	echo -n "Reload Pokemon Online server "
	/sbin/killproc -HUP $POKEMON_ONLINE_BIN
	rc_status -v
	;;
    status)
	echo -n "Checking for service "
	/sbin/checkproc $POKEMON_ONLINE_BIN
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart|reload}"
	exit 1
	;;
esac
rc_exit

