diff options
Diffstat (limited to 'gmid/files/rc.gmid.new')
-rw-r--r-- | gmid/files/rc.gmid.new | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/gmid/files/rc.gmid.new b/gmid/files/rc.gmid.new new file mode 100644 index 0000000..33044b7 --- /dev/null +++ b/gmid/files/rc.gmid.new @@ -0,0 +1,56 @@ +#!/bin/sh +# +# Startup/shutdown script for the gmid gemini service. +# + +create_run_dir() { + if [ ! -d /run/gmid/ ]; then + mkdir -p /run/gmid + chown :gmid /run/gmid + chmod g+wX /run/gmid + fi +} + +start() { + echo "Starting gmid gemini service" + create_run_dir + + sudo -u gmid -- gmid \ + -c /etc/gmid/gmid.conf \ + -P /run/gmid/gmid.pid +} + +status() { + create_run_dir + + if [ -f /run/gmid/gmid.pid ] && [ kill -0 "$(cat /run/gmid/gmid.pid)" >/dev/null ]; then + echo "gmid is running" + else + echo "gmid is not running" + fi +} + +stop() { + echo "Stopping gmid gemini service" + create_run_dir + + if [ -f /run/gmid/gmid.pid ]; then + sudo -u gmid -- kill -SIGINT "$(cat /run/gmid/gmid.pid)" + fi +} + +case "$1" in +start) + start + ;; +status) + status + ;; +stop) + stop + ;; +*) + echo "Usage: $0 {start|stop|status}" + exit 1 +esac + |