aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorDian Fay2019-12-18 22:22:35 -0500
committerDian Fay2019-12-18 22:36:17 -0500
commitcecf43e8ea864127169845bd1f2c9fdf974514f2 (patch)
treea759b3655697492524354905cb70040ecfdd623b
parent71e2cb86487dc3b4778e900eec872b386e515e64 (diff)
downloadaur-cecf43e8ea864127169845bd1f2c9fdf974514f2.tar.gz
revamp for Dominions 5
-rw-r--r--.SRCINFO35
-rw-r--r--PKGBUILD41
-rw-r--r--README.md26
-rwxr-xr-xbuild2
-rwxr-xr-xdom4272
-rwxr-xr-xdom4-server31
-rw-r--r--dom4-server.install55
-rw-r--r--dom4-sysusers.conf1
-rw-r--r--dom4-tmpfile.conf1
-rwxr-xr-xdominions282
-rwxr-xr-xdominions-server35
-rw-r--r--dominions-server.install55
-rw-r--r--dominions-server.service (renamed from dom4-server.service)6
-rw-r--r--dominions-sysusers.conf1
-rw-r--r--dominions-tmpfile.conf1
15 files changed, 430 insertions, 414 deletions
diff --git a/.SRCINFO b/.SRCINFO
index e8d1155ba21e..1f48e3ccf4a0 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,22 +1,23 @@
-pkgbase = dom4-server
- pkgdesc = Configure and run Dominions 4 as a headless server
- pkgver = 1.1.5
+pkgbase = dominions-server
+ pkgdesc = Configure and run Dominions 5 as a headless server
+ pkgver = 5
pkgrel = 1
- url = http://www.illwinter.com/dom4/
- install = dom4-server.install
+ url = http://www.illwinter.com/dom5/
+ install = dominions-server.install
arch = x86_64
license = MIT
- depends = steamcmd
- source = dom4-server
- source = dom4-server.service
- source = dom4-sysusers.conf
- source = dom4-tmpfile.conf
- source = dom4
- md5sums = 372f6150c891165d1c1dc3a26477c7de
- md5sums = 7c6722df4f73b19e0db3c365f89eec96
- md5sums = e9772a237cc540558e74235b98df8a7f
- md5sums = 338b8462868ecf6cc56c4a520cea6bac
- md5sums = 219c9aca46b988f031200263bcacc4de
+ replaces = dom4-server
+ source = dominions-server
+ source = dominions-server.service
+ source = dominions-sysusers.conf
+ source = dominions-tmpfile.conf
+ source = dominions
+ md5sums = 1c50c7bf2b0bd067f1749c9153bd4c36
+ md5sums = 8194de8c40005e24334d6c402fcc97e1
+ md5sums = b1db7bda72a917fed819d1251361b1ca
+ md5sums = 0c20183b083e3927a5a49771cd530004
+ md5sums = 5ecfb39e75cb603afaeaae8a32921288
+ depends_x86_64 = steamcmd
-pkgname = dom4-server
+pkgname = dominions-server
diff --git a/PKGBUILD b/PKGBUILD
index 43982c038580..7324bfa717dc 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,33 +1,34 @@
-# Dominions 4 Server Configuration
+# Dominions Server Configuration
# Maintainer: Dian Fay <dian.m.fay@gmail.com>
-pkgname=dom4-server
-pkgver=1.1.5
+pkgname=dominions-server
+pkgver=5
pkgrel=1
-pkgdesc="Configure and run Dominions 4 as a headless server"
+pkgdesc="Configure and run Dominions 5 as a headless server"
arch=("x86_64")
-url="http://www.illwinter.com/dom4/"
+url="http://www.illwinter.com/dom5/"
license=("MIT")
install=$pkgname.install
depends_x86_64=("steamcmd")
source=(
- dom4-server
- dom4-server.service
- dom4-sysusers.conf
- dom4-tmpfile.conf
- dom4
+ dominions-server
+ dominions-server.service
+ dominions-sysusers.conf
+ dominions-tmpfile.conf
+ dominions
)
+replaces=("dom4-server")
package() {
- install -Dm744 "$srcdir/dom4-server" "$pkgdir/usr/bin/dom4-server"
- install -Dm644 "$srcdir/dom4-server.service" "$pkgdir/usr/lib/systemd/system/dom4-server.service"
+ install -Dm744 "$srcdir/dominions-server" "$pkgdir/usr/bin/dominions-server"
+ install -Dm644 "$srcdir/dominions-server.service" "$pkgdir/usr/lib/systemd/system/dominions-server.service"
- install -Dm755 "$srcdir/dom4" "$pkgdir/usr/bin/dom4"
+ install -Dm755 "$srcdir/dominions" "$pkgdir/usr/bin/dominions"
- install -Dm644 "$srcdir/dom4-sysusers.conf" "$pkgdir/usr/lib/sysusers.d/dom4.conf"
- install -Dm644 "$srcdir/dom4-tmpfile.conf" "$pkgdir/usr/lib/tmpfiles.d/dom4.conf"
+ install -Dm644 "$srcdir/dominions-sysusers.conf" "$pkgdir/usr/lib/sysusers.d/dominions.conf"
+ install -Dm644 "$srcdir/dominions-tmpfile.conf" "$pkgdir/usr/lib/tmpfiles.d/dominions.conf"
}
-md5sums=('372f6150c891165d1c1dc3a26477c7de'
- '7c6722df4f73b19e0db3c365f89eec96'
- 'e9772a237cc540558e74235b98df8a7f'
- '338b8462868ecf6cc56c4a520cea6bac'
- '219c9aca46b988f031200263bcacc4de')
+md5sums=('1c50c7bf2b0bd067f1749c9153bd4c36'
+ '8194de8c40005e24334d6c402fcc97e1'
+ 'b1db7bda72a917fed819d1251361b1ca'
+ '0c20183b083e3927a5a49771cd530004'
+ '5ecfb39e75cb603afaeaae8a32921288')
diff --git a/README.md b/README.md
index 18f98916ee2a..291055161aba 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,16 @@
-# Dominions 4 Headless Server
+# Dominions Headless Server
## Installing
-Install this package (`dom4-server`) using your AUR package manager of choice, or `makepkg`.
+Install this package (`dominions-server`) using your AUR package manager of choice, or `makepkg`.
### Application
```bash
-dom4 install
+dominions install
```
-You will need to enter your Steam user ID, password, and Dominions 4 license key when prompted. SteamCMD may ask you to authenticate through Steam Guard.
+You will need to enter your Steam user ID, password, and Dominions license key when prompted. SteamCMD may ask you to authenticate through Steam Guard.
### Network
@@ -20,27 +20,27 @@ If your computer is behind a router you will need to make sure the port is forwa
## Usage
-Most of the game configuration is accomplished through the `dom4` program. Run it without arguments for detailed usage instructions.
+Most of the game configuration is accomplished through the `dominions` program. Run it without arguments for detailed usage instructions.
-The actual game server is set up as a systemd service and can be managed via systemctl like any other service.
+The actual game server is set up as a systemd service and can be started, stopped, enabled, or disabled via systemctl like any other service.
### Configuration
```bash
-dom4 config mygame
+dominions config mygame
```
-Edit the file as desired and save. The `mapfile` should reference a file either in the current directory or in *your* `~/dominions4/maps` directory. Once you have a game configured:
+Edit the file as desired and save. The `mapfile` should reference a file either in the current directory or in *your* `~/dominions/maps` directory. Once you have a game configured:
-1. `sudo systemctl start dom4-server` starts the server in pretender upload mode.
+1. `sudo systemctl start dominions-server` starts the server in pretender upload mode.
1. If `uploadmaxp` or `uploadtime` are set in your configuration, you're done: the game will start automatically when the appropriate limit is reached.
-1. Once everyone has uploaded their pretenders, `dom4 ready` sets the game start flag. You can `dom4 ready mygame` to specify a game to host regardless of what was last configured.
-1. Restart the server using `sudo systemctl restart dom4-server` to begin the game.
+1. Once everyone has uploaded their pretenders, `dominions ready` sets the game start flag. You can `dominions ready mygame` to specify a game to host regardless of what was last configured.
+1. Restart the server using `sudo systemctl restart dominions-server` to begin the game.
-You may also want to `sudo systemctl enable dom4-server` in order to start the server automatically after reboots.
+You may also want to `sudo systemctl enable dominions-server` in order to start the server automatically after reboots.
Note that only one game may be served at a time. If you configure or ready a new game, you will be asked if you want to host it instead of the current game. Any existing configuration will be preserved.
### Deleting Games
-`dom4 delete mygame` removes the properties file and save directory. Maps are not removed.
+`dominions delete mygame` removes the properties file and save directory. Maps are not removed.
diff --git a/build b/build
index fac05bfefc8e..75cf536625c6 100755
--- a/build
+++ b/build
@@ -1,4 +1,4 @@
-sudo pacman -R dom4-server <<< "Y"
+sudo pacman -R dominions-server <<< "Y"
updpkgsums
makepkg -cf
makepkg --printsrcinfo > .SRCINFO
diff --git a/dom4 b/dom4
deleted file mode 100755
index 466f2f919e7e..000000000000
--- a/dom4
+++ /dev/null
@@ -1,272 +0,0 @@
-#!/bin/bash
-
-# List all configured games.
-function list {
- ls /usr/share/dom4/config | cut -d "." -f 1
-}
-
-# Install Dominions 4 via SteamCMD.
-function install {
- if [ ! $(find /opt/dom4 -maxdepth 0 -type d -empty 2>/dev/null) ];then
- echo "/opt/dom4 is not empty. Is Dominions 4 already installed?"
- exit 0
- fi
-
- read -r -p "Steam username: " user
- read -r -s -p "Steam password: " pass
-
- echo
- echo "Installing Dominions 4 to /opt/dom4..."
-
- sudo -u dom4 steamcmd +login $user $pass +force_install_dir /opt/dom4 +app_update 259060 validate +quit
-
- read -r -p "Enter your Dominions 4 license key: " key
- echo $key | sudo -u dom4 tee /opt/dom4/dom4key > /dev/null
-
- echo "Copied license information to Dominions 4 install directory."
- echo "Installation complete. Use 'dom4 config' to set up a game."
-}
-
-# Change the current hosted game by editing /usr/share/dom4/current.
-# Params:
-# $1 game name
-function change {
- if [[ -s /usr/share/dom4/current ]]; then
- game=$(</usr/share/dom4/current)
-
- if [[ $1 != $game ]]; then
- read -r -n 2 -p "Currently hosting $game. Set up to host $1 instead? [Y/n] " ovr
- if [[ $ovr != Y ]]; then
- exit 0
- fi
- echo
- fi
- fi
-
- echo "Setting $1 up for hosting."
- echo
- echo "$1" | sudo -u dom4 tee /usr/share/dom4/current > /dev/null
-}
-
-# Load a properties file.
-# Params:
-# $1 path to properties file
-function config {
- if [[ -z $1 ]]; then
- cat <<EOF
-Usage:
-
- dom4 config mygame
-EOF
- exit 1
- fi
-
- if [[ -s "/usr/share/dom4/config/$1.properties" ]]; then
- read -r -n 2 -p "$1 is already configured. Edit this game? [Y/n] " ovr
- if [[ $ovr != Y ]]; then
- exit 0
- fi
-
- echo
- else
- newgame=true
- cat << EOF | sudo -u dom4 tee /usr/share/dom4/config/$1.properties > /dev/null
-# See http://www.illwinter.com/dom4/startoptions.pdf for a full reference.
-# Sections 3-5, 3-6, and 3-7 are especially relevant. Switches should be
-# reproduced as given in the documentation, without any leading dashes (so to
-# pass the '--era 1' setting to the server, include the line 'era 1' in this
-# file).
-
-# SERVER INFO
-
-# Port number must be between 1024 and 65535, and forwarded in your router
-# config. Master password is not required but useful if you want to be able to
-# set dropped-out players to computer control.
-
-port 6666
-masterpass supersecure
-
-# GAME SETTINGS
-
-# The mapfile is required. Any .rgb or image files must have the same filename
-# and differ only in extension since the map data is automatically copied over.
-
-mapfile my_pretty_world.map
-hours 26
-era 1
-renaming
-storyevents
-hofsize 15
-requiredap 13
-thrones 2 8 1
-EOF
- fi
-
- sudo -u dom4 ${EDITOR:-nano} /usr/share/dom4/config/$1.properties
-
- mapfile=$(grep -oP "^mapfile\s+\K.+" /usr/share/dom4/config/$1.properties)
- mapname=$(basename $mapfile .map)
-
- if [ "$newgame" = true ]; then
- if [[ -s "$mapname.map" ]]; then
- echo "Copying $mapname map files..."
-
- sudo cp "$mapname".* /usr/share/dom4/maps
- elif [[ -s "$HOME/dominions4/maps/$mapname".map ]]; then
- echo "Copying $mapname map files from $HOME/dominions4/maps..."
-
- sudo cp "$HOME/dominions4/maps/$mapname".* /usr/share/dom4/maps
- else
- echo "Could not find $mapname.map in $(pwd) or $HOME/dominions4/maps. Please ensure the map file(s) exist in one or the other location and try again."
-
- exit 1;
- fi
-
- echo
-
- change $1
-
- cat <<EOF
-Done. Start the service to let players upload their pretenders.
-
- sudo systemctl start dom4-server.service
-
-Once all pretenders have been uploaded, stop the service and set the game to ready.
-
- dom4 ready
-EOF
- else
- change $1
-
- cat <<EOF
-Done. Restart the service to load the new configuration:
-
- sudo systemctl restart dom4-server.service
-EOF
- fi
-}
-
-# Set game start flag in properties file.
-# Params:
-# $1 game name (optional; uses whatever's in current if not supplied)
-function ready {
- if [[ ! -z $1 ]]; then
- if [[ ! -s "/usr/share/dom4/config/$1.properties" ]]; then
- echo "No game named '$1' found."
-
- exit 1
- fi
-
- change $1
- elif [[ ! -s /usr/share/dom4/current ]]; then
- echo "No game configured. Use 'dom4 config' to set up a game."
-
- exit 1
- fi
-
- game=$(</usr/share/dom4/current)
-
- if [[ ! -d "/usr/share/dom4/savedgames/$game" ]]; then
- echo "No pretenders uploaded for $game. Start the service with systemctl to let players upload."
-
- exit 1
- fi
-
- if [[ -s "/usr/share/dom4/savedgames/$game/ftherlnd" ]]; then
- echo "$game has already been started. If the service is not running, start it with systemctl."
-
- exit 0
- fi
-
- players=$(ls -1 /usr/share/dom4/savedgames/$game/*.2h | wc -l)
-
- if grep -qE "uploadtime|uploadmaxp" /usr/share/dom4/config/$game.properties ; then
- echo "Upload flag already set for $game. Start the service with systemctl."
-
- exit 0
- fi
-
- echo "Setting start flag for $game ($players players)"
-
- echo "uploadmaxp $players" | sudo -u dom4 tee -a "/usr/share/dom4/config/$game.properties" > /dev/null
-
- cat <<EOF
-
-Flag set. Start the dom4-server service to begin the game.
-
- sudo systemctl start dom4-server.service
-
-You may wish to enable it as well to ensure it restarts on boot.
-EOF
-}
-
-function delete {
- if [[ -z $1 ]]; then
- echo "Specify a game name to delete."
- exit 0
- fi
-
- if [[ -s /usr/share/dom4/current ]]; then
- game=$(</usr/share/dom4/current)
-
- if [[ $game = $1 ]]; then
- read -r -n 2 -p "$game is currently being hosted. Really delete? [Y/n] " ovr
- if [[ $ovr != Y ]]; then
- exit 0
- fi
-
- sudo -u dom4 rm /usr/share/dom4/current
- fi
- fi
-
- # leave the mapfile in case something else is using it
- sudo -u dom4 rm /usr/share/dom4/config/$1.properties
- sudo -u dom4 rm -rf /usr/share/dom4/savedgames/$1
-
- echo "Deleted $1."
-}
-
-case $1 in
- "list")
- list
- ;;
-
- "install")
- install
- ;;
-
- "config" | "configure")
- config "${@:2}"
- ;;
-
- "ready")
- ready "${@:2}"
- ;;
-
- "delete")
- delete "${@:2}"
- ;;
-
- *)
- cat <<EOF
-Dominions 4 Headless Server Interface
-
-This program manages Dominions 4 installation and configuration for the headless server. Multiple games may be configured, but only one game can be actively hosted at once -- this is a true multiplayer server rather than a PBEM setup.
-
-The headless server itself is a systemd service and can be managed via systemctl.
-
-Usage:
- dom4 install Install Dominions 4 through SteamCMD
- dom4 list List configured games
- dom4 config mygame Configure a new game, or edit an existing one
- dom4 ready mygame Sets the start flag for mygame after all pretenders have been uploaded
- dom4 delete mygame Deletes mygame (this operation is irreversible!)
-
-Service commands:
- sudo systemctl start dom4-server.service
- sudo systemctl stop dom4-server.service
- sudo systemctl restart dom4-server.service
- systemctl status dom4-server.service
-EOF
- ;;
-esac
diff --git a/dom4-server b/dom4-server
deleted file mode 100755
index ecfb613af452..000000000000
--- a/dom4-server
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-if [[ ! -s /usr/share/dom4/current ]]; then
- echo "No game configured. Use 'dom4 config' to set up a game."
- exit 1
-fi
-
-game=$(</usr/share/dom4/current)
-
-if [[ ! -s /usr/share/dom4/config/$game.properties ]]; then
- echo "Tried to load $game but configuration file is missing."
- exit 1
-fi
-
-# Load config
-
-config="--tcpserver --textonly --noclientstart"
-
-while read -r line; do
- if [[ -n $line && ! $line = \#* ]]; then
- echo "Setting $line"
-
- config="$config --$line"
- fi
-done < /usr/share/dom4/config/$game.properties
-
-# Start server
-
-export DOM4_CONF=/usr/share/dom4
-
-exec sh /opt/dom4/dom4.sh $config $game > /var/log/dom4/dom4.log
diff --git a/dom4-server.install b/dom4-server.install
deleted file mode 100644
index 1c2081d95021..000000000000
--- a/dom4-server.install
+++ /dev/null
@@ -1,55 +0,0 @@
-post_install() {
- post_upgrade
-
- systemctl daemon-reload
-}
-
-post_upgrade() {
- if hash systemd-sysusers &> /dev/null; then
- systemd-sysusers dom4.conf
- fi
-
- if hash systemd-tmpfiles &> /dev/null; then
- systemd-tmpfiles --create dom4.conf
- fi
-
- mkdir -p /opt/dom4
- mkdir -p /usr/share/dom4/config
- mkdir -p /usr/share/dom4/maps
- mkdir -p /var/log/dom4
-
- chown dom4:dom4 /usr/bin/dom4-server
- chown -R dom4:dom4 /usr/share/dom4
- chown -R dom4:dom4 /opt/dom4
- chown -R dom4:dom4 /var/log/dom4
-
- cat <<EOF
-
-Post-install tasks:
-
-Install Dominions 4 for the server user using SteamCMD:
-
- dom4 install
-
-You will need your login information and a valid Dominions 4 CD key. SteamCMD may ask you to validate via Steam Guard.
-
-To begin setting up hosting, run 'dom4' without arguments for more information.
-EOF
-}
-
-post_remove() {
- if systemctl is-active dom4-server &> /dev/null; then
- systemctl stop dom4-server &> /dev/null
- fi
-
- systemctl daemon-reload &> /dev/null
- systemctl reset-failed &> /dev/null
-
- userdel dom4 &> /dev/null
-
- if [[ -s /usr/share/dom4/current ]]; then
- rm /usr/share/dom4/current &> /dev/null
- fi
-
- rm -rf /run/dom4 &> /dev/null
-}
diff --git a/dom4-sysusers.conf b/dom4-sysusers.conf
deleted file mode 100644
index 2997550ca21a..000000000000
--- a/dom4-sysusers.conf
+++ /dev/null
@@ -1 +0,0 @@
-u dom4 - "Dominions 4 headless server" /usr/share/dom4
diff --git a/dom4-tmpfile.conf b/dom4-tmpfile.conf
deleted file mode 100644
index c8584b927897..000000000000
--- a/dom4-tmpfile.conf
+++ /dev/null
@@ -1 +0,0 @@
-d /run/dom4 0755 dom4 dom4 -
diff --git a/dominions b/dominions
new file mode 100755
index 000000000000..f015f21de5f9
--- /dev/null
+++ b/dominions
@@ -0,0 +1,282 @@
+#!/bin/bash
+
+# List all configured games.
+function list {
+ ls /usr/share/dominions/config | cut -d "." -f 1
+ echo
+
+ if [[ -s /usr/share/dominions/current ]]; then
+ echo "Currently hosting:"
+ echo $(</usr/share/dominions/current)
+ else
+ echo "Not hosting any games."
+ fi
+}
+
+# Install Dominions via SteamCMD.
+function install {
+ if [ ! $(find /opt/dominions -maxdepth 0 -type d -empty 2>/dev/null) ];then
+ echo "/opt/dominions is not empty. Is Dominions already installed?"
+ exit 0
+ fi
+
+ read -r -p "Steam username: " user
+ read -r -s -p "Steam password: " pass
+
+ echo
+ echo "Installing Dominions to /opt/dominions..."
+
+ sudo -u dominions steamcmd +login "$user" "$pass" +force_install_dir /opt/dominions +app_update 722060 validate +quit
+
+ read -r -p "Enter your Dominions license key: " key
+ echo "$key" | sudo -u dominions tee /opt/dominions/dom5key > /dev/null
+
+ echo "Copied license information to Dominions install directory."
+ echo "Installation complete. Use 'dominions config' to set up a game."
+}
+
+# Change the current hosted game by editing /usr/share/dominions/current.
+# Params:
+# $1 game name
+function change {
+ if [[ -s /usr/share/dominions/current ]]; then
+ game=$(</usr/share/dominions/current)
+
+ if [[ $1 != "$game" ]]; then
+ read -r -n 2 -p "Currently hosting $game. Set up to host $1 instead? [Y/n] " ovr
+ if [[ $(echo "$ovr" | tr '[:upper:]' '[:lower:]') != y ]]; then
+ exit 0
+ fi
+ echo
+ fi
+ fi
+
+ echo "Setting $1 up for hosting."
+ echo
+ echo "$1" | sudo -u dominions tee /usr/share/dominions/current > /dev/null
+}
+
+# Load a properties file.
+# Params:
+# $1 path to properties file
+function config {
+ if [[ -z $1 ]]; then
+ cat <<EOF
+Usage:
+
+ dominions config mygame
+EOF
+ exit 1
+ fi
+
+ if [[ -s "/usr/share/dominions/config/$1.properties" ]]; then
+ read -r -n 2 -p "$1 is already configured. Edit this game? [Y/n] " ovr
+ if [[ $(echo "$ovr" | tr '[:upper:]' '[:lower:]') != y ]]; then
+ exit 0
+ fi
+
+ echo
+ else
+ newgame=true
+ cat << EOF | sudo -u dominions tee "/usr/share/dominions/config/$1.properties" > /dev/null
+# See http://www.illwinter.com/dom5/startoptions.pdf for a full reference.
+# Sections 3-5, 3-6, and 3-7 are especially relevant. Switches should be
+# reproduced as given in the documentation, without any leading dashes (so to
+# pass the '--era 1' setting to the server, include the line 'era 1' in this
+# file).
+
+# SERVER INFO
+
+# Port number must be between 1024 and 65535, and forwarded in your router
+# config. Master password is not required but useful if you want to be able to
+# set dropped-out players to computer control.
+
+port 6666
+masterpass supersecure
+
+# GAME SETTINGS
+
+# The mapfile is required. Any .rgb or image files must have the same filename
+# and differ only in extension since the map data is automatically copied over.
+
+mapfile my_pretty_world.map
+hours 26
+era 1
+renaming
+storyevents
+hofsize 15
+requiredap 13
+thrones 2 8 1
+EOF
+ fi
+
+ sudo -u dominions "${EDITOR:-nano}" "/usr/share/dominions/config/$1.properties"
+
+ mapfile=$(grep -oP "^mapfile\s+\K.+" "/usr/share/dominions/config/$1.properties")
+ mapname=$(basename "$mapfile" .map)
+
+ if [ "$newgame" = true ]; then
+ if [[ -s "/usr/share/dominions/maps/$mapname.map" ]]; then
+ echo "Found existing $mapname.map"
+ elif [[ -s "$mapname.map" ]]; then
+ echo "Copying $mapname map files..."
+
+ sudo cp "$mapname".* /usr/share/dominions/maps
+ elif [[ -s "$HOME/dominions/maps/$mapname".map ]]; then
+ echo "Copying $mapname map files from $HOME/dominions/maps..."
+
+ sudo cp "$HOME/dominions/maps/$mapname".* /usr/share/dominions/maps
+ else
+ echo "Could not find $mapname.map in $(pwd) or $HOME/dominions/maps. Please ensure the map file(s) exist in one or the other location and try again."
+
+ exit 1;
+ fi
+
+ echo
+
+ change "$1"
+
+ cat <<EOF
+Done. Start the service to let players upload their pretenders.
+
+ sudo systemctl start dominions-server.service
+
+Once all pretenders have been uploaded, stop the service and set the game to ready.
+
+ dominions ready
+EOF
+ else
+ change "$1"
+
+ cat <<EOF
+Done. Restart the service to load the new configuration:
+
+ sudo systemctl restart dominions-server.service
+EOF
+ fi
+}
+
+# Set game start flag in properties file.
+# Params:
+# $1 game name (optional; uses whatever's in current if not supplied)
+function ready {
+ if [[ ! -z $1 ]]; then
+ if [[ ! -s "/usr/share/dominions/config/$1.properties" ]]; then
+ echo "No game named '$1' found."
+
+ exit 1
+ fi
+
+ change "$1"
+ elif [[ ! -s /usr/share/dominions/current ]]; then
+ echo "No game configured. Use 'dominions config' to set up a game."
+
+ exit 1
+ fi
+
+ game=$(</usr/share/dominions/current)
+
+ if [[ ! -d "/usr/share/dominions/savedgames/$game" ]]; then
+ echo "No pretenders uploaded for $game. Start the service with systemctl to let players upload."
+
+ exit 1
+ fi
+
+ if [[ -s "/usr/share/dominions/savedgames/$game/ftherlnd" ]]; then
+ echo "$game has already been started. If the service is not running, start it with systemctl."
+
+ exit 0
+ fi
+
+ players=$(ls -l /usr/share/dominions/savedgames/$game/*.2h | wc -l)
+
+ if grep -qE "uploadtime|uploadmaxp" "/usr/share/dominions/config/$game.properties" ; then
+ echo "Upload flag already set for $game. Start the service with systemctl."
+
+ exit 0
+ fi
+
+ echo "Setting start flag for $game ($players players)"
+
+ echo "uploadmaxp $players" | sudo -u dominions tee -a "/usr/share/dominions/config/$game.properties" > /dev/null
+
+ cat <<EOF
+
+Flag set. Start or restart the dominions-server service to begin the game.
+
+ sudo systemctl restart dominions-server.service
+
+You may wish to enable it as well to ensure it restarts on boot.
+EOF
+}
+
+function delete {
+ if [[ -z $1 ]]; then
+ echo "Specify a game name to delete."
+ exit 0
+ fi
+
+ if [[ -s /usr/share/dominions/current ]]; then
+ game=$(</usr/share/dominions/current)
+
+ if [[ "$game" = "$1" ]]; then
+ read -r -n 2 -p "$game is currently being hosted. Really delete? [Y/n] " ovr
+ if [[ $(echo "$ovr" | tr '[:upper:]' '[:lower:]') != y ]]; then
+ exit 0
+ fi
+
+ sudo -u dominions rm /usr/share/dominions/current
+ fi
+ fi
+
+ # leave the mapfile in case something else is using it
+ sudo -u dominions rm "/usr/share/dominions/config/$1.properties"
+ sudo -u dominions rm -rf "/usr/share/dominions/savedgames/$1"
+
+ echo "Deleted $1."
+}
+
+case $1 in
+ "list")
+ list
+ ;;
+
+ "install")
+ install
+ ;;
+
+ "config" | "configure")
+ config "${@:2}"
+ ;;
+
+ "ready")
+ ready "${@:2}"
+ ;;
+
+ "delete")
+ delete "${@:2}"
+ ;;
+
+ *)
+ cat <<EOF
+Dominions Headless Server Interface
+
+This program manages Dominions installation and configuration for the headless server. Multiple games may be configured, but only one game can be actively hosted at once -- this is a true multiplayer server rather than a PBEM setup.
+
+The headless server itself is a systemd service and can be managed via systemctl.
+
+Usage:
+ dominions install Install Dominions through SteamCMD
+ dominions list List configured games
+ dominions config mygame Configure a new game, or edit an existing one
+ dominions ready mygame Sets the start flag for mygame after all pretenders have been uploaded
+ dominions delete mygame Deletes mygame (this operation is irreversible!)
+
+Service commands:
+ sudo systemctl start dominions-server.service
+ sudo systemctl stop dominions-server.service
+ sudo systemctl restart dominions-server.service
+ systemctl status dominions-server.service
+EOF
+ ;;
+esac
diff --git a/dominions-server b/dominions-server
new file mode 100755
index 000000000000..fa66619c3785
--- /dev/null
+++ b/dominions-server
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+if [[ ! -s /usr/share/dominions/current ]]; then
+ echo "No game configured. Use 'dominions config' to set up a game."
+ exit 1
+fi
+
+game=$(</usr/share/dominions/current)
+
+if [[ ! -s /usr/share/dominions/config/$game.properties ]]; then
+ echo "Tried to load $game but configuration file is missing."
+ exit 1
+fi
+
+# Load config
+
+config="--tcpserver --textonly --noclientstart"
+
+while read -r line; do
+ if [[ -n $line && ! $line = \#* ]]; then
+ echo "Setting $line"
+
+ config="$config --$line"
+ fi
+done < "/usr/share/dominions/config/$game.properties"
+
+# Start server
+
+export DOM5_CONF=/usr/share/dominions
+
+echo "Final configuration:"
+echo "$config"
+echo "Starting game..."
+
+exec sh /opt/dominions/dom5.sh $config "$game" > /var/log/dominions/dominions.log
diff --git a/dominions-server.install b/dominions-server.install
new file mode 100644
index 000000000000..272f58ee4d46
--- /dev/null
+++ b/dominions-server.install
@@ -0,0 +1,55 @@
+post_install() {
+ post_upgrade
+
+ systemctl daemon-reload
+}
+
+post_upgrade() {
+ if hash systemd-sysusers &> /dev/null; then
+ systemd-sysusers dominions.conf
+ fi
+
+ if hash systemd-tmpfiles &> /dev/null; then
+ systemd-tmpfiles --create dominions.conf
+ fi
+
+ mkdir -p /opt/dominions
+ mkdir -p /usr/share/dominions/config
+ mkdir -p /usr/share/dominions/maps
+ mkdir -p /var/log/dominions
+
+ chown dominions:dominions /usr/bin/dominions-server
+ chown -R dominions:dominions /usr/share/dominions
+ chown -R dominions:dominions /opt/dominions
+ chown -R dominions:dominions /var/log/dominions
+
+ cat <<EOF
+
+Post-install tasks:
+
+Install Dominions 5 for the server user using SteamCMD:
+
+ dominions install
+
+You will need your login information and a valid Dominions 5 CD key. SteamCMD may ask you to validate via Steam Guard.
+
+To begin setting up hosting, run 'dominions' without arguments for more information.
+EOF
+}
+
+post_remove() {
+ if systemctl is-active dominions-server &> /dev/null; then
+ systemctl stop dominions-server &> /dev/null
+ fi
+
+ systemctl daemon-reload &> /dev/null
+ systemctl reset-failed &> /dev/null
+
+ userdel dominions &> /dev/null
+
+ if [[ -s /usr/share/dominions/current ]]; then
+ rm /usr/share/dominions/current &> /dev/null
+ fi
+
+ rm -rf /run/dominions &> /dev/null
+}
diff --git a/dom4-server.service b/dominions-server.service
index 451d2c3a75ea..6a1da838a4ea 100644
--- a/dom4-server.service
+++ b/dominions-server.service
@@ -1,11 +1,11 @@
[Unit]
-Description=Dominions 4 Headless Server
+Description=Dominions Headless Server
After=network.target
[Service]
-ExecStart=/usr/bin/dom4-server
+ExecStart=/usr/bin/dominions-server
Type=simple
-User=dom4
+User=dominions
[Install]
WantedBy=multi-user.target
diff --git a/dominions-sysusers.conf b/dominions-sysusers.conf
new file mode 100644
index 000000000000..7f65f5e5fd59
--- /dev/null
+++ b/dominions-sysusers.conf
@@ -0,0 +1 @@
+u dominions - "Dominions headless server" /usr/share/dominions
diff --git a/dominions-tmpfile.conf b/dominions-tmpfile.conf
new file mode 100644
index 000000000000..870242a7fc92
--- /dev/null
+++ b/dominions-tmpfile.conf
@@ -0,0 +1 @@
+d /run/dominions 0755 dominions dominions -