2007-01-10 23:36:27 +01:00
|
|
|
#! /bin/bash
|
|
|
|
# Copyright (c) 1995-2002 SuSE Linux AG, Nuernberg, Germany.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
2022-03-16 10:34:28 +01:00
|
|
|
# Author: Mads Martin Jørgensen <feedback@suse.de>
|
2007-01-10 23:36:27 +01:00
|
|
|
#
|
|
|
|
# /etc/init.d/bzflagserver
|
|
|
|
#
|
|
|
|
# and its symbolic link
|
|
|
|
#
|
|
|
|
# /usr/sbin/rcbzflagserver
|
|
|
|
#
|
|
|
|
# LSB compliant service control script; see http://www.linuxbase.org/spec/
|
2010-03-19 10:36:38 +01:00
|
|
|
#
|
2007-01-10 23:36:27 +01:00
|
|
|
# System startup script for the BZFlag gameserver
|
|
|
|
#
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: bzflagserver
|
|
|
|
# Required-Start: $remote_fs $syslog
|
|
|
|
# Required-Stop: $remote_fs $syslog
|
|
|
|
# Default-Start: 3 5
|
|
|
|
# Default-Stop: 0 1 2 6
|
2008-04-21 18:36:30 +02:00
|
|
|
# Short-Description: bzflag server daemon
|
2007-01-10 23:36:27 +01:00
|
|
|
# Description: Start bzflagserver to provide a server for the popular
|
2010-03-19 10:36:38 +01:00
|
|
|
# tank game BZFlag, http://www.bzflag.org
|
2007-01-10 23:36:27 +01:00
|
|
|
### END INIT INFO
|
2010-03-19 10:36:38 +01:00
|
|
|
#
|
2007-01-10 23:36:27 +01:00
|
|
|
# Note on Required-Start: It does specify the init script ordering,
|
|
|
|
# not real dependencies. Depencies have to be handled by admin
|
|
|
|
# resp. the configuration tools (s)he uses.
|
|
|
|
. /etc/rc.status
|
|
|
|
|
|
|
|
# First reset status of this service
|
|
|
|
rc_reset
|
|
|
|
|
|
|
|
if [ -f /etc/sysconfig/bzflagserver ]; then
|
2010-03-19 10:36:38 +01:00
|
|
|
. /etc/sysconfig/bzflagserver
|
2007-01-10 23:36:27 +01:00
|
|
|
else
|
2010-03-19 10:36:38 +01:00
|
|
|
echo "Could not find /etc/sysconfig/bzflagserver"
|
|
|
|
echo "Please start the bzflagserver manually"
|
|
|
|
rc_failed 1
|
|
|
|
rc_status -v
|
2007-01-10 23:36:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for missing binaries (stale symlinks should not happen)
|
|
|
|
BZFLAGSERVER_BIN=/usr/bin/bzfs
|
|
|
|
test -x $BZFLAGSERVER_BIN || exit 5
|
|
|
|
|
|
|
|
# See /etc/sysconfig/bzflagserver for options to the bzfs
|
|
|
|
if [ "$BZFLAGSERVER_PUBLIC" = "yes" ] ; then
|
2010-03-19 10:36:38 +01:00
|
|
|
PUBLIC="-public"
|
2007-01-10 23:36:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$BZFLAGSERVER_NEWBIE" = "yes" ] ; then
|
2010-03-19 10:36:38 +01:00
|
|
|
HANDICAP="-handicap"
|
2007-01-10 23:36:27 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2010-03-19 10:36:38 +01:00
|
|
|
echo -n "Starting bzflagserver"
|
2007-01-10 23:36:27 +01:00
|
|
|
|
2010-03-19 10:36:38 +01:00
|
|
|
if [ "$BZFLAGSERVER_SRVMSG" ] ; then
|
|
|
|
startproc -u nobody -g nobody $BZFLAGSERVER_BIN \
|
|
|
|
$BZFLAGSERVER_OPTS $PUBLIC -p "$BZFLAGSERVER_PORT" \
|
2019-03-25 16:33:56 +01:00
|
|
|
-world "/usr/share/bzflag/maps/$BZFLAGSERVER_WORLD" \
|
2010-03-19 10:36:38 +01:00
|
|
|
-srvmsg "$BZFLAGSERVER_SRVMSG" $HANDICAP
|
|
|
|
else
|
|
|
|
startproc -u nobody -g nobody $BZFLAGSERVER_BIN \
|
|
|
|
$BZFLAGSERVER_OPTS $PUBLIC -p "$BZFLAGSERVER_PORT" \
|
2019-03-25 16:33:56 +01:00
|
|
|
-world "/usr/share/bzflag/maps/$BZFLAGSERVER_WORLD" \
|
2010-03-19 10:36:38 +01:00
|
|
|
$HANDICAP
|
|
|
|
fi
|
|
|
|
# Remember status and be verbose
|
|
|
|
rc_status -v
|
|
|
|
;;
|
2007-01-10 23:36:27 +01:00
|
|
|
stop)
|
2010-03-19 10:36:38 +01:00
|
|
|
echo -n "Shutting down bzflagserver"
|
|
|
|
## Stop daemon with killproc(8) and if this fails
|
|
|
|
## set echo the echo return value.
|
2007-01-10 23:36:27 +01:00
|
|
|
|
2010-03-19 10:36:38 +01:00
|
|
|
killproc -TERM $BZFLAGSERVER_BIN
|
2007-01-10 23:36:27 +01:00
|
|
|
|
2010-03-19 10:36:38 +01:00
|
|
|
# Remember status and be verbose
|
|
|
|
rc_status -v
|
|
|
|
;;
|
2007-01-10 23:36:27 +01:00
|
|
|
try-restart)
|
2010-03-19 10:36:38 +01:00
|
|
|
## Stop the service and if this succeeds (i.e. the
|
|
|
|
## service was running before), start it again.
|
|
|
|
## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
|
|
|
|
$0 status >/dev/null && $0 restart
|
2007-01-10 23:36:27 +01:00
|
|
|
|
2010-03-19 10:36:38 +01:00
|
|
|
# Remember status and be quiet
|
|
|
|
rc_status
|
|
|
|
;;
|
2007-01-10 23:36:27 +01:00
|
|
|
restart)
|
2010-03-19 10:36:38 +01:00
|
|
|
## Stop the service and regardless of whether it was
|
|
|
|
## running or not, start it again.
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
2007-01-10 23:36:27 +01:00
|
|
|
|
2010-03-19 10:36:38 +01:00
|
|
|
# Remember status and be quiet
|
|
|
|
rc_status
|
|
|
|
;;
|
2007-01-10 23:36:27 +01:00
|
|
|
force-reload)
|
2010-03-19 10:36:38 +01:00
|
|
|
$0 stop && $0 start
|
|
|
|
rc_status
|
|
|
|
;;
|
2007-01-10 23:36:27 +01:00
|
|
|
reload)
|
2010-03-19 10:36:38 +01:00
|
|
|
rc_failed 3
|
|
|
|
rc_status -v
|
|
|
|
;;
|
2007-01-10 23:36:27 +01:00
|
|
|
status)
|
2010-03-19 10:36:38 +01:00
|
|
|
echo -n "Checking for service bzflagserver: "
|
|
|
|
## Check status with checkproc(8), if process is running
|
|
|
|
## checkproc will return with exit status 0.
|
2007-01-10 23:36:27 +01:00
|
|
|
|
2010-03-19 10:36:38 +01:00
|
|
|
# Return value is slightly different for the status command:
|
|
|
|
# 0 - service running
|
|
|
|
# 1 - service dead, but /var/run/ pid file exists
|
|
|
|
# 2 - service dead, but /var/lock/ lock file exists
|
|
|
|
# 3 - service not running
|
2007-01-10 23:36:27 +01:00
|
|
|
|
2010-03-19 10:36:38 +01:00
|
|
|
# NOTE: checkproc returns LSB compliant status values.
|
|
|
|
checkproc $BZFLAGSERVER_BIN
|
|
|
|
rc_status -v
|
|
|
|
;;
|
2007-01-10 23:36:27 +01:00
|
|
|
*)
|
2010-03-19 10:36:38 +01:00
|
|
|
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
|
|
|
|
exit 1
|
|
|
|
;;
|
2007-01-10 23:36:27 +01:00
|
|
|
esac
|
|
|
|
rc_exit
|