summaryrefslogtreecommitdiffstats
path: root/recipes-containers/docker/files/docker.init
diff options
context:
space:
mode:
authorMartin Jansa <martin.jansa@lge.com>2020-07-02 17:39:07 +0200
committerBruce Ashfield <bruce.ashfield@gmail.com>2020-07-02 12:09:10 -0400
commit87b9e054ff1b4812194af9f0b4f3083400d42095 (patch)
treebf1d8dc9cf6a618a8efd63fe42d03c9fe80dd8a6 /recipes-containers/docker/files/docker.init
parent70d832f37af186bf7c7fabc0dbce3b356ba5cc1a (diff)
downloadmeta-virtualization-87b9e054ff1b4812194af9f0b4f3083400d42095.tar.gz
docker: move docker.init back to files directory to use it from docker-moby
* it was moved for some reason in: http://git.yoctoproject.org/cgit/cgit.cgi/meta-virtualization/commit/?id=929372946aeb85953d1ca6acc428d73fbac52a56 but docker-moby uses it as well and now started to fail with: ERROR: docker-moby-19.03.12+git9dc6525e6118a25fab2be322d1914740ea842495-r0 do_fetch: Fetcher failure: Unable to find file file://docker.init anywhere. .. Signed-off-by: Martin Jansa <martin.jansa@lge.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-containers/docker/files/docker.init')
-rw-r--r--recipes-containers/docker/files/docker.init131
1 files changed, 131 insertions, 0 deletions
diff --git a/recipes-containers/docker/files/docker.init b/recipes-containers/docker/files/docker.init
new file mode 100644
index 00000000..24f8fea6
--- /dev/null
+++ b/recipes-containers/docker/files/docker.init
@@ -0,0 +1,131 @@
1#!/bin/sh
2#
3# /etc/rc.d/init.d/docker
4#
5# Daemon for docker.com
6#
7# chkconfig: 2345 95 95
8# description: Daemon for docker.com
9
10### BEGIN INIT INFO
11# Provides: docker
12# Required-Start: $network cgconfig
13# Required-Stop:
14# Should-Start:
15# Should-Stop:
16# Default-Start: 2 3 4 5
17# Default-Stop: 0 1 6
18# Short-Description: start and stop docker
19# Description: Daemon for docker.com
20### END INIT INFO
21
22# Source function library.
23. /etc/init.d/functions
24
25prog="dockerd"
26unshare=/usr/bin/unshare
27exec="/usr/bin/$prog"
28pidfile="/var/run/$prog.pid"
29lockfile="/var/lock/subsys/$prog"
30logfile="/var/log/$prog"
31other_args="--pidfile $pidfile --registry-mirror=http://localhost:5000 --insecure-registry=http://localhost:5000 --raw-logs"
32
33[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
34
35start() {
36 [ -x $exec ] || exit 5
37
38 check_for_cleanup
39
40 if ! [ -f $pidfile ]; then
41 printf "Starting $prog:\t"
42 echo -e "\n$(date)\n" >> $logfile
43 "$unshare" -m -- $exec $other_args >> $logfile 2>&1 &
44 pid=$!
45 touch $lockfile
46 # wait up to 10 seconds for the pidfile to exist. see
47 # https://github.com/docker/docker/issues/5359
48 tries=0
49 while [ ! -f $pidfile -a $tries -lt 10 ]; do
50 sleep 1
51 tries=$((tries + 1))
52 done
53 success
54 echo
55 else
56 failure
57 echo
58 printf "$pidfile still exists...\n"
59 exit 7
60 fi
61}
62
63stop() {
64 echo -n $"Stopping $prog: "
65 killproc $prog
66 retval=$?
67 echo
68 [ $retval -eq 0 ] && rm -f $lockfile
69 return $retval
70}
71
72restart() {
73 stop
74 start
75}
76
77reload() {
78 restart
79}
80
81force_reload() {
82 restart
83}
84
85rh_status() {
86 status $prog
87}
88
89rh_status_q() {
90 rh_status >/dev/null 2>&1
91}
92
93
94check_for_cleanup() {
95 if [ -f ${pidfile} ]; then
96 /bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile}
97 fi
98}
99
100case "$1" in
101 start)
102 rh_status_q && exit 0
103 $1
104 ;;
105 stop)
106 rh_status_q || exit 0
107 $1
108 ;;
109 restart)
110 $1
111 ;;
112 reload)
113 rh_status_q || exit 7
114 $1
115 ;;
116 force-reload)
117 force_reload
118 ;;
119 status)
120 rh_status
121 ;;
122 condrestart|try-restart)
123 rh_status_q || exit 0
124 restart
125 ;;
126 *)
127 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
128 exit 2
129esac
130
131exit $?