From 9e6813a994d55f5493c862fa96db4bb29f32be7c Mon Sep 17 00:00:00 2001 From: f Date: Tue, 15 Mar 2022 20:03:52 -0300 Subject: [PATCH] upgrade --- monit.conf | 6 +++--- postsrsd.sh | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/monit.conf b/monit.conf index 6c18e88..a1ad1f1 100644 --- a/monit.conf +++ b/monit.conf @@ -1,6 +1,6 @@ -check process postsrsd with pidfile /tmp/postsrsd.pid - start program = "/usr/local/bin/postsrsd" - stop program = "/bin/sh -c 'cat /tmp/postsrsd.pid | xargs -r kill'" +check process postsrsd with pidfile /run/postsrsd/postsrsd.pid + start program = "/usr/local/bin/postsrsd start" + stop program = "/usr/local/bin/postsrsd stop" if failed port 10001 for 3 cycles then restart if failed port 10002 for 3 cycles then restart diff --git a/postsrsd.sh b/postsrsd.sh index 7e56162..a544e4d 100755 --- a/postsrsd.sh +++ b/postsrsd.sh @@ -1,17 +1,18 @@ #!/bin/sh set -e -export SRS_PID_FILE=/tmp/postsrsd.pid +export SRS_PID_FILE=/run/postsrsd/postsrsd.pid -case "$1" in +case $1 in + start) + test -n "${SRS_DOMAIN}" + test -n "${SRS_SECRET}" + test -f "${SRS_SECRET}" || dd if=/dev/urandom bs=18 count=1 status=none | base64 > "${SRS_SECRET}" + + install -dm 750 -u postsrsd -g postsrsd "${SRS_PID_FILE%/.*}" + /usr/sbin/postsrsd -e -D -u postsrsd -l :: + ;; stop) - test -f "${SRS_PID_FILE}" && cat /tmp/postsrsd.pid | xargs -r kill - exit $? + test ! -f "${SRS_PID_FILE}" || cat "${SRS_PID_FILE}" | xargs -r kill ;; esac - -test -n "${SRS_DOMAIN}" -test -n "${SRS_SECRET}" -test -f "${SRS_SECRET}" || dd if=/dev/urandom bs=18 count=1 status=none | base64 > "${SRS_SECRET}" - -/usr/sbin/postsrsd -e -D -l 0.0.0.0 -u postsrsd -4