File: incus-base.incus-user.init

package info (click to toggle)
incus 6.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 23,864 kB
  • sloc: sh: 16,015; ansic: 3,121; python: 456; makefile: 321; ruby: 51; sql: 50; lisp: 6
file content (82 lines) | stat: -rwxr-xr-x 2,295 bytes parent folder | download | duplicates (6)
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
#!/bin/dash -ue

### BEGIN INIT INFO
# Short-Description:    Incus - User daemon
# Description:          Incus - User daemon
# Provides:             incus-user
# Required-Start:       incus
# Required-Stop:        incus
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
### END INIT INFO

# WARNING:
# This script has not been tested on hosts with cgroup v1.
# The host system must have a cgroup v2 hierarchy mounted.

DAEMON=/usr/libexec/incus/incus-user
DESC='Incus - User daemon'
NAME=incus-user
PIDFILE=/run/incus-user.pid

# Import log_* functions.
. /lib/lsb/init-functions

# Load environment vars.
[ -e /etc/environment ] && . /etc/environment

# Load default config.
[ -e /etc/default/incus ] && . /etc/default/incus

# Just exit if incusd does not exist or is not excutable.
[ -x "${DAEMON}" ] || exit 0

case "${1:-}" in
    start)
        printf '%s' "Starting ${DESC}: ${NAME}"
        if start-stop-daemon -m --start --quiet --pidfile "${PIDFILE}" \
            --exec "${DAEMON}" --background -- --group=incus > /dev/null 2>&1; then
            log_success_msg
        else
            if start-stop-daemon --test -m --start --quiet --pidfile "${PIDFILE}" \
                --exec "${DAEMON}" --background > /dev/null 2>&1; then
                log_failure_msg
                exit 1
            else
                log_failure_msg " already running"
                exit 0
            fi
        fi

        exit 0
        ;;
    stop)
        printf '%s' "Stopping ${DESC}: ${NAME}"
        if start-stop-daemon --stop --quiet --pidfile "${PIDFILE}" \
            --exec "${DAEMON}" --retry 10; then
            log_success_msg
        else
            if start-stop-daemon --test -m --start --quiet --pidfile "${PIDFILE}" \
                --exec "${DAEMON}" --background >/dev/null 2>&1; then
                log_failure_msg " not running"
                exit 0
            else
                log_failure_msg
                exit 1
            fi
        fi

        exit 0
        ;;
    status)
        status_of_proc -p "${PIDFILE}" "${DAEMON}" incus-user
        ;;
    restart|force-reload)
        "$0" stop
        exec "$0" start
        ;;
    *)
        printf '%s\n' "Usage: $0 {start|stop|restart|force-reload}" 1>&2
        exit 1
        ;;
esac