From 61eb7bc9b892f034e092d570d309a2f6c8e8d39b Mon Sep 17 00:00:00 2001 From: f Date: Thu, 20 Apr 2023 13:04:42 -0300 Subject: [PATCH] feat: start stop --- access_logd.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/access_logd.sh b/access_logd.sh index 520905c..4519ab5 100755 --- a/access_logd.sh +++ b/access_logd.sh @@ -6,8 +6,20 @@ test -n "$ACCESS_LOGS_FLAGS" || exit 1 # Give write access to Nginx umask 007 -# Copy default database -install -m 640 -o nobody /var/lib/access_log.sqlite3 /var/log/access_log.sqlite3 +pid=/run/access_logd.pid -# Read from fifo and load into database -daemonize -p /run/access_logd.pid -u nobody /usr/local/bin/syslogize /usr/bin/access_log $ACCESS_LOGS_FLAGS +case $1 in + start) + # Copy default database + install -m 640 -o nobody /var/lib/access_log.sqlite3 /var/log/access_log.sqlite3 + + # Read from fifo and load into database + daemonize -p /run/access_logd.pid -u nobody /usr/local/bin/syslogize /usr/bin/access_log $ACCESS_LOGS_FLAGS + ;; + stop) + test -f $pid || exit 0 + + cat $pid | xargs kill + rm $pid + ;; +esac