blob: 4b9e006c7f76ad6874c7d398b982c52159dff661 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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 "$(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"
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
|