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>
This commit is contained in:
Bruce Ashfield 2015-04-08 13:26:22 -04:00
parent 29bca75fa6
commit 19ca5c408a
2 changed files with 135 additions and 1 deletions

View File

@ -22,6 +22,7 @@ SRCREV = "2243e32cbbf1c9809c262a7376d34ca43a7a36dc"
SRC_URI = "\
git://github.com/docker/docker.git \
file://docker.service \
file://docker.init \
file://hi.Dockerfile \
"
@ -97,11 +98,15 @@ do_compile() {
go install github.com/docker/libcontainer/nsinit/
}
inherit systemd
inherit systemd update-rc.d
SYSTEMD_PACKAGES = "${@base_contains('DISTRO_FEATURES','systemd','${PN}','',d)}"
SYSTEMD_SERVICE_${PN} = "${@base_contains('DISTRO_FEATURES','systemd','docker.service','',d)}"
INITSCRIPT_PACKAGES += "${@base_contains('DISTRO_FEATURES','sysvinit','${PN}','',d)}"
INITSCRIPT_NAME_${PN} = "${@base_contains('DISTRO_FEATURES','sysvinit','docker.init','',d)}"
INITSCRIPT_PARAMS_${PN} = "${OS_DEFAULT_INITSCRIPT_PARAMS}"
do_install() {
mkdir -p ${D}/${bindir}
cp ${S}/bundles/${DOCKER_VERSION}-dev/dynbinary/docker-${DOCKER_VERSION}-dev \
@ -114,6 +119,9 @@ do_install() {
install -m 644 ${S}/contrib/init/systemd/docker.* ${D}/${systemd_unitdir}/system
# replaces one copied from above with one that uses the local registry for a mirror
install -m 644 ${WORKDIR}/docker.service ${D}/${systemd_unitdir}/system
else
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/docker.init ${D}${sysconfdir}/init.d/docker.init
fi
cp ${S}/vendor/bin/nsinit ${D}/${bindir}

View File

@ -0,0 +1,126 @@
#!/bin/sh
#
# /etc/rc.d/init.d/docker
#
# Daemon for docker.com
#
# chkconfig: 2345 95 95
# description: Daemon for docker.com
### BEGIN INIT INFO
# Provides: docker
# Required-Start: $network cgconfig
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop docker
# Description: Daemon for docker.com
### END INIT INFO
# Source function library.
. /etc/init.d/functions
prog="docker"
unshare=/usr/bin/unshare
exec="/usr/bin/$prog"
pidfile="/var/run/$prog.pid"
lockfile="/var/lock/subsys/$prog"
logfile="/var/log/$prog"
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
start() {
[ -x $exec ] || exit 5
check_for_cleanup
if ! [ -f $pidfile ]; then
printf "Starting $prog:\t"
echo "\n$(date)\n" >> $logfile
"$unshare" -m -- $exec -d $other_args &>> $logfile &
pid=$!
touch $lockfile
# wait up to 10 seconds for the pidfile to exist. see
# https://github.com/docker/docker/issues/5359
tries=0
while [ ! -f $pidfile -a $tries -lt 10 ]; do
sleep 1
tries=$((tries + 1))
done
success
echo
else
failure
echo
printf "$pidfile still exists...\n"
exit 7
fi
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status -p $pidfile $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
check_for_cleanup() {
if [ -f ${pidfile} ]; then
/bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile}
fi
}
case "$1" in
start)
$1
;;
stop)
$1
;;
restart)
$1
;;
reload)
$1
;;
force-reload)
force_reload
;;
status)
status
;;
condrestart|try-restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?