aboutsummaryrefslogtreecommitdiff
path: root/gmid/files/rc.gmid.new
diff options
context:
space:
mode:
authorSlack Coder <slackcoder@server.ky>2024-10-08 19:31:41 -0500
committerSlack Coder <slackcoder@server.ky>2024-10-08 19:36:57 -0500
commit2954898f6551cbd2e5b0ed4dae8925d729f741a9 (patch)
tree9b66596fa7c1b1f4f376c9f974ebb349ed4286d1 /gmid/files/rc.gmid.new
parentff09d99234d42e8dba3f1f9b7de8181b6bacbdbd (diff)
downloadslackbuilds-2954898f6551cbd2e5b0ed4dae8925d729f741a9.tar.xz
gmid: bump v2.1.1 and update config
Diffstat (limited to 'gmid/files/rc.gmid.new')
-rw-r--r--gmid/files/rc.gmid.new81
1 files changed, 59 insertions, 22 deletions
diff --git a/gmid/files/rc.gmid.new b/gmid/files/rc.gmid.new
index 33044b7..4b9e006 100644
--- a/gmid/files/rc.gmid.new
+++ b/gmid/files/rc.gmid.new
@@ -3,54 +3,91 @@
# Startup/shutdown script for the gmid gemini service.
#
-create_run_dir() {
+GMID_USER=${GMID_USER:-root}
+
+create_gmid_run_dir() {
if [ ! -d /run/gmid/ ]; then
mkdir -p /run/gmid
- chown :gmid /run/gmid
- chmod g+wX /run/gmid
+ chown gmid:gmid /run/gmid
fi
}
-start() {
- echo "Starting gmid gemini service"
- create_run_dir
+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 "$(cat /run/gmid/gmid.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"
- sudo -u gmid -- gmid \
- -c /etc/gmid/gmid.conf \
+ return
+ fi
+
+ echo "Starting gmid gemini service"
+ sudo -u "$GMID_USER" -- gmid \
+ -c /etc/gmid.conf \
-P /run/gmid/gmid.pid
}
-status() {
- create_run_dir
+gmid_status() {
+ create_gmid_run_dir
- if [ -f /run/gmid/gmid.pid ] && [ kill -0 "$(cat /run/gmid/gmid.pid)" >/dev/null ]; then
- echo "gmid is running"
- else
+ 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"
}
-stop() {
+gmid_stop() {
echo "Stopping gmid gemini service"
- create_run_dir
+ create_gmid_run_dir
- if [ -f /run/gmid/gmid.pid ]; then
- sudo -u gmid -- kill -SIGINT "$(cat /run/gmid/gmid.pid)"
+ 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)
- start
+ gmid_start
;;
status)
- status
+ gmid_status
;;
stop)
- stop
+ gmid_stop
;;
*)
- echo "Usage: $0 {start|stop|status}"
+ echo "Usage: $0 {reload|start|status|stop}"
exit 1
esac
-