]>
Commit | Line | Data |
---|---|---|
345101bd ER |
1 | #!/bin/sh |
2 | # | |
51de77f0 | 3 | # Create lightweight, portable, self-sufficient containers. |
345101bd | 4 | # |
09414b03 | 5 | # chkconfig: 345 20 80 |
345101bd | 6 | # |
51de77f0 ER |
7 | # description: Docker is an open-source project to easily create lightweight, portable, \ |
8 | # self-sufficient containers from any application. The same container that a \ | |
9 | # developer builds and tests on a laptop can run at scale, in production, on \ | |
10 | # VMs, bare metal, OpenStack clusters, public clouds and more. \ | |
345101bd ER |
11 | # processname: docker |
12 | # pidfile: /var/run/docker.pid | |
13 | # | |
14 | ||
15 | # Source function library | |
16 | . /etc/rc.d/init.d/functions | |
17 | ||
18 | # Get network config | |
19 | . /etc/sysconfig/network | |
20 | ||
21 | # Check that networking is up. | |
22 | if is_yes "${NETWORKING}"; then | |
23 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
24 | msg_network_down "LXC Docker" | |
25 | exit 1 | |
26 | fi | |
27 | else | |
28 | exit 0 | |
29 | fi | |
30 | ||
31 | # Get service config - may override defaults | |
32 | [ -f /etc/sysconfig/lxc-docker ] && . /etc/sysconfig/lxc-docker | |
33 | ||
34 | pidfile="/var/run/docker.pid" | |
35 | ||
36 | start() { | |
37 | # Check if the service is already running? | |
38 | if [ -f /var/lock/subsys/lxc-docker ]; then | |
39 | msg_already_running "LXC Docker" | |
40 | return | |
41 | fi | |
42 | ||
43 | msg_starting "LXC Docker" | |
44 | daemon --fork /usr/bin/docker -d | |
45 | RETVAL=$? | |
46 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lxc-docker | |
47 | } | |
48 | ||
49 | stop() { | |
50 | if [ ! -f /var/lock/subsys/lxc-docker ]; then | |
51 | msg_not_running "LXC Docker" | |
52 | return | |
53 | fi | |
54 | ||
55 | # Stop daemons. | |
56 | msg_stopping "LXC Docker" | |
57 | killproc --pidfile $pidfile docker -TERM | |
58 | rm -f /var/lock/subsys/lxc-docker | |
59 | } | |
60 | ||
61 | condrestart() { | |
62 | if [ ! -f /var/lock/subsys/lxc-docker ]; then | |
63 | msg_not_running "LXC Docker" | |
64 | RETVAL=$1 | |
65 | return | |
66 | fi | |
67 | ||
68 | stop | |
69 | start | |
70 | } | |
71 | ||
72 | RETVAL=0 | |
73 | # See how we were called. | |
74 | case "$1" in | |
75 | start) | |
76 | start | |
77 | ;; | |
78 | stop) | |
79 | stop | |
80 | ;; | |
81 | restart) | |
82 | stop | |
83 | start | |
84 | ;; | |
85 | try-restart) | |
86 | condrestart 0 | |
87 | ;; | |
88 | force-reload) | |
89 | condrestart 7 | |
90 | ;; | |
91 | status) | |
92 | status --pidfile $pidfile lxc-docker docker | |
93 | RETVAL=$? | |
94 | ;; | |
95 | *) | |
96 | msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" | |
97 | exit 3 | |
98 | esac | |
99 | ||
100 | exit $RETVAL |