summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorDian Fay2016-10-17 21:07:14 -0400
committerDian Fay2016-10-17 21:07:14 -0400
commitfde739df32c2e190dc7deebf7c793bdd75778e4d (patch)
treed636ed661719d8a7daa433bceeb7a1f4c84677eb
parentabf27b0c25c88260081c0cd45897f785e298108d (diff)
downloadaur-fde739df32c2e190dc7deebf7c793bdd75778e4d.tar.gz
include steamcmd install and simplify a bunch of stuff
-rw-r--r--.SRCINFO7
-rw-r--r--PKGBUILD13
-rw-r--r--default.properties19
-rwxr-xr-xdom4129
-rwxr-xr-xdom4-server10
-rw-r--r--dom4-server.install17
6 files changed, 93 insertions, 102 deletions
diff --git a/.SRCINFO b/.SRCINFO
index f9223bfd911..bfac2e258f9 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -6,18 +6,17 @@ pkgbase = dom4-server
install = dom4-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
- source = default.properties
- md5sums = d8e3011dfa108d3f1574c57aefcecb32
+ md5sums = 03931b9317799ef4ae7fded185cd1c69
md5sums = d7467fb7a599236f71d428a85cf05014
md5sums = e9772a237cc540558e74235b98df8a7f
md5sums = 338b8462868ecf6cc56c4a520cea6bac
- md5sums = 26c54faba6e1b864997cc918723c8db4
- md5sums = 22bdb16a296d12c51988c43c3218201b
+ md5sums = d25b42aae80b30633920605faa36ed35
pkgname = dom4-server
diff --git a/PKGBUILD b/PKGBUILD
index de2e9eb0eec..ae7469d1450 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -4,17 +4,17 @@ pkgname=dom4-server
pkgver=1.0.6
pkgrel=1
pkgdesc="Configure and run Dominions 4 as a headless server"
-arch=('x86_64')
+arch=("x86_64")
url="http://www.illwinter.com/dom4/"
-license=('MIT')
+license=("MIT")
install=$pkgname.install
+depends_x86_64=("steamcmd")
source=(
dom4-server
dom4-server.service
dom4-sysusers.conf
dom4-tmpfile.conf
dom4
- default.properties
)
package() {
@@ -23,14 +23,11 @@ package() {
install -Dm755 "$srcdir/dom4" "$pkgdir/usr/bin/dom4"
- install -Dm644 "$srcdir/default.properties" "$pkgdir/usr/share/dom4/config/default.properties"
-
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"
}
-md5sums=('d8e3011dfa108d3f1574c57aefcecb32'
+md5sums=('03931b9317799ef4ae7fded185cd1c69'
'd7467fb7a599236f71d428a85cf05014'
'e9772a237cc540558e74235b98df8a7f'
'338b8462868ecf6cc56c4a520cea6bac'
- '26c54faba6e1b864997cc918723c8db4'
- '22bdb16a296d12c51988c43c3218201b')
+ 'd25b42aae80b30633920605faa36ed35')
diff --git a/default.properties b/default.properties
deleted file mode 100644
index 67e16f30632..00000000000
--- a/default.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###### SERVER INFO ######
-# set the map file. any image file must have the same name but a different extension.
-mapfile my_pretty_world.map
-# allow host to set dropped-out players to computer control
-masterpass supersecure
-# will default to localhost
-ipadr 127.0.0.1
-# must be between 1024 and 65535
-port 6666
-# time between turn rollover
-hours 26
-
-###### GAME SETTINGS ######
-era 1
-renaming
-storyevents
-hofsize 15
-requiredap 13
-thrones 2 8 1
diff --git a/dom4 b/dom4
index 73d2ba6178c..a2ffb654ecd 100755
--- a/dom4
+++ b/dom4
@@ -1,5 +1,24 @@
#!/bin/bash
+# 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 CD Key: " key
+ echo $key | sudo -u dom4 tee /opt/dom4/dom4key > /dev/null
+}
+
# Change the current hosted game by editing /usr/share/dom4/current.
# Params:
# $1 game name
@@ -17,8 +36,7 @@ function change {
fi
echo "Setting $1 up for hosting."
- echo "$1" > /usr/share/dom4/current
- chown dom4:dom4 /usr/share/dom4/current
+ echo "$1" | sudo -u dom4 tee /usr/share/dom4/current > /dev/null
}
# Load a properties file.
@@ -29,57 +47,65 @@ function config {
cat <<EOF
Usage:
- sudo dom4 config path/to/mygame.properties
+ dom4 config mygame
EOF
exit 1
fi
- if [[ ! -s $1 ]]; then
- echo "$1 does not exist. Specify a valid properties file."
- exit 1
- fi
-
- if [[ -s "/usr/share/dom4/config/$1" ]]; then
+ if [[ -s "/usr/share/dom4/config/$1.properties" ]]; then
read -r -n 2 -p "$1 is already configured. Overwrite? [Y/n] " ovr
if [[ $ovr != Y ]]; then
exit 0
fi
echo
+ else
+ cat << EOF | sudo -u dom4 tee /usr/share/dom4/config/$1.properties > /dev/null
+###### SERVER INFO ######
+# Set the map file. Any image file must have the same name but a different extension.
+mapfile my_pretty_world.map
+# Allow host to set dropped-out players to computer control
+masterpass supersecure
+# Will default to localhost
+ipadr 127.0.0.1
+# Must be between 1024 and 65535, and forwarded in your router config
+port 6666
+# Time between turn rollover
+hours 26
+
+###### GAME SETTINGS ######
+era 1
+renaming
+storyevents
+hofsize 15
+requiredap 13
+thrones 2 8 1
+EOF
fi
- echo "Copying properties file..."
-
- cp $1 /usr/share/dom4/config
+ sudo -u dom4 $EDITOR /usr/share/dom4/config/$1.properties
- mapfile=$(grep -oP "mapfile\s+\K.+" $1)
+ mapfile=$(grep -oP "mapfile\s+\K.+" /usr/share/dom4/config/$1.properties)
mapname=$(basename $mapfile .map)
- confdir=$(dirname $1)
- mkdir -p /usr/share/dom4/maps
-
- USER_HOME=$(getent passwd $SUDO_USER | cut -d: -f6)
+ sudo -u dom4 mkdir -p /usr/share/dom4/maps
if [[ -s "$mapname.map" ]]; then
echo "Copying $mapname map files..."
- cp "$mapname".* /usr/share/dom4/maps
- elif [[ -s "$confdir/$mapname".map ]]; then
- echo "Copying $mapname map files from $confdir..."
-
- cp "$confdir/$mapname".* /usr/share/dom4/maps
- elif [[ -s "$USER_HOME/dominions4/maps/$mapname".map ]]; then
- echo "Copying $mapname map files from $USER_HOME/dominions4/maps..."
+ sudo -u dom4 cp "$mapname".* /usr/share/dom4/maps
+ elif [[ -s "$HOME/dominions4/maps/$mapname".map ]]; then
+ echo "Copying $mapname map files from $HOME/dominions4/maps..."
- cp "$USER_HOME/dominions4/maps/$mapname".* /usr/share/dom4/maps
+ sudo cp "$HOME/dominions4/maps/$mapname".* /usr/share/dom4/maps
else
- echo "Could not find $mapname.map in $(pwd) or $USER_HOME/dominions4/maps. Please ensure the map file(s) exist and try again."
+ 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 "$(basename $1 .properties)"
+ change $1
cat <<EOF
@@ -89,7 +115,7 @@ Done. Start the service to let players upload their pretenders.
Once all pretenders have been uploaded, stop the service and set the game to ready.
- sudo dom4 ready
+ dom4 ready
EOF
}
@@ -99,16 +125,14 @@ EOF
function ready {
if [[ ! -z $1 ]]; then
if [[ ! -s "/usr/share/dom4/config/$1.properties" ]]; then
- echo "No game named '$1' found. Use dom4 config $1.properties to upload it."
+ echo "No game named '$1' found."
exit 1
fi
change $1
- fi
-
- if [[ ! -s /usr/share/dom4/current ]]; then
- echo "No current game found. Use dom4 config to load game configuration."
+ elif [[ ! -s /usr/share/dom4/current ]]; then
+ echo "No game configured. Use 'dom4 config' to set up a game."
exit 1
fi
@@ -137,7 +161,7 @@ function ready {
echo "Setting start flag for $game ($players players)"
- echo "uploadmaxp $players" >> "/usr/share/dom4/config/$game.properties"
+ echo "uploadmaxp $players" | sudo -u dom4 tee -a "/usr/share/dom4/config/$game.properties" > /dev/null
cat <<EOF
@@ -155,11 +179,6 @@ function delete {
exit 0
fi
- if [[ $1 = "default" ]]; then
- echo "Not deleting the default config."
- exit 0
- fi
-
game=$(</usr/share/dom4/current)
if [[ $game = $1 ]]; then
@@ -168,21 +187,19 @@ function delete {
exit 0
fi
- rm /usr/share/dom4/current
+ sudo -u dom4 rm /usr/share/dom4/current
fi
# leave the mapfile in case something else is using it
- rm /usr/share/dom4/config/$1.properties
- rm -rf /usr/share/dom4/savedgames/$1
+ sudo -u dom4 rm /usr/share/dom4/config/$1.properties
+ sudo -u dom4 rm -rf /usr/share/dom4/savedgames/$1
}
-if [[ $EUID -ne 0 && ! -z $1 ]]; then
- echo "Use sudo to run this script."
-
- exit 1
-fi
-
case $1 in
+ "install")
+ install
+ ;;
+
"config" | "configure")
config "${@:2}"
;;
@@ -197,25 +214,25 @@ case $1 in
*)
cat <<EOF
-Get an example template to modify in your editor of choice:
+Install Dominions 4 through SteamCMD:
- cp /usr/share/dom4/config/default.properties mygame.properties
+ dom4 install
-Load a properties file into the server and set it as the current hosted game:
+Configure a new game, or edit an existing one:
- sudo dom4 config path/to/mygame.properties
+ dom4 config mygame
Set start flag for current game after all pretenders have been uploaded, prior to running service:
- sudo dom4 ready
+ dom4 ready
Set start flag for mygame after pretenders have been uploaded and set it as current hosted game:
- sudo dom4 ready mygame
+ dom4 ready mygame
-Delete a game:
+Delete a game (this operation is irreversible!):
- sudo dom4 delete mygame
+ dom4 delete mygame
Service commands:
diff --git a/dom4-server b/dom4-server
index e8537794cc1..b239c0e1ad0 100755
--- a/dom4-server
+++ b/dom4-server
@@ -1,12 +1,12 @@
#!/bin/bash
-game=`cat /usr/share/dom4/current`
-
-if [[ -z "$game" ]]; then
- echo "No game specified. Use 'dom4 config' to load a game configuration."
+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
@@ -28,4 +28,4 @@ done < /usr/share/dom4/config/$game.properties
export DOM4_CONF=/usr/share/dom4
-exec sh /opt/Dominions4/dom4.sh $config $game
+exec sh /opt/dom4/dom4.sh $config $game
diff --git a/dom4-server.install b/dom4-server.install
index 90156c3870f..2c445fdfe4c 100644
--- a/dom4-server.install
+++ b/dom4-server.install
@@ -13,26 +13,23 @@ post_upgrade() {
systemd-tmpfiles --create dom4.conf
fi
+ mkdir -p /opt/dom4
+
chown dom4:dom4 /usr/bin/dom4-server
chown -R dom4:dom4 /usr/share/dom4
+ chown -R dom4:dom4 /opt/dom4
cat <<EOF
Post-install tasks:
-Ensure Dominions 4 is installed to /opt/Dominions4. If you installed it from the Steam GUI with the default library path, use:
-
- sudo cp -R ~/.local/share/Steam/steamapps/common/Dominions4 /opt
-
-If you installed it via SteamCMD (see README.md in the Git repository for instructions on doing that if you're starting from scratch):
-
- sudo cp -R ~/Steam/steamapps/common/Dominions4 /opt
+Install Dominions 4 for the server user using SteamCMD:
-If you can't find it at either of those locations, try 'locate dom4.sh' (if you *just* installed Dominions 4, 'sudo updatedb' first). This should output one line with the full path and filename of 'dom4.sh'. 'sudo cp -R' the path, excluding the filename.
+ dom4 install
-Your install directory must have a 'dom4key' file present containing your Dominions 4 license key. If the file does not already exist, you can create it using the license information from Steam.
+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'.
+To begin setting up hosting, run 'dom4' without arguments for more information.
EOF
}