Browse code

Added sysvinit/sysconfig files for redhat family of distros (RHEL/CentOS/SL/etc.)

Docker-DCO-1.1-Signed-off-by: Adam Miller <admiller@redhat.com> (github: maxamillion)

Adam Miller authored on 2014/02/06 05:35:44
Showing 2 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,128 @@
0
+#!/bin/sh
1
+#
2
+#       /etc/rc.d/init.d/docker
3
+#
4
+#       Daemon for docker.io
5
+#       
6
+# chkconfig:   2345 95 95
7
+# description: Daemon for docker.io
8
+
9
+### BEGIN INIT INFO
10
+# Provides:       docker
11
+# Required-Start: $network cgconfig
12
+# Required-Stop:
13
+# Should-Start:
14
+# Should-Stop:
15
+# Default-Start: 2 3 4 5
16
+# Default-Stop:  0 1 6
17
+# Short-Description: start and stop docker
18
+# Description: Daemon for docker.io
19
+### END INIT INFO
20
+
21
+# Source function library.
22
+. /etc/rc.d/init.d/functions
23
+
24
+prog="docker"
25
+exec="/usr/bin/$prog"
26
+pidfile="/var/run/$prog.pid"
27
+lockfile="/var/lock/subsys/$prog"
28
+logfile="/var/log/$prog"
29
+
30
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
31
+
32
+prestart() {
33
+    service cgconfig status > /dev/null
34
+
35
+    if [[ $? != 0 ]]; then
36
+        service cgconfig start
37
+    fi
38
+
39
+    preexec="/sbin/sysctl"
40
+    [ -x $preexec ] || exit 6
41
+    $preexec -w net.ipv4.ip_forward=1 > /dev/null 2>&1
42
+    $preexec -w net.ipv6.conf.all.forwarding=1 > /dev/null 2>&1
43
+
44
+}
45
+
46
+start() {
47
+    [ -x $exec ] || exit 5
48
+
49
+    if ! [ -f $pidfile ]; then
50
+        prestart
51
+        printf "Starting $prog:\t"
52
+        echo "\n$(date)\n" >> $logfile
53
+        $exec -d $other_args &>> $logfile &
54
+        pid=$!
55
+        touch $lockfile
56
+        success
57
+        echo
58
+    else
59
+        failure
60
+        echo
61
+        printf "$pidfile still exists...\n"
62
+        exit 7
63
+    fi
64
+}
65
+
66
+stop() {
67
+    echo -n $"Stopping $prog: "
68
+    killproc -p $pidfile $prog
69
+    retval=$?
70
+    echo
71
+    [ $retval -eq 0 ] && rm -f $lockfile
72
+    return $retval
73
+}
74
+
75
+restart() {
76
+    stop
77
+    start
78
+}
79
+
80
+reload() {
81
+    restart
82
+}
83
+
84
+force_reload() {
85
+    restart
86
+}
87
+
88
+rh_status() {
89
+    status -p $pidfile $prog
90
+}
91
+
92
+rh_status_q() {
93
+    rh_status >/dev/null 2>&1
94
+}
95
+
96
+case "$1" in
97
+    start)
98
+        rh_status_q && exit 0
99
+        $1
100
+        ;;
101
+    stop)
102
+        rh_status_q || exit 0
103
+        $1
104
+        ;;
105
+    restart)
106
+        $1
107
+        ;;
108
+    reload)
109
+        rh_status_q || exit 7
110
+        $1
111
+        ;;
112
+    force-reload)
113
+        force_reload
114
+        ;;
115
+    status)
116
+        rh_status
117
+        ;;
118
+    condrestart|try-restart)
119
+        rh_status_q || exit 0
120
+        restart
121
+        ;;
122
+    *)
123
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
124
+        exit 2
125
+esac
126
+
127
+exit $?
0 128
new file mode 100644
... ...
@@ -0,0 +1,7 @@
0
+# /etc/sysconfig/docker
1
+# 
2
+# Other arguments to pass to the docker daemon process
3
+# These will be parsed by the sysv initscript and appended
4
+# to the arguments list passed to docker -d
5
+
6
+other_args=""