forked from ports/contrib
b8befd8d57
--HG-- extra : rebase_source : e80277a18fcae77ca5fdb8e2aa95b23dcccb5c49
50 lines
1.3 KiB
Bash
Executable File
50 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# /etc/rc.d/docker: start/stop docker daemon
|
|
#
|
|
|
|
source /etc/docker.conf
|
|
|
|
case $1 in
|
|
start)
|
|
# Ensure ownership and permissiong of log file.
|
|
touch /var/log/docker.log
|
|
chgrp docker /var/log/docker.log
|
|
chown 640 /var/log/docker.log
|
|
|
|
# Ensure cgroups is properly mounted. (Taken from: https://github.com/dotcloud/docker/blob/v0.9.0/contrib/init/sysvinit-debian/docker#L57-L66)
|
|
if ! grep -q cgroup /proc/mounts; then
|
|
# rough approximation of cgroupfs-mount
|
|
mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
|
|
for sys in $(cut -d' ' -f1 /proc/cgroups); do
|
|
mkdir -p /sys/fs/cgroup/$sys
|
|
if ! mount -n -t cgroup -o $sys cgroup /sys/fs/cgroup/$sys 2>/dev/null; then
|
|
rmdir /sys/fs/cgroup/$sys 2>/dev/null || true
|
|
fi
|
|
done
|
|
fi
|
|
|
|
nohup /usr/bin/docker $DOCKER_OPTS > /var/log/docker.log 2>&1 &
|
|
;;
|
|
stop)
|
|
if [ -f /var/run/docker.pid ]; then
|
|
kill $(< /var/run/docker.pid)
|
|
rm -f /var/run/docker.pid
|
|
rm -f /var/run/docker.sock
|
|
else
|
|
killall -q /usr/bin/docker
|
|
rm -f /var/run/docker.sock
|
|
fi
|
|
;;
|
|
restart)
|
|
$0 stop
|
|
sleep 2
|
|
$0 start
|
|
;;
|
|
*)
|
|
echo "usage: $0 [start|stop|restart]"
|
|
;;
|
|
esac
|
|
|
|
# End of file
|