#!/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=$( /dev/null } # Load a properties file. # Params: # $1 path to properties file function config { if [[ -z $1 ]]; then cat < /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 < /dev/null cat <