[game-data-packager] 158/293: Add a quake-server binary package with the server

Simon McVittie smcv at debian.org
Fri Oct 14 00:12:09 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch quake
in repository game-data-packager.

commit dcfe7400880d2b2fdfa08437637c2337e48ae3af
Author: Simon McVittie <smcv at debian.org>
Date:   Thu Jul 14 22:14:58 2011 +0100

    Add a quake-server binary package with the server
---
 .gitignore                        |  1 +
 Makefile                          | 17 +++++++-
 debian/.gitignore                 |  1 +
 debian/changelog                  |  1 +
 debian/control                    | 14 ++++++
 debian/quake-server.README.Debian | 62 +++++++++++++++++++++++++++
 debian/quake-server.default       |  9 ++++
 debian/quake-server.init          | 90 +++++++++++++++++++++++++++++++++++++++
 debian/quake-server.install       |  2 +
 debian/quake-server.links         |  1 +
 debian/quake-server.manpages      |  1 +
 debian/quake-server.postinst      | 26 +++++++++++
 debian/quake-server.postrm        | 12 ++++++
 debian/server.cfg                 | 16 +++++++
 quake.6 => quake-server.6         | 29 +++++--------
 quake.6                           |  1 +
 quake.sh => quake.in              | 20 ++++++---
 17 files changed, 275 insertions(+), 28 deletions(-)

diff --git a/.gitignore b/.gitignore
index 62bb444..4868106 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,5 +5,6 @@
 /48/
 /256/
 /quake
+/quake-server
 /quake.xpm
 /quake.svg
diff --git a/Makefile b/Makefile
index df55eef..c9c105e 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,7 @@
 
 obj = \
 	quake \
+	quake-server \
 	quake.xpm \
 	16/quake.png \
 	22/quake.png \
@@ -13,8 +14,20 @@ obj = \
 
 all: $(obj)
 
-quake: quake.sh
-	cp $< $@
+quake: quake.in
+	sed -e 's/@self@/quake/g' \
+		-e 's/@role@/client/g' \
+		-e 's/@options@//g' \
+		-e 's/@alternative@/quake-engine/g' \
+		< $< > $@
+	chmod +x $@
+
+quake-server: quake.in
+	sed -e 's/@self@/quake-server/g' \
+		-e 's/@role@/server/g' \
+		-e 's/@options@/-dedicated/g' \
+		-e 's/@alternative@/quake-engine-server/g' \
+		< $< > $@
 	chmod +x $@
 
 24/quake.png: 22/quake.png
