summaryrefslogtreecommitdiffstats
path: root/network/gmid/files/rc.gmid.new
diff options
context:
space:
mode:
Diffstat (limited to 'network/gmid/files/rc.gmid.new')
-rw-r--r--network/gmid/files/rc.gmid.new93
1 files changed, 93 insertions, 0 deletions
diff --git a/network/gmid/files/rc.gmid.new b/network/gmid/files/rc.gmid.new
new file mode 100644
index 0000000000..9438b36c2f
--- /dev/null
+++ b/network/gmid/files/rc.gmid.new
@@ -0,0 +1,93 @@
+#!/bin/sh
+#
+# Startup/shutdown script for the gmid gemini service.
+#
+
+GMID_USER=${GMID_USER:-root}
+
+create_gmid_run_dir() {
+ if [ ! -d /run/gmid/ ]; then
+ mkdir -p /run/gmid
+ chown gmid:gmid /run/gmid
+ fi
+}
+
+gmid_reload()
+{
+ create_gmid_run_dir
+
+ local pid="$(2>/dev/null cat /run/gmid/gmid.pid)"
+
+ if [ -z "$pid" ] || ! kill -0 "$pid" >/dev/null; then
+ echo "gmid is not running"
+
+ return
+ fi
+
+ echo "Reloading gmid configuration"
+ kill -HUP "$pid"
+}
+
+gmid_start() {
+ create_gmid_run_dir
+
+ local pid="$(2>/dev/null cat /run/gmid/gmid.pid)"
+
+ if [ -n "$pid" ] || kill -0 "$pid" 2>/dev/null; then
+ echo "gmid is already running"
+
+ return
+ fi
+
+ echo "Starting gmid gemini service"
+ sudo -u "$GMID_USER" -- gmid \
+ -c /etc/gmid.conf \
+ -P /run/gmid/gmid.pid
+}
+
+gmid_status() {
+ create_gmid_run_dir
+
+ local pid="$(2>/dev/null cat /run/gmid/gmid.pid)"
+
+ if [ -z "$pid" ] || ! kill -0 "$pid" 2>/dev/null; then
+ echo "gmid is not running"
+
+ return
+ fi
+
+ echo "gmid is running"
+}
+
+gmid_stop() {
+ echo "Stopping gmid gemini service"
+ create_gmid_run_dir
+
+ local pid="$(2>/dev/null cat /run/gmid/gmid.pid)"
+
+ if [ -z "$pid" ] || ! kill -0 "$pid" 2>/dev/null; then
+ echo "gmid is not running"
+
+ return
+ fi
+
+ sudo -u "$GMID_USER" -- kill -TERM "$pid"
+}
+
+case "$1" in
+reload)
+ gmid_reload
+ ;;
+start)
+ gmid_start
+ ;;
+status)
+ gmid_status
+ ;;
+stop)
+ gmid_stop
+ ;;
+*)
+ echo "Usage: $0 {reload|start|status|stop}"
+ exit 1
+esac