up to 1.6.2 (2015-05-13)
[packages/docker.git] / docker.init
CommitLineData
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.
22if is_yes "${NETWORKING}"; then
23 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
47009a45 24 msg_network_down "Docker"
345101bd
ER
25 exit 1
26 fi
27else
28 exit 0
29fi
30
31# Get service config - may override defaults
47009a45 32[ -f /etc/sysconfig/docker ] && . /etc/sysconfig/docker
345101bd
ER
33
34pidfile="/var/run/docker.pid"
35
36start() {
37 # Check if the service is already running?
47009a45
ER
38 if [ -f /var/lock/subsys/docker ]; then
39 msg_already_running "Docker"
345101bd
ER
40 return
41 fi
42
47009a45 43 msg_starting "Docker"
62b620a7 44 daemon --fork /usr/bin/docker -d $OPTIONS
345101bd 45 RETVAL=$?
47009a45 46 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/docker
345101bd
ER
47}
48
49stop() {
47009a45
ER
50 if [ ! -f /var/lock/subsys/docker ]; then
51 msg_not_running "Docker"
345101bd
ER
52 return
53 fi
54
55 # Stop daemons.
47009a45 56 msg_stopping "Docker"
b16e11f6 57 killproc --pidfile $pidfile docker
47009a45 58 rm -f /var/lock/subsys/docker
345101bd
ER
59}
60
61condrestart() {
47009a45
ER
62 if [ ! -f /var/lock/subsys/docker ]; then
63 msg_not_running "Docker"
345101bd
ER
64 RETVAL=$1
65 return
66 fi
67
68 stop
69 start
70}
71
72RETVAL=0
73# See how we were called.
74case "$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)
47009a45 92 status --pidfile $pidfile docker docker
345101bd
ER
93 RETVAL=$?
94 ;;
95 *)
96 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
97 exit 3
98esac
99
100exit $RETVAL
This page took 0.205169 seconds and 4 git commands to generate.