aboutsummaryrefslogtreecommitdiff
path: root/system/incus/rc.incusd.new
blob: ef7ca4aea555cdc6c4542fa0005d27bb4bfc976a (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
#!/bin/sh
#
# /etc/rc.d/rc.incusd
#
# start/stop/restart incusd as a daemon.


INCUSD_GROUP=wheel

# Use defaults from /etc/default/incusd
# (overrides anything set above).
#
if [ -r /etc/default/incus ]; then
  . /etc/default/incus
fi


incusd_start() {
  echo "Starting incusd:  /usr/sbin/incus --group $INCUSD_GROUP --logfile=/var/log/incus/incusd.log"
  INCUS_EDK2_PATH=/usr/share/edk2-ovmf-x64 /usr/sbin/incusd --group $INCUSD_GROUP --logfile=/var/log/incus/incusd.log 2>/dev/null &

}

incusd_stop() {
  if [ "$(pgrep -fc /usr/sbin/incusd)" -gt "0" ]; then
    echo "Terminating incusd"
    pkill -f /usr/sbin/incusd
  fi
}

incusd_restart() {
  incusd_stop
  sleep 1
  incusd_start
}

case "$1" in
'start')
  # We don't want to run this more than once, so just use restart to start it:
  incusd_restart
  ;;
'stop')
  incusd_stop
  ;;
'restart')
  incusd_restart
  ;;
*)
  incusd_start
esac