summaryrefslogtreecommitdiffstats
path: root/recipes-containers/docker
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@windriver.com>2015-04-08 13:26:22 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2015-04-08 13:27:19 -0400
commit19ca5c408ad14bef81d3e785f0cb4a70e95db467 (patch)
tree42efc1a356d69b97e16e5e069aae5421d3b74cbb /recipes-containers/docker
parent29bca75fa656713e3ab64f6ff8d26a679f10a13c (diff)
downloadmeta-virtualization-19ca5c408ad14bef81d3e785f0cb4a70e95db467.tar.gz
docker: add sysvinit script
Adding a basic sysvinit script to docker .. for those that still use sysvinit! Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Diffstat (limited to 'recipes-containers/docker')
-rw-r--r--recipes-containers/docker/docker_git.bb10
-rw-r--r--recipes-containers/docker/files/docker.init126
2 files changed, 135 insertions, 1 deletions
diff --git a/recipes-containers/docker/docker_git.bb b/recipes-containers/docker/docker_git.bb
index 225745a5..a683840d 100644
--- a/recipes-containers/docker/docker_git.bb
+++ b/recipes-containers/docker/docker_git.bb
@@ -22,6 +22,7 @@ SRCREV = "2243e32cbbf1c9809c262a7376d34ca43a7a36dc"
22SRC_URI = "\ 22SRC_URI = "\
23 git://github.com/docker/docker.git \ 23 git://github.com/docker/docker.git \
24 file://docker.service \ 24 file://docker.service \
25 file://docker.init \
25 file://hi.Dockerfile \ 26 file://hi.Dockerfile \
26 " 27 "
27 28
@@ -97,11 +98,15 @@ do_compile() {
97 go install github.com/docker/libcontainer/nsinit/ 98 go install github.com/docker/libcontainer/nsinit/
98} 99}
99 100
100inherit systemd 101inherit systemd update-rc.d
101 102
102SYSTEMD_PACKAGES = "${@base_contains('DISTRO_FEATURES','systemd','${PN}','',d)}" 103SYSTEMD_PACKAGES = "${@base_contains('DISTRO_FEATURES','systemd','${PN}','',d)}"
103SYSTEMD_SERVICE_${PN} = "${@base_contains('DISTRO_FEATURES','systemd','docker.service','',d)}" 104SYSTEMD_SERVICE_${PN} = "${@base_contains('DISTRO_FEATURES','systemd','docker.service','',d)}"
104 105
106INITSCRIPT_PACKAGES += "${@base_contains('DISTRO_FEATURES','sysvinit','${PN}','',d)}"
107INITSCRIPT_NAME_${PN} = "${@base_contains('DISTRO_FEATURES','sysvinit','docker.init','',d)}"
108INITSCRIPT_PARAMS_${PN} = "${OS_DEFAULT_INITSCRIPT_PARAMS}"
109
105do_install() { 110do_install() {
106 mkdir -p ${D}/${bindir} 111 mkdir -p ${D}/${bindir}
107 cp ${S}/bundles/${DOCKER_VERSION}-dev/dynbinary/docker-${DOCKER_VERSION}-dev \ 112 cp ${S}/bundles/${DOCKER_VERSION}-dev/dynbinary/docker-${DOCKER_VERSION}-dev \
@@ -114,6 +119,9 @@ do_install() {
114 install -m 644 ${S}/contrib/init/systemd/docker.* ${D}/${systemd_unitdir}/system 119 install -m 644 ${S}/contrib/init/systemd/docker.* ${D}/${systemd_unitdir}/system
115 # replaces one copied from above with one that uses the local registry for a mirror 120 # replaces one copied from above with one that uses the local registry for a mirror
116 install -m 644 ${WORKDIR}/docker.service ${D}/${systemd_unitdir}/system 121 install -m 644 ${WORKDIR}/docker.service ${D}/${systemd_unitdir}/system
122 else
123 install -d ${D}${sysconfdir}/init.d
124 install -m 0755 ${WORKDIR}/docker.init ${D}${sysconfdir}/init.d/docker.init
117 fi 125 fi
118 126
119 cp ${S}/vendor/bin/nsinit ${D}/${bindir} 127 cp ${S}/vendor/bin/nsinit ${D}/${bindir}
diff --git a/recipes-containers/docker/files/docker.init b/recipes-containers/docker/files/docker.init
new file mode 100644
index 00000000..9c01c758
--- /dev/null
+++ b/recipes-containers/docker/files/docker.init
@@ -0,0 +1,126 @@
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="docker"
26unshare=/usr/bin/unshare
27exec="/usr/bin/$prog"
28pidfile="/var/run/$prog.pid"
29lockfile="/var/lock/subsys/$prog"
30logfile="/var/log/$prog"
31
32[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
33
34start() {
35 [ -x $exec ] || exit 5
36
37 check_for_cleanup
38
39 if ! [ -f $pidfile ]; then
40 printf "Starting $prog:\t"
41 echo "\n$(date)\n" >> $logfile
42 "$unshare" -m -- $exec -d $other_args &>> $logfile &
43 pid=$!
44 touch $lockfile
45 # wait up to 10 seconds for the pidfile to exist. see
46 # https://github.com/docker/docker/issues/5359
47 tries=0
48 while [ ! -f $pidfile -a $tries -lt 10 ]; do
49 sleep 1
50 tries=$((tries + 1))
51 done
52 success
53 echo
54 else
55 failure
56 echo
57 printf "$pidfile still exists...\n"
58 exit 7
59 fi
60}
61
62stop() {
63 echo -n $"Stopping $prog: "
64 killproc $prog
65 retval=$?
66 echo
67 [ $retval -eq 0 ] && rm -f $lockfile
68 return $retval
69}
70
71restart() {
72 stop
73 start
74}
75
76reload() {
77 restart
78}
79
80force_reload() {
81 restart
82}
83
84rh_status() {
85 status -p $pidfile $prog
86}
87
88rh_status_q() {
89 rh_status >/dev/null 2>&1
90}
91
92
93check_for_cleanup() {
94 if [ -f ${pidfile} ]; then
95 /bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile}
96 fi
97}
98
99case "$1" in
100 start)
101 $1
102 ;;
103 stop)
104 $1
105 ;;
106 restart)
107 $1
108 ;;
109 reload)
110 $1
111 ;;
112 force-reload)
113 force_reload
114 ;;
115 status)
116 status
117 ;;
118 condrestart|try-restart)
119 restart
120 ;;
121 *)
122 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
123 exit 2
124esac
125
126exit $?