diff --git a/bin/once b/bin/once index 82ee920..9439510 100755 --- a/bin/once +++ b/bin/once @@ -7,7 +7,7 @@ else fi basedir=$(pwd) -printf "Updating moth instance in %s\n" $(pwd) +[ -n "$DEBUG" ] && printf "Updating moth instance in %s\n" $(pwd) # Do nothing if `disabled` is present if [ -f disabled ]; then diff --git a/tools/mothd b/tools/mothd new file mode 100755 index 0000000..ffad247 --- /dev/null +++ b/tools/mothd @@ -0,0 +1,14 @@ +#! /bin/sh + +cd ${1:-$(dirname $0)} +KOTH_BASE=$(pwd) + +echo "Running koth instances in $KOTH_BASE" + +while true; do + for i in $KOTH_BASE/*/assigned.txt; do + dir=${i%/*} + $dir/bin/once + done + sleep 5 +done diff --git a/tools/mothd.service b/tools/mothd.service new file mode 100644 index 0000000..664afcb --- /dev/null +++ b/tools/mothd.service @@ -0,0 +1,18 @@ +# To install: +# sudo cp mothd.service /etc/systemd/system/moth.service +# sudo systemctl enable mothd +# sudo systemctl start mothd + +[Unit] +Description=Monarch Of The Hill server +After=network.target auditd.service + +[Service] +WorkingDirectory=/srv/moth +User=www-data +ExecStart=/srv/moth/mothd +KillMode=process +Restart=on-failure + +[Install] +WantedBy=multi-user.target