1
0
minetest-engine-multicraft2/doc/multicraftserver.init
mckaygerhard dad9ed70f3 fix daemon parameters, ser shared dir to PREFIX/share/multicraft
* pass game id and game world name to daemons scripts,
  cos now cannot be pointed in config file..
* fix dameon scripts invocations
2024-06-04 15:26:57 -04:00

81 lines
2.1 KiB
Bash

#! /bin/sh
### BEGIN INIT INFO
# Provides: multicraftserver
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: multicraftserver daemon by MinenuX
# Description: MinenuX dedicated game server for multicraft
### END INIT INFO
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
NAME="multicraftserver"
DAEMON="/usr/games/$NAME"
DESC="multicraft network game server"
PIDFILE="/var/run/$NAME.pid"
BINARY="/usr/games/$NAME"
USER="multicraft"
test -x $DAEMON || exit 0
. /lib/lsb/init-functions
# Include defaults if available
if [ -f /etc/default/$NAME ] ; then
. /etc/default/$NAME
fi
DAEMON_OPTS = "--world $WORLD --logfile $LOG --config $CONFIG --gameid $GAMEID"
multicraft_start() {
start-stop-daemon --chdir /var/games/multicraft --user ${USER:-multicraft} --chuid ${USER:-multicraft} --group ${GROUP:-games} --make-pidfile --pidfile $PIDFILE --background --quiet --wait 300 \
--start \
--oknodo \
--exec $BINARY \
-- $DAEMON_OPTS > /dev/null 2>&1 || return 1
return 0
}
multicraft_stop() {
start-stop-daemon \
--stop \
--pidfile $PIDFILE \
--oknodo \
--exec $BINARY || return 1
rm -f $PIDFILE
return 0
}
case "$1" in
start)
log_begin_msg "Starting $DESC: $NAME"
multicraft_start
log_end_msg $?
;;
stop)
log_begin_msg "Stopping $DESC: $NAME"
multicraft_stop
log_end_msg $?
;;
restart|force-reload)
log_begin_msg "Restarting $DESC: $NAME"
multicraft_stop && sleep 1 && multicraft_start
log_end_msg $?
;;
reload)
log_begin_msg "Reloading $DESC: $NAME"
start-stop-daemon --signal HUP --exec "$BINARY" --pidfile "$PIDFILE"
log_end_msg $?
;;
status)
status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status|reload}" >&2
exit 1
;;
esac
exit 0