Type=simple
User=plom
WorkingDirectory=/home/plom
+# once per second check if dtach file still exists, only declare run over (and thereby re-start possible) once it doesn't
ExecStart=/bin/sh -lc "dtach -n /tmp/dtach_ircplom && while true; do sleep 1; test ! -e /tmp/dtach_ircplom && break; done"
-ExecStop=/bin/sh -lc "rm /tmp/dtach_ircplom"
+ExecStop=/bin/sh -lc "rm -f /tmp/dtach_ircplom"
Environment=TERM=linux
Restart=on-success
+# leave enough time for manual intervention if need be
RestartSec=10
[Install]
-#!/bin/sh
+#!/usr/bin/env dash
set -e
-cd $(dirname "$0")
-. lib/expect_n_args
+ROOT=$(dirname "$0")
+cd "${ROOT}"
+. lib/expect_n_args.sh
expect_n_args 0 0 ''
TODAY="$(date +'%Y-%m-%d')"
set +e
-PATHS_LOGFILES="$(ls ${PATH_LOGS}/*/*/*.log 2> /dev/null)"
+PATHS_LOGFILES=$(ls "${PATH_LOGS}"/*/*/*.log 2> /dev/null)
set -e
if [ -z "${PATHS_LOGFILES}" ]; then
echo "No log files present, so nothing to do."