From 631d1d800ca7ea7a2de000c9f082de0cf5ba8e1b Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Fri, 14 Jul 2017 22:56:09 +0000 Subject: [PATCH] Commit mothd and its systemd service --- bin/once | 2 +- tools/mothd | 14 ++++++++++++++ tools/mothd.service | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 tools/mothd create mode 100644 tools/mothd.service 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