Fix jobrunner.log overwriting

This commit is contained in:
JeremyStar™ 2024-06-03 19:55:13 +02:00
parent 61c3e1c903
commit 7f78f36d6a
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -1,6 +1,14 @@
#!/bin/bash #!/bin/bash
# jeremystartm's jobrunner # jeremystartm's jobrunner
# Check for PID file
if [ -f "/tmp/jobrunner/jobrunner.pid" ]; then
echo ":: Error: The jobrunner daemon is already running."
echo " If you think that this is an error, remove"
echo " \"/tmp/jobrunner/jobrunner.pid\"."
exit 1
fi
# Logging functions # Logging functions
function log() { function log() {
[[ -z "${JOBRUNNER_DISABLEOUTPUT}" ]] && echo "${*}" [[ -z "${JOBRUNNER_DISABLEOUTPUT}" ]] && echo "${*}"
@ -21,18 +29,10 @@ else
echo ":: Creating runtime directory" echo ":: Creating runtime directory"
mkdir -p "/tmp/jobrunner/" mkdir -p "/tmp/jobrunner/"
echo -e "" > /tmp/jobrunner/jobrunner.log echo -n "" > /tmp/jobrunner/jobrunner.log
rm -rf /tmp/jobrunner/jobrunner.cmd rm -rf /tmp/jobrunner/jobrunner.cmd
fi fi
# Check for PID file
if [ -f "/tmp/jobrunner/jobrunner.pid" ]; then
log ":: Error: The jobrunner daemon is already running."
log " If you think that this is an error, remove"
log " \"/tmp/jobrunner/jobrunner.pid\"."
exit 1
fi
# Write PID file # Write PID file
log ":: Writing PID" log ":: Writing PID"
echo "$$" > "/tmp/jobrunner/jobrunner.pid" echo "$$" > "/tmp/jobrunner/jobrunner.pid"