[iortcw] 08/10: Add dedicated server startup scripts
Simon McVittie
smcv at debian.org
Tue Dec 30 22:11:31 UTC 2014
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch master
in repository iortcw.
commit ddc11fd517482fab0a7824795963bc9440461331
Author: Simon McVittie <smcv at debian.org>
Date: Tue Dec 30 20:05:04 2014 +0000
Add dedicated server startup scripts
---
debian/.gitignore | 1 +
debian/control | 19 +++++++----
debian/default.cfg | 31 ++++++++++++++++++
debian/rtcw-server.README.Debian | 56 +++++++++++++++++++++++++++++++++
debian/rtcw-server.install | 2 ++
debian/rtcw-server.links | 2 ++
debian/rtcw-server.postinst | 30 ++++++++++++++++++
debian/rtcw-server.postrm | 16 ++++++++++
debian/rtcw-server.wolfded.init | 64 ++++++++++++++++++++++++++++++++++++++
debian/rtcw-server.wolfded.service | 15 +++++++++
debian/rules | 8 ++++-
debian/wolfded at .service | 22 +++++++++++++
12 files changed, 259 insertions(+), 7 deletions(-)
diff --git a/debian/.gitignore b/debian/.gitignore
index 9afbafd..cc845b8 100644
--- a/debian/.gitignore
+++ b/debian/.gitignore
@@ -1,5 +1,6 @@
*.debhelper.log
*.substvars
+/*.debhelper
/build/
/files
/rtcw/
diff --git a/debian/control b/debian/control
index c6a46bc..2e7fc29 100644
--- a/debian/control
+++ b/debian/control
@@ -4,6 +4,7 @@ Priority: optional
Maintainer: Debian Games Team <pkg-games-devel at lists.alioth.debian.org>
Uploaders: Simon McVittie <smcv at debian.org>
Build-Depends: debhelper (>= 9),
+ dh-systemd,
dpkg-dev (>= 1.16.1),
imagemagick,
libcurl4-gnutls-dev,
@@ -35,14 +36,16 @@ Description: game engine for Return to Castle Wolfenstein
.
This package contains the iortcw game engines for the single-player campaign
and multiplayer, based on ioquake3 and the GPL source releases of RTCW.
- It requires non-distributable game data files prepared using
- the game-data-packager tool.
+ .
+ Return to Castle Wolfenstein requires non-distributable game data files
+ in the rtcw-data package, prepared using the game-data-packager tool.
Package: rtcw-server
Architecture: linux-any kfreebsd-any hurd-any
Depends:
${misc:Depends},
${shlibs:Depends},
+ adduser,
rtcw-common (= ${binary:Version}),
Description: standalone server for Return to Castle Wolfenstein
Return to Castle Wolfenstein is a military- and occult-themed first-person
@@ -51,8 +54,12 @@ Description: standalone server for Return to Castle Wolfenstein
(in the wolf4sdl package).
.
This package contains the iortcw dedicated server for multiplayer,
- based on ioquake3 and the GPL source releases of RTCW. It requires
- non-distributable game data files prepared using the game-data-packager tool.
+ based on ioquake3 and the GPL source releases of RTCW. It also contains
+ the init script and systemd unit to start the RTCW server, with support
+ for multiple server instances under systemd.
+ .
+ Return to Castle Wolfenstein requires non-distributable game data files
+ from the rtcw-data package, prepared using the game-data-packager tool.
Package: rtcw-common
Architecture: linux-any kfreebsd-any hurd-any
@@ -67,8 +74,8 @@ Description: common files for Return to Castle Wolfenstein
(in the wolf4sdl package).
.
This package contains files shared by the game and the dedicated server.
- It requires non-distributable game data files prepared using
- the game-data-packager tool.
+ It requires non-distributable game data files from the rtcw-data package,
+ which can be prepared using the game-data-packager tool.
Package: rtcw-dbg
Architecture: linux-any kfreebsd-any hurd-any
diff --git a/debian/default.cfg b/debian/default.cfg
new file mode 100644
index 0000000..4d6a49d
--- /dev/null
+++ b/debian/default.cfg
@@ -0,0 +1,31 @@
+// Sample server configuration for RTCW in Debian
+//
+// See e.g. http://brian-horning.com/rtcw-server-setup-guide/ for useful
+// commands and variables.
+
+// "dedicated 2" will advertise your server on the public master servers.
+// "dedicated 1" will not.
+//set dedicated 2
+
+seta sv_hostname "An unconfigured Debian server"
+seta g_motd "apt-get install rtcw"
+
+// The port must be different for each server instance. The default is 27960.
+seta net_port 27960
+
+// Game type. If you change this, change the map below too.
+// 5: multiplayer
+// 6: stopwatch
+// 7: checkpoint
+seta g_gametype "5"
+
+// starting map (required)
+// - mp_assault
+// - mp_base
+// - mp_beach (gametype 5 or 6 only)
+// - mp_castle (gametype 5 or 6 only)
+// - mp_depot
+// - mp_destruction (gametype 7 only)
+// - mp_sub
+// - mp_village
+map mp_assault
diff --git a/debian/rtcw-server.README.Debian b/debian/rtcw-server.README.Debian
new file mode 100644
index 0000000..94ca15c
--- /dev/null
+++ b/debian/rtcw-server.README.Debian
@@ -0,0 +1,56 @@
+RTCW dedicated server for Debian
+================================
+
+Running the server
+------------------
+
+Installing the rtcw-server package provides a dedicated server
+running as the user "rtcw-server", from an init script named wolfded.
+This is a simple setup suitable for running one server on a machine.
+
+By default, the server will use etc/rtcw-server/default.cfg,
+which is a symlink to /etc/rtcw-server/default.cfg. You can edit
+this file to reconfigure the default instance.
+
+The server can be managed in the usual way, e.g. via service(8) commands
+like
+
+ service wolfded stop
+ service wolfded start
+
+which should work for all of systemd, sysvinit and upstart.
+
+The whole /etc/rtcw-server directory is symlinked into the engine's
+search path as etc/rtcw-server, so you can place files there and
+execute them with commands like "exec etc/rtcw-server/checkpoint.cfg".
+
+Disabling the server
+--------------------
+
+To disable the default instance, use the facilities provided by your
+init system. The recommended command is
+
+ update-rc.d wolfded disable
+
+which should work for all of systemd, sysvinit and upstart.
+
+Multiple instances under systemd
+--------------------------------
+
+Under systemd, wolfded.service just depends on wolfded at default.service,
+which runs the actual server. You can create an additional instance
+"foo" like this:
+
+- create /etc/rtcw-server/foo.cfg based on /etc/rtcw-server/default.cfg
+ (remember to change the net_port)
+- run "systemctl enable wolfded at foo.service"
+
+You can control individual instances with commands like
+"systemctl start wolfded at foo.service".
+You can also use commands like "systemctl start wolfded.service"
+to start the default instance and all enabled instances.
+
+Non-default instances can be enabled and disabled with systemctl, but
+to disable the default instance, you must either mask the
+default instance ("systemctl mask wolfded at default.service")
+or disable wolfded.service ("systemctl disable wolfded.service").
diff --git a/debian/rtcw-server.install b/debian/rtcw-server.install
index aba6177..38ca730 100644
--- a/debian/rtcw-server.install
+++ b/debian/rtcw-server.install
@@ -1,3 +1,5 @@
debian/build/mp/iowolfded usr/lib/rtcw
debian/build/mp/iowolfded.* usr/lib/rtcw
debian/scripts/wolfded usr/games
+debian/wolfded at .service lib/systemd/system
+debian/default.cfg etc/rtcw-server
diff --git a/debian/rtcw-server.links b/debian/rtcw-server.links
new file mode 100644
index 0000000..b2d5078
--- /dev/null
+++ b/debian/rtcw-server.links
@@ -0,0 +1,2 @@
+# so you can do "exec etc/rtcw-server/default.cfg"
+etc/rtcw-server usr/lib/rtcw/main/etc/rtcw-server
diff --git a/debian/rtcw-server.postinst b/debian/rtcw-server.postinst
new file mode 100644
index 0000000..11a5ec9
--- /dev/null
+++ b/debian/rtcw-server.postinst
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+ configure)
+ if ! getent passwd rtcw-server >/dev/null; then
+ adduser --disabled-password --quiet --system \
+ --home /var/games/rtcw-server --no-create-home \
+ --gecos "Return to Castle Wolfenstein dedicated server" \
+ --ingroup games rtcw-server
+ fi
+ # Unlock account, if it was locked by our postrm
+ if [ -f /etc/shadow ]; then
+ usermod -U -e '' rtcw-server
+ else
+ usermod -U rtcw-server
+ fi
+ install -d /var/games
+ install -d -o rtcw-server -g games /var/games/rtcw-server
+ ;;
+ abort-upgrade|abort-remove|abort-deconfigure)
+ ;;
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+#DEBHELPER#
diff --git a/debian/rtcw-server.postrm b/debian/rtcw-server.postrm
new file mode 100644
index 0000000..a8ca6d8
--- /dev/null
+++ b/debian/rtcw-server.postrm
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+#DEBHELPER#
+
+if [ "$1" = "purge" ] ; then
+ # Lock account on purge
+ if [ -f /etc/shadow ]; then
+ usermod -L -e 1 rtcw-server
+ else
+ usermod -L rtcw-server
+ fi
+ rm -r /var/games/rtcw-server
+ rmdir --ignore-fail-on-non-empty /var/games
+fi
diff --git a/debian/rtcw-server.wolfded.init b/debian/rtcw-server.wolfded.init
new file mode 100644
index 0000000..1e9607a
--- /dev/null
+++ b/debian/rtcw-server.wolfded.init
@@ -0,0 +1,64 @@
+#!/bin/sh
+# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
+if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
+ set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
+fi
+### BEGIN INIT INFO
+# Provides: wolfded rtcw-server
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop:
+# Short-Description: Return to Castle Wolfenstein game server
+# Description: Return to Castle Wolfenstein multiplayer dedicated
+# server using the iortcw engine.
+### END INIT INFO
+
+PACKAGE="rtcw-server"
+NAME="wolfded"
+DESC="Return to Castle Wolfenstein game server"
+DAEMON="/usr/games/$NAME"
+BINARY="/usr/lib/rtcw/$NAME"
+START_ARGS="--background --make-pidfile --chuid ${PACKAGE}"
+DAEMON_ARGS="+exec etc/${PACKAGE}/default.cfg"
+
+# The init script corresponds to the "default" systemd instance
+HOME="/var/games/$PACKAGE/default.home"
+XDG_DATA_HOME="$HOME"
+XDG_CACHE_HOME="$HOME/cache"
+XDG_CONFIG_HOME="$HOME/config"
+export HOME XDG_DATA_HOME XDG_CACHE_HOME XDG_CONFIG_HOME
+
+# Return
+# 0 if daemon has been started
+# 1 if daemon was already running
+# 2 if daemon could not be started
+do_start_cmd() {
+ start-stop-daemon --start --quiet ${PIDFILE:+--pidfile ${PIDFILE}} \
+ $START_ARGS \
+ --startas $DAEMON --name $NAME --exec $BINARY --test > /dev/null \
+ || return 1
+ start-stop-daemon --start --quiet ${PIDFILE:+--pidfile ${PIDFILE}} \
+ $START_ARGS \
+ --startas $DAEMON --name $NAME --exec $BINARY -- $DAEMON_ARGS \
+ || return 2
+}
+
+# Return
+# 0 if daemon has been stopped
+# 1 if daemon was already stopped
+# 2 if daemon could not be stopped
+# other if a failure occurred
+do_stop_cmd() {
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
+ $STOP_ARGS \
+ ${PIDFILE:+--pidfile ${PIDFILE}} --name $NAME --exec $BINARY
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ rm -f $PIDFILE
+ return $RETVAL
+}
+
+do_status() {
+ status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && return 0 || return $?
+}
diff --git a/debian/rtcw-server.wolfded.service b/debian/rtcw-server.wolfded.service
new file mode 100644
index 0000000..9c4af56
--- /dev/null
+++ b/debian/rtcw-server.wolfded.service
@@ -0,0 +1,15 @@
+# This service is actually more like a systemd target,
+# but we are using a service so it will mask the init script.
+[Unit]
+Description=Return to Castle Wolfenstein game server(s)
+After=network.target
+Wants=wolfded at default.service
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/bin/true
+
+[Install]
+WantedBy=multi-user.target
+Alias=rtcw-server.service
diff --git a/debian/rules b/debian/rules
index 753b3df..c503ec0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -13,7 +13,7 @@ Q3COMPILE_PLATFORM := $(shell $(CURDIR)/debian/q3arch platform BUILD)
distro := $(shell lsb_release -is)
%:
- dh $@ --parallel
+ dh $@ --parallel --with=systemd
ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
TARGET = release
@@ -79,6 +79,12 @@ override_dh_auto_build:
convert debian/32/wolfsp.png debian/wolfsp.xpm
convert debian/32/wolfmp.png debian/wolfmp.xpm
+override_dh_systemd_enable:
+ dh_systemd_enable -prtcw-server --name=wolfded
+
+override_dh_installinit:
+ dh_installinit -prtcw-server --name=wolfded
+
override_dh_strip:
dh_strip --dbg-package=rtcw-dbg
diff --git a/debian/wolfded at .service b/debian/wolfded at .service
new file mode 100644
index 0000000..28d90db
--- /dev/null
+++ b/debian/wolfded at .service
@@ -0,0 +1,22 @@
+[Unit]
+Description=Return to Castle Wolfenstein game server - %i configuration
+PartOf=wolfded.service
+Before=wolfded.service
+After=network.target
+ConditionPathExists=/etc/rtcw-server/%i.cfg
+
+[Service]
+Environment=HOME=/var/games/rtcw-server/%i.home
+Environment=XDG_DATA_HOME=/var/games/rtcw-server/%i.home
+Environment=XDG_CACHE_HOME=/var/games/rtcw-server/%i.home/cache
+Environment=XDG_CONFIG_HOME=/var/games/rtcw-server/%i.home/config
+ExecStart=/usr/games/wolfded +exec etc/rtcw-server/%i.cfg
+Restart=on-failure
+RestartPreventExitStatus=72
+
+[Install]
+WantedBy=multi-user.target
+# We deliberately do not set DefaultInstance so that
+# "update-rc.d wolfded disable" -> "systemctl disable wolfded.service"
+# results in wolfded at default.service not being started unless explicitly
+# requested.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git
More information about the Pkg-games-commits
mailing list