diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
commit | 4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch) | |
tree | ba5f07bf3f9d22d82e54a462313f5d244036c768 /games-fps/sauerbraten/files/sauerbraten.init |
reinit the tree, so we can have metadata
Diffstat (limited to 'games-fps/sauerbraten/files/sauerbraten.init')
-rw-r--r-- | games-fps/sauerbraten/files/sauerbraten.init | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/games-fps/sauerbraten/files/sauerbraten.init b/games-fps/sauerbraten/files/sauerbraten.init new file mode 100644 index 000000000000..a5a7bb32966d --- /dev/null +++ b/games-fps/sauerbraten/files/sauerbraten.init @@ -0,0 +1,74 @@ +#!/sbin/openrc-run + +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 + + start-stop-daemon \ + --quiet --start --user ${USER}:${GROUP} --chdir ${SERVERCONFIG} \ + --make-pidfile --pidfile %GAMES_STATEDIR%/run/sauerbraten/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 + + start-stop-daemon \ + --quiet --start --user ${USER}:${GROUP} \ + --make-pidfile --pidfile %GAMES_STATEDIR%/run/sauerbraten/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 %GAMES_STATEDIR%/run/sauerbraten/server.pid + eend $? +} + +stop_master() { + ebegin "Stopping Sauerbraten master server" + start-stop-daemon --stop --retry 3 --pidfile %GAMES_STATEDIR%/run/sauerbraten/master.pid + eend $? +} + +restart() { + svc_stop + svc_start +} |