]> git.pld-linux.org Git - packages/lxd.git/blame - lxd.init
- up to 4.24
[packages/lxd.git] / lxd.init
CommitLineData
da7971c6 1#!/bin/sh
2#
3# Container hypervisor and a new user experience for LXC
4#
5# chkconfig: 345 20 80
6#
7# processname: lxd
8# pidfile: /var/run/lxd.pid
9#
10
11# Source function library
12. /etc/rc.d/init.d/functions
13
14# Get network config
15. /etc/sysconfig/network
16
17# Check that networking is up.
18if is_yes "${NETWORKING}"; then
19 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
20 msg_network_down "lxd"
21 exit 1
22 fi
23else
24 exit 0
25fi
26
27# Get service config - may override defaults
28[ -f /etc/sysconfig/lxd ] && . /etc/sysconfig/lxd
29OPTIONS="$OPTIONS --group lxd --logfile /var/log/lxd/lxd.log"
30
31pidfile="/var/run/lxd.pid"
32
33start() {
34 if status --pidfile $pidfile lxd lxd >/dev/null; then
35 msg_already_running "lxd"
4ecaeaab 36 RETVAL=1
da7971c6 37 return
38 fi
4ecaeaab 39
da7971c6 40 msg_starting "lxd"
c04fdf45 41 daemon --fork --waitforname lxd /usr/lib/lxd-wrapper daemon $OPTIONS
da7971c6 42
43 # lxd does not write pidfile, so create one
44 show "Checking lxd daemon status"
45 busy
15809549 46
47 if lxd waitready --timeout=16 2>/dev/null; then
48 pid=$(lxc info 2>/dev/null | awk '/server_pid:/{print $2}')
49 [ -n "$pid" ] && echo $pid > $pidfile
50 fi
da7971c6 51
52 if [ -n "$pid" ]; then
a89a534c
ER
53 touch /var/lock/subsys/lxd
54 ok
55 RETVAL=0
da7971c6 56 else
a89a534c
ER
57 fail
58 RETVAL=1
da7971c6 59 fi
60}
61
62stop() {
63 if [ ! -f /var/lock/subsys/lxd ]; then
64 msg_not_running "lxd"
65 return
66 fi
67
68 # Stop daemons.
69 msg_stopping "lxd"
70 /usr/sbin/lxd shutdown
a89a534c 71 busy
da7971c6 72 sleep 1
73 if status --pidfile $pidfile lxd lxd >/dev/null; then
74 killproc --pidfile $pidfile lxd
75 else
76 ok
a89a534c 77 fi
da7971c6 78 rm -f /var/lock/subsys/lxd
79}
80
81condrestart() {
82 if [ ! -f /var/lock/subsys/lxd ]; then
83 msg_not_running "lxd"
84 RETVAL=$1
85 return
86 fi
87
88 stop
89 start
90}
91
92RETVAL=0
93# See how we were called.
94case "$1" in
95 start)
96 start
97 ;;
98 stop)
99 stop
100 ;;
101 restart)
102 stop
103 start
104 ;;
105 try-restart)
106 condrestart 0
107 ;;
108 force-reload)
109 condrestart 7
110 ;;
111 status)
112 status --pidfile $pidfile lxd lxd
113 RETVAL=$?
114 ;;
115 *)
116 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
117 exit 3
118esac
119
120exit $RETVAL
This page took 0.102809 seconds and 4 git commands to generate.