projects/aports·blob master · refs

43 lines · 1.1 KiB

1#!/sbin/openrc-run
2
3command="/usr/sbin/incusd"
4command_args="${INCUSD_OPTIONS}"
5command_background="true"
6pidfile="/run/incus/${RC_SVCNAME}.pid"
7retry="${INCUSD_STOP_TIMEOUT:-60}"
8extra_started_commands="quit"
9description_quit="Daemon quits and leaves the instances running"
10
11: ${INCUSD_FORCE_STOP:="no"}
12
13depend() {
14 need net cgroups dbus
15 use lxcfs
16 after firewall
17}
18
19start_pre() {
20 checkpath --directory "${pidfile%/*}" --mode 0750
21 # Required for running systemd containers
22 if [ -d /sys/fs/cgroup/unified ] && ! [ -d /sys/fs/cgroup/systemd ]; then
23 checkpath --directory --owner root:incus /sys/fs/cgroup/systemd
24 mount -t cgroup \
25 -o rw,nosuid,nodev,noexec,relatime,none,name=systemd \
26 cgroup /sys/fs/cgroup/systemd
27 fi
28}
29
30stop() {
31 ebegin "Stopping ${RC_SVCNAME}"
32 if [ "$INCUSD_FORCE_STOP" = "no" ]; then
33 $command shutdown --timeout ${INCUSD_STOP_TIMEOUT:-60}
34 elif [ "$INCUSD_FORCE_STOP" = "yes" ]; then
35 $command shutdown --force
36 fi
37}
38
39quit() {
40 ebegin "Quitting ${RC_SVCNAME}"
41 start-stop-daemon --signal SIGQUIT --pidfile $pidfile --quiet
42 rm /run/openrc/started/incusd
43}