forked from hasufell/hasufell-repository
98 lines
2.1 KiB
Plaintext
98 lines
2.1 KiB
Plaintext
#!/sbin/runscript
|
|
|
|
rundir=${rundir:-/run/sauerbraten}
|
|
|
|
depend() {
|
|
use net
|
|
}
|
|
|
|
start() {
|
|
[ $(echo ${RUNMASTER} | tr '[:upper:]' '[:lower:]') = "yes" ] && start_master
|
|
[ $(echo ${RUNSERVER} | tr '[:upper:]' '[:lower:]') = "yes" ] && start_server
|
|
true
|
|
}
|
|
|
|
start_server() {
|
|
ebegin "Starting Sauerbraten dedicated server"
|
|
|
|
# Make sure necessary parameters are set
|
|
SERVERCONFIG="${SERVERCONFIG:-%SYSCONFDIR%}"
|
|
|
|
if [ ! -d ${SERVERCONFIG} ]; then
|
|
einfo "No ${SERVERCONFIG} around. Creating new..."
|
|
mkdir ${SERVERCONFIG}
|
|
chown ${USER}:${GROUP} ${SERVERCONFIG}
|
|
fi
|
|
|
|
[ -d ${rundir} ] || {
|
|
mkdir -p "${rundir}"
|
|
chown -R ${USER}:${GROUP} "${rundir}"
|
|
}
|
|
|
|
start-stop-daemon \
|
|
--quiet \
|
|
--start \
|
|
--user ${USER} \
|
|
--group ${GROUP} \
|
|
--chdir ${SERVERCONFIG} \
|
|
--make-pidfile \
|
|
--pidfile "${rundir}"/server.pid \
|
|
--background \
|
|
--exec %LIBEXECDIR%/sauer_server -- ${SERVERARGS}
|
|
eend $?
|
|
}
|
|
|
|
start_master() {
|
|
ebegin "Starting Sauerbraten master server"
|
|
|
|
# Make sure necessary parameters are set
|
|
MASTERCONFIG="${MASTERCONFIG:-%SYSCONFDIR%}"
|
|
[ -n "${MASTERIP}" ] && MASTERPORT="${MASTERPORT:-28787}"
|
|
MASTERARGS="${MASTERCONFIG}/ ${MASTERPORT} ${MASTERIP}"
|
|
|
|
if [ ! -d ${MASTERCONFIG} ]; then
|
|
einfo "No ${MASTERCONFIG} around. Creating new..."
|
|
mkdir ${MASTERCONFIG}
|
|
chown ${USER}:${GROUP} ${MASTERCONFIG}
|
|
fi
|
|
|
|
[ -d ${rundir} ] || {
|
|
mkdir -p "${rundir}"
|
|
chown -R ${USER}:${GROUP} "${rundir}"
|
|
}
|
|
|
|
start-stop-daemon \
|
|
--quiet \
|
|
--start \
|
|
--user ${USER} \
|
|
--group ${GROUP} \
|
|
--make-pidfile \
|
|
--pidfile "${rundir}"/master.pid \
|
|
--background \
|
|
--exec %LIBEXECDIR%/sauer_master -- ${MASTERARGS}
|
|
eend $?
|
|
}
|
|
|
|
stop() {
|
|
[ $(echo ${RUNSERVER} | tr '[:upper:]' '[:lower:]') = "yes" ] && stop_server
|
|
[ $(echo ${RUNMASTER} | tr '[:upper:]' '[:lower:]') = "yes" ] && stop_master
|
|
true
|
|
}
|
|
|
|
stop_server() {
|
|
ebegin "Stopping Sauerbraten dedicated server"
|
|
start-stop-daemon --stop --retry 3 --pidfile "${rundir}"/server.pid
|
|
eend $?
|
|
}
|
|
|
|
stop_master() {
|
|
ebegin "Stopping Sauerbraten master server"
|
|
start-stop-daemon --stop --retry 3 --pidfile "${rundir}"/master.pid
|
|
eend $?
|
|
}
|
|
|
|
restart() {
|
|
svc_stop
|
|
svc_start
|
|
}
|