diff --git a/debian/.gitignore b/debian/.gitignore
index 8cb4f01..a7cdeda 100644
--- a/debian/.gitignore
+++ b/debian/.gitignore
@@ -1,5 +1,6 @@
 /*.debhelper.log
 /*.post*.debhelper
+/*.pre*.debhelper
 /*.substvars
 /files
 /changelog.dch
diff --git a/debian/changelog b/debian/changelog
index 8a077c3..49a44fd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -19,5 +19,6 @@ quake (1) UNRELEASED; urgency=low
   * Give the script a --engine switch to force a particular engine
   * Include menu entries for the mission packs, which are automatically
     hidden if the corresponding data files are not installed
+  * Add a quake-server binary package
 
  -- David Banks <amoebae at gmail.com>  Wed, 01 Jun 2011 17:02:39 +0100
diff --git a/debian/control b/debian/control
index 2ccbeb9..a9ace42 100644
--- a/debian/control
+++ b/debian/control
@@ -27,3 +27,17 @@ Description: classic first person shooter
  CD-ROM.
  .
  Creating quake-shareware requires the shareware version of Quake.
+
+Package: quake-server
+Architecture: all
+Depends: adduser,
+         quakespasm | quake-engine-server,
+         quake-registered | quake-shareware | game-data-packager,
+         ${misc:Depends}
+Description: classic first person shooter - server and init script
+ This package contains a launcher script and init script to run a
+ Quake 1 server automatically, with any suitable engine.
+ .
+ To make this package useful, you will need to create and install the
+ non-distributable quake-registered or quake-shareware package, by using the
+ game-data-packager package.
diff --git a/debian/quake-server.README.Debian b/debian/quake-server.README.Debian
new file mode 100644
index 0000000..ea858df
--- /dev/null
+++ b/debian/quake-server.README.Debian
@@ -0,0 +1,62 @@
+Quake dedicated server for Debian
+=================================
+
+Running the server via sysvinit
+-------------------------------
+
+By default, quake-server adds a user under which to run the dedicated server
+(quake-server) and sets it up to be run by an init script in the conventional
+Debian way. This is a simple setup suitable for running one server on a
+machine; by default it will run a deathmatch game.
+
+The quake-server user's home directory is /var/games/quake-server, so you
+can find Quake files in /var/games/quake-server/.quakespasm,
+/var/games/quake-server/.darkplaces or whatever.
+
+By default, the init script will use
+/usr/share/games/quake/id1/debian_server.cfg, which is a symlink to
+/etc/quake-server/server.cfg. You can edit this file, or put an alternative
+configuration in /var/games/quake-server/.quakespasm/id1 (or whatever is the
+appropriate directory for your selected engine) and change
+/etc/default/quake-server to exec that.
+
+There are various alternative ways you can run the server if this doesn't
+meet your requirements.
+
+Disabling the init script
+-------------------------
+
+To stop the server:
+
+    /etc/init.d/quake-server stop
+
+To prevent it from running again, either edit /etc/default/quake-server
+and set START_DAEMON to 0, or use update-rc.d:
+
+    update-rc.d quake-server disable
+
+Running the server with cron and screen
+---------------------------------------
+
+One alternative way to run the server is to run it in a screen(1) session
+from a cron @reboot action. This can be used to run multiple instances
+of the server; you'll need to set a different port number on each server after
+the first, and it's safest to give each server a unique home directory so they
+don't overwrite each other's configuration files.
+
+To do this, you could put something like this in the quake-server user's
+crontab (don't break the long lines!):
+
+    @reboot screen -d -m -S ffa env HOME=/var/games/quake-server/ffa /usr/games/quake-server +exec ffa.config
+    @reboot screen -d -m -S ctf env HOME=/var/games/quake-server/ctf /usr/games/quake-server -port 54321 +exec ctf.config
+
+or in /etc/crontab or a file in /etc/cron.d:
+
+    @reboot quake-server screen -d -m -S ffa env HOME=/var/games/quake-server/ffa /usr/games/quake-server +exec ffa.config
+    @reboot quake-server screen -d -m -S ctf env HOME=/var/games/quake-server/ctf /usr/games/quake-server -port 54321 +exec ctf.config
+
+If you do that, you can access the servers' consoles by attaching a screen
+session to them:
+
+    sudo -u quake-server screen -r ffa
+    sudo -u quake-server screen -r ctf
diff --git a/debian/quake-server.default b/debian/quake-server.default
new file mode 100644
index 0000000..ab2ce2d
--- /dev/null
+++ b/debian/quake-server.default
@@ -0,0 +1,9 @@
+# Defaults for Quake init script
+# sourced by /etc/init.d/quake-server
+# installed at /etc/default/quake-server by the maintainer scripts
+
+# set to 1 to enable
+START_DAEMON=1
+
+# Additional options that are passed to the daemon.
+DAEMON_OPTS="+exec debian_server.cfg"
diff --git a/debian/quake-server.init b/debian/quake-server.init
new file mode 100644
index 0000000..638dd53
--- /dev/null
+++ b/debian/quake-server.init
@@ -0,0 +1,90 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          quake-server
+# Required-Start:    $remote_fs $network
+# Required-Stop:     $remote_fs $network
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start Quake game server
+### END INIT INFO
+
+PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
+NAME="quake-server"
+DAEMON="/usr/games/$NAME"
+DESC="Quake dedicated server"
+PIDFILE="/var/run/$NAME.pid"
+BINARY="/usr/lib/quake/quake-engine-server"
+USER="$NAME"
+
+test -x $DAEMON || exit 0
+
+. /lib/lsb/init-functions
+
+# Include defaults if available
+if [ -f /etc/default/$NAME ] ; then
+	. /etc/default/$NAME
+fi
+
+do_start() {
+    if [ -f $PIDFILE ]; then
+        return 2
+    fi
+    if [ "$START_DAEMON" != 1 ]; then
+        echo -n " (not starting - disabled in /etc/default/$NAME)"
+        return 0
+    fi
+    start-stop-daemon --start --quiet --pidfile $PIDFILE --oknodo \
+	--background --exec $BINARY --startas $DAEMON \
+	--make-pidfile --chuid $USER \
+	-- $DAEMON_OPTS > /dev/null 2>&1 || return 1
+    return 0
+}
+
+do_stop() {
+    start-stop-daemon --stop --quiet --pidfile $PIDFILE \
+	--oknodo --exec $BINARY || return 1
+    rm -f $PIDFILE
+    return 0
+}
+
+case "$1" in
+    start)
+        log_begin_msg "Starting $DESC: $NAME"
+	do_start
+        log_end_msg $?
+	;;
+    stop)
+        log_begin_msg "Stopping $DESC: $NAME"
+	do_stop
+        log_end_msg $?
+	;;
+    #reload)
+	#
+	#	If the daemon can reload its config files on the fly
+	#	for example by sending it SIGHUP, do it here.
+	#
+	#	If the daemon responds to changes in its config file
+	#	directly anyway, make this a do-nothing entry.
+	#
+	# echo "Reloading $DESC configuration files."
+	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
+	#	/var/run/$NAME.pid --exec $DAEMON
+        #;;
+    restart|force-reload)
+	#
+	#	If the "reload" option is implemented, move the "force-reload"
+	#	option to the "reload" entry above. If not, "force-reload" is
+	#	just the same as "restart".
+	#
+        log_begin_msg "Restarting $DESC: $NAME"
+	do_stop && sleep 1 && do_start
+        log_end_msg $?
+	;;
+    *)
+	# echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
+	echo "Usage: $0 {start|stop|restart|force-reload}" >&2
+	exit 1
+	;;
+esac
+
+exit 0
diff --git a/debian/quake-server.install b/debian/quake-server.install
new file mode 100644
index 0000000..d6292bb
--- /dev/null
+++ b/debian/quake-server.install
@@ -0,0 +1,2 @@
+quake-server   /usr/games
+debian/server.cfg /etc/quake-server
diff --git a/debian/quake-server.links b/debian/quake-server.links
new file mode 100644
index 0000000..c42451a
--- /dev/null
+++ b/debian/quake-server.links
@@ -0,0 +1 @@
+etc/quake-server/server.cfg usr/share/games/quake/id1/debian_server.cfg
diff --git a/debian/quake-server.manpages b/debian/quake-server.manpages
new file mode 100644
index 0000000..a3f11e7
--- /dev/null
+++ b/debian/quake-server.manpages
@@ -0,0 +1 @@
+quake-server.6
diff --git a/debian/quake-server.postinst b/debian/quake-server.postinst
new file mode 100644
index 0000000..e0319b3
--- /dev/null
+++ b/debian/quake-server.postinst
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+  configure)
+    if ! getent passwd quake-server >/dev/null; then
+      adduser --disabled-password --quiet --system \
+        --home /var/games/quake-server --no-create-home \
+        --gecos "Quake dedicated server" \
+	--ingroup games --force-badname quake-server
+    fi
+    # Unlock account, if it was locked by our postrm
+    usermod -U -e '' quake-server
+    install -d /var/games
+    install -d -o quake-server -g games /var/games/quake-server
+  ;;
+  abort-upgrade|abort-remove|abort-deconfigure)
+  ;;
+  *)
+    echo "postinst called with unknown argument \`$1'" >&2
+    exit 1
+  ;;
+esac
+
+#DEBHELPER#
diff --git a/debian/quake-server.postrm b/debian/quake-server.postrm
new file mode 100644
index 0000000..3f84523
--- /dev/null
+++ b/debian/quake-server.postrm
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+
+#DEBHELPER#
+
+if [ "$1" = "purge" ] ; then
+    # Lock account on purge
+    usermod -L -e 1 quake-server
+    rm -r /var/games/quake-server
+    rmdir --ignore-fail-on-non-empty /var/games
+fi
diff --git a/debian/server.cfg b/debian/server.cfg
new file mode 100644
index 0000000..d431250
--- /dev/null
+++ b/debian/server.cfg
@@ -0,0 +1,16 @@
+// Example Quake server configuration for Debian
+// This is installed into /etc/quake-server/server.cfg and symlinked into
+// the game directory as debian_server.cfg, so you can run it via:
+//
+//     exec debian_server.cfg
+
+deathmatch 1
+hostname "An anonymous Debian server"
+timelimit 30
+fraglimit 30
+map dm1
+
+// Various options depend on the server version you're using.
+// When using darkplaces-server, you can use "sv_public 1" to advertise
+// your server to the "master servers"
+// sv_public 0
diff --git a/quake.6 b/quake-server.6
similarity index 77%
copy from quake.6
copy to quake-server.6
index fe6f623..e073d3b 100644
--- a/quake.6
+++ b/quake-server.6
@@ -2,7 +2,7 @@
 .\" First parameter, NAME, should be all caps
 .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
 .\" other parameters are allowed: see man(7), man(1)
-.TH QUAKE 6 "2011-06-22"
+.TH QUAKE\-SERVER 6 "2011-06-22"
 .\" Please adjust this date whenever revising the manpage.
 .\"
 .\" Some roff macros, for reference:
@@ -16,24 +16,26 @@
 .\" .sp <n>    insert n+1 empty lines
 .\" for manpage-specific macros, see man(7)
 .SH NAME
-quake \- classic first person shooter
+quake\-server \- dedicated server for Quake
 .SH SYNOPSIS
-.B quake
+.B quake\-server
 .RI [ WRAPPER-OPTIONS ]
 .RI [ ENGINE-OPTIONS ]
 .RI [ ENGINE-COMMANDS ] ...
 .br
 .SH DESCRIPTION
 This manual page documents briefly the
-.B quake
+.B quake\-server
 command.
 .PP
 .\" TeX users may be more comfortable with the \fB<whatever>\fP and
 .\" \fI<whatever>\fP escape sequences to invode bold face and italics,
 .\" respectively.
 \fBQuake\fP is a popular first-person shooter game that appeared in 1996,
-released by iD Software.  This wrapper script will launch the Quake engine.  The
-game data needs to be installed independently using the 'game-data-packager'
+released by iD Software.  This wrapper script will launch the Quake
+dedicated server.
+.PP
+The game data needs to be installed independently using the 'game-data-packager'
 program, and by default it will be looked for at \fI/usr/share/games/quake\fR.
 .PP
 This wrapper script accepts the two common GNU-style options to get information
@@ -51,21 +53,10 @@ Show summary of options.
 .TP
 .B \-v, \-\-version
 Show version of program.
-.SH EXAMPLES
-These are all engine dependent.
-.TP
-Play the Zerstoerer mod:
-.B quake -game zer
-.TP
-Play a specific map using the Drake expansion:
-.B quake -game drake +map sludge1
-.TP
-Connect to a server for multiplayer:
-.B quake +connect dm.quakeone.net:27000
 .SH SEE ALSO
+.BR quake (6),
 .BR quakespasm (6),
 .BR game-data-packager (6).
 .SH AUTHOR
 This manual page, and the Quake wrapper script, were written by David Banks
-<amoebae at gmail.com>, for the Debian project (and may be used by others).  The
-package was based on the \fBquake3\fR package by Simon McVittie.
+and Simon McVittie for the Debian project (and may be used by others).
diff --git a/quake.6 b/quake.6
index fe6f623..987f8ed 100644
--- a/quake.6
+++ b/quake.6
@@ -63,6 +63,7 @@ Play a specific map using the Drake expansion:
 Connect to a server for multiplayer:
 .B quake +connect dm.quakeone.net:27000
 .SH SEE ALSO
+.BR quake-server (6),
 .BR quakespasm (6),
 .BR game-data-packager (6).
 .SH AUTHOR
diff --git a/quake.sh b/quake.in
similarity index 73%
rename from quake.sh
rename to quake.in
index 8c0e586..b080269 100644
--- a/quake.sh
+++ b/quake.in
@@ -2,9 +2,12 @@
 
 # quake.sh - launcher script for quake 1
 
+self="@self@"
+role="@role@"
+options="@options@"
 data_location=/usr/share/games/quake
-engine_path=/usr/lib/quake/quake-engine
-no_data_msg="Missing data; see /usr/share/doc/quake/README.Debian"
+engine_path=/usr/lib/quake/@alternative@
+no_data_msg="Missing data; see /usr/share/doc/${self}/README.Debian"
 
 main() {
     while [ $# -gt 0 ]; do
@@ -34,15 +37,19 @@ main() {
     done
 
     if ! [ -f "${data_location}/id1/pak0.pak" ]; then
-        exec "$data_location"/need-data.sh "$no_data_msg"
+        if test "${role}" = server; then
+            echo "$no_data_msg"
+        else
+            exec "$data_location"/need-data.sh "$no_data_msg"
+        fi
     fi
     
-    exec ${engine_path} -basedir ${data_location} "$@"
+    exec ${engine_path} -basedir ${data_location} ${options} "$@"
 }
 
 show_help() {
-    echo "Usage: quake [-h|--help] [-v|--version] [ARG1] [ARG2] ..."
-    echo "Launch Quake."
+    echo "Usage: ${self} [-h|--help] [-v|--version] [ARG1] [ARG2] ..."
+    echo "Launch Quake ${role}."
     echo
     echo "This script supports these options:"
     echo "  -h, --help       show this help information"
@@ -61,4 +68,3 @@ show_version() {
 }
 
 main "$@"
-

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git



More information about the Pkg-games-commits mailing list