From dad9ed70f3fc3c254eacef2f8dffdbfd0bfe6d07 Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Tue, 4 Jun 2024 15:26:57 -0400 Subject: [PATCH] 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 --- CMakeLists.txt | 5 +++-- doc/multicraftserver.confd | 8 ++++++-- doc/multicraftserver.defaults | 3 ++- doc/multicraftserver.init | 11 ++--------- doc/multicraftserver.initd | 27 ++++++++++++++------------- doc/multicraftserver.service | 3 ++- doc/multicraftserver@.service | 2 +- 7 files changed, 30 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 815de9e2c..138aa084f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,7 @@ elseif(UNIX) # Linux, BSD etc set(ICONDIR "unix/icons") set(LOCALEDIR "locale") else() - set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share") + set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}") set(BINDIR "${CMAKE_INSTALL_PREFIX}/games") set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}") set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man") @@ -242,7 +242,8 @@ if(UNIX AND NOT APPLE) DESTINATION "${ICONDIR}/hicolor/128x128/apps" RENAME "multicraft.png") install(FILES "doc/multicraftserver.confd" DESTINATION "${ETCDIR}/conf.d" RENAME "${PROJECT_NAME}server") - install(FILES "doc/multicraftserver.defaults" DESTINATION "${ETCDIR}/defaults" RENAME "${PROJECT_NAME}server") + install(FILES "doc/multicraftserver.defaults" DESTINATION "${ETCDIR}/default" RENAME "${PROJECT_NAME}server") + install(FILES "doc/multicraftserver.defaults" DESTINATION "${ETCDIR}/sysconfig" RENAME "${PROJECT_NAME}server") if(NOT RUN_IN_PLACE) install(FILES "doc/multicraftserver.init" DESTINATION "${ETCDIR}/init.d" RENAME "${PROJECT_NAME}server") # install(FILES "doc/multicraftserver.initd" DESTINATION "${CMAKE_INSTALL_PREFIX}/etc/init.d" RENAME "${PROJECT_NAME}server") diff --git a/doc/multicraftserver.confd b/doc/multicraftserver.confd index 22d81a2b2..1df5f52b1 100644 --- a/doc/multicraftserver.confd +++ b/doc/multicraftserver.confd @@ -1,7 +1,11 @@ -# alpine based server default distro config file +# ALPINE based server default distro config file +# for apk place as /etc/conf.d/multicraftserver +# for deb place as /etc/defaults/multicraftserver +# for rpm place as /etc/sysconfig/multicraftserver USER="multicraft" GROUP="games" LOG="/var/log/multicraft/multicraft.log" CONFIG="/etc/multicraft/multicraft.conf" ARGS="" -GAMEID="minenux" +GAMEID="minetest" +WORLD="default" diff --git a/doc/multicraftserver.defaults b/doc/multicraftserver.defaults index 505afb58a..7c53fb346 100644 --- a/doc/multicraftserver.defaults +++ b/doc/multicraftserver.defaults @@ -7,4 +7,5 @@ GROUP="games" LOG="/var/log/multicraft/multicraft.log" CONFIG="/etc/multicraft/multicraft.conf" ARGS="" -GAMEID="minenux" +GAMEID="minetest" +WORLD="default" diff --git a/doc/multicraftserver.init b/doc/multicraftserver.init index 7f5a8f914..573cbb8ef 100644 --- a/doc/multicraftserver.init +++ b/doc/multicraftserver.init @@ -26,18 +26,13 @@ if [ -f /etc/default/$NAME ] ; then . /etc/default/$NAME fi -DAEMON_OPTS = "--logfile $LOG --config $CONFIG --gameid $GAMEID" +DAEMON_OPTS = "--world $WORLD --logfile $LOG --config $CONFIG --gameid $GAMEID" multicraft_start() { - start-stop-daemon \ + 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 \ - --quiet \ - --pidfile $PIDFILE \ --oknodo \ - --background \ --exec $BINARY \ - --startas $DAEMON \ - --make-pidfile --chuid $USER \ -- $DAEMON_OPTS > /dev/null 2>&1 || return 1 return 0 } @@ -45,7 +40,6 @@ multicraft_start() { multicraft_stop() { start-stop-daemon \ --stop \ - --quiet \ --pidfile $PIDFILE \ --oknodo \ --exec $BINARY || return 1 @@ -78,7 +72,6 @@ case "$1" in status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $? ;; *) - # echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $0 {start|stop|restart|force-reload|status|reload}" >&2 exit 1 ;; diff --git a/doc/multicraftserver.initd b/doc/multicraftserver.initd index e9216d3ca..35c57b0c4 100644 --- a/doc/multicraftserver.initd +++ b/doc/multicraftserver.initd @@ -3,31 +3,32 @@ description="multicraftserver daemon by MinenuX" pidfile="/var/run/$SVCNAME.pid" -command="/usr/bin/multicraftserver" +command="/usr/games/multicraftserver" -start_stop_daemon_args="--user ${USER:-multicraft} --group ${GROUP:-games} --make-pidfile --pidfile $pidfile --background --quiet --wait 300" +start_stop_daemon_args="--chdir /var/games/multicraft --user ${USER:-multicraft} --group ${GROUP:-games} --make-pidfile --pidfile $pidfile --background --quiet --wait 300" command_args="$ARGS" depend() { - need net - after firewall + need net + after firewall } optional_command_arg() { - if [ -n "$2" ]; then - command_args="$command_args $1 $2" - fi + if [ -n "$2" ]; then + command_args="$command_args $1 $2" + fi } start_pre() { - optional_command_arg --logfile $LOG - optional_command_arg --config $CONFIG - optional_command_arg --gameid $GAMEID + optional_command_arg --world $WORLD + optional_command_arg --logfile $LOG + optional_command_arg --config $CONFIG + optional_command_arg --gameid $GAMEID } reload() { - ebegin "Reloading $SVCNAME" - start-stop-daemon --signal HUP --exec "$EXEC" --pidfile "$pidfile" - eend $? + ebegin "Reloading $SVCNAME" + start-stop-daemon --signal HUP --exec "$EXEC" --pidfile "$pidfile" + eend $? } diff --git a/doc/multicraftserver.service b/doc/multicraftserver.service index 5147ac8c9..5dcc4b573 100644 --- a/doc/multicraftserver.service +++ b/doc/multicraftserver.service @@ -3,12 +3,13 @@ Description=multicraftserver daemon for multicraft.conf by MinenuX Documentation=man:multicraftserver(6) After=network.target RequiresMountsFor=/var/games/multicraft +EnvironmentFile=-/etc/sysconfig/multicrafserver [Service] Restart=on-failure User=multicraft Group=games -ExecStart=/usr/games/multicraftserver --config /etc/multicraft/multicraft.conf --logfile /var/log/multicraft/multicraft.log +ExecStart=/usr/games/multicraftserver --world ${WORLD:-default} --logfile /var/log/multicraft/multicraft.log --config ${CONFIG:-/etc/multicraft/multicraft.conf} --gameid ${GAMEID:-minetest} StandardOutput=null [Install] diff --git a/doc/multicraftserver@.service b/doc/multicraftserver@.service index 593856fe0..05d7a100f 100644 --- a/doc/multicraftserver@.service +++ b/doc/multicraftserver@.service @@ -8,7 +8,7 @@ RequiresMountsFor=/var/games/multicraft Restart=on-failure User=multicraft Group=games -ExecStart=/usr/games/multicraftserver --config /etc/multicraft/%i.conf --logfile /var/log/multicraft/%i.log --gameid %i +ExecStart=/usr/games/multicraftserver --world %i --config /etc/multicraft/%i.conf --logfile /var/log/multicraft/%i.log --gameid %i StandardOutput=null [Install]