]> git.pld-linux.org Git - packages/docker.git/blob - docker.init
7ba800b07e1e1d95f432f25d763c6a4f95a88108
[packages/docker.git] / docker.init
1 #!/bin/sh
2 #
3 # Create lightweight, portable, self-sufficient containers.
4 #
5 # chkconfig:    345 20 80
6 #
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. \
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 "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/docker ] && . /etc/sysconfig/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/docker ]; then
39                 msg_already_running "Docker"
40                 return
41         fi
42
43         # NOTE: docker daemon actually doesn't go to background, need to do that ourselves
44         # https://github.com/docker/docker/issues/2758
45
46         msg_starting "Docker"
47         daemon --fork --pidfile $pidfile --waitfortime 60 \
48                 /usr/bin/docker daemon $OPTIONS
49
50         RETVAL=$?
51         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/docker
52 }
53
54 stop() {
55         if [ ! -f /var/lock/subsys/docker ]; then
56                 msg_not_running "Docker"
57                 return
58         fi
59
60         # Stop daemons.
61         msg_stopping "Docker"
62         killproc --pidfile $pidfile docker
63         rm -f /var/lock/subsys/docker
64 }
65
66 condrestart() {
67         if [ ! -f /var/lock/subsys/docker ]; then
68                 msg_not_running "Docker"
69                 RETVAL=$1
70                 return
71         fi
72
73         stop
74         start
75 }
76
77 RETVAL=0
78 # See how we were called.
79 case "$1" in
80   start)
81         start
82         ;;
83   stop)
84         stop
85         ;;
86   restart)
87         stop
88         start
89         ;;
90   try-restart)
91         condrestart 0
92         ;;
93   force-reload)
94         condrestart 7
95         ;;
96   status)
97         status --pidfile $pidfile docker docker
98         RETVAL=$?
99         ;;
100   *)
101         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
102         exit 3
103 esac
104
105 exit $RETVAL
This page took 0.08591 seconds and 2 git commands to generate.