Last active
December 27, 2015 16:09
-
-
Save igaki/7352479 to your computer and use it in GitHub Desktop.
/etc/init.d/lxc-docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: lxc-docker | |
# Required-Start: $syslog $remote_fs | |
# Required-Stop: $syslog $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Linux container runtime | |
# Description: Linux container runtime | |
### END INIT INFO | |
DOCKER=/usr/bin/docker | |
# Check lxc-docker is present | |
[ -x $DOCKER ] || (log_failure_msg "lxc-docker not present"; exit 1) | |
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin | |
# Get lsb functions | |
. /etc/init.d/functions | |
check_root_id () | |
{ | |
if [ "$(id -u)" != "0" ]; then | |
log_failure_msg "LXC Docker must be run as root"; exit 1 | |
fi | |
} | |
# -g /share changes location of docker repositories | |
case "$1" in | |
start) | |
check_root_id || exit 1 | |
mount | grep cgroup >/dev/null || mount -t cgroup none /sys/fs/cgroup | |
daemon "$DOCKER" -d -g /share & | |
;; | |
stop) | |
check_root_id || exit 1 | |
mount | grep cgroup >/dev/null && umount /sys/fs/cgroup | |
kill $(echo $(ps -ef |grep docker | egrep -v "vi|grep" | awk '{print $2}')) | |
;; | |
restart) | |
check_root_id || exit 1 | |
docker_pid=`pgrep -f "$DOCKER -d -g /share "` | |
[ -n "$docker_pid" ] && /etc/init.d/lxc-docker stop | |
/etc/init.d/lxc-docker start | |
;; | |
force-reload) | |
check_root_id || exit 1 | |
/etc/init.d/lxc-docker restart | |
;; | |
status) | |
docker_pid=`pgrep -f "$DOCKER -d"` | |
if [ -z "$docker_pid" ] ; then | |
echo "lxc-docker not running" | |
else | |
echo "lxc-docker running (pid $docker_pid)" | |
fi | |
;; | |
*) | |
echo "Usage: /etc/init.d/lxc-docker {start|stop|restart|status}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lxc-docker is used for docker setup on CentOS6.4.
In the above code,
daemon $DOCKER" -d -g /share &
is writtern.This part of code was
daemon $DOCKER" -d &
originally.This modification means docker image or container files are stored in /share.