|
@@ -39,18 +39,20 @@ if [ -f /etc/default/$BASE ]; then
|
|
. /etc/default/$BASE
|
|
. /etc/default/$BASE
|
|
fi
|
|
fi
|
|
|
|
|
|
-# see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it)
|
|
|
|
-if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then
|
|
|
|
- log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1"
|
|
|
|
- exit 1
|
|
|
|
-fi
|
|
|
|
-
|
|
|
|
# Check docker is present
|
|
# Check docker is present
|
|
if [ ! -x $DOCKER ]; then
|
|
if [ ! -x $DOCKER ]; then
|
|
log_failure_msg "$DOCKER not present or not executable"
|
|
log_failure_msg "$DOCKER not present or not executable"
|
|
exit 1
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
+check_init() {
|
|
|
|
+ # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it directly)
|
|
|
|
+ if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then
|
|
|
|
+ log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1"
|
|
|
|
+ exit 1
|
|
|
|
+ fi
|
|
|
|
+}
|
|
|
|
+
|
|
fail_unless_root() {
|
|
fail_unless_root() {
|
|
if [ "$(id -u)" != '0' ]; then
|
|
if [ "$(id -u)" != '0' ]; then
|
|
log_failure_msg "$DOCKER_DESC must be run as root"
|
|
log_failure_msg "$DOCKER_DESC must be run as root"
|
|
@@ -83,6 +85,8 @@ cgroupfs_mount() {
|
|
|
|
|
|
case "$1" in
|
|
case "$1" in
|
|
start)
|
|
start)
|
|
|
|
+ check_init
|
|
|
|
+
|
|
fail_unless_root
|
|
fail_unless_root
|
|
|
|
|
|
cgroupfs_mount
|
|
cgroupfs_mount
|
|
@@ -111,6 +115,7 @@ case "$1" in
|
|
;;
|
|
;;
|
|
|
|
|
|
stop)
|
|
stop)
|
|
|
|
+ check_init
|
|
fail_unless_root
|
|
fail_unless_root
|
|
log_begin_msg "Stopping $DOCKER_DESC: $BASE"
|
|
log_begin_msg "Stopping $DOCKER_DESC: $BASE"
|
|
start-stop-daemon --stop --pidfile "$DOCKER_SSD_PIDFILE"
|
|
start-stop-daemon --stop --pidfile "$DOCKER_SSD_PIDFILE"
|
|
@@ -118,6 +123,7 @@ case "$1" in
|
|
;;
|
|
;;
|
|
|
|
|
|
restart)
|
|
restart)
|
|
|
|
+ check_init
|
|
fail_unless_root
|
|
fail_unless_root
|
|
docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null`
|
|
docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null`
|
|
[ -n "$docker_pid" ] \
|
|
[ -n "$docker_pid" ] \
|
|
@@ -127,16 +133,18 @@ case "$1" in
|
|
;;
|
|
;;
|
|
|
|
|
|
force-reload)
|
|
force-reload)
|
|
|
|
+ check_init
|
|
fail_unless_root
|
|
fail_unless_root
|
|
$0 restart
|
|
$0 restart
|
|
;;
|
|
;;
|
|
|
|
|
|
status)
|
|
status)
|
|
|
|
+ check_init
|
|
status_of_proc -p "$DOCKER_SSD_PIDFILE" "$DOCKER" "$DOCKER_DESC"
|
|
status_of_proc -p "$DOCKER_SSD_PIDFILE" "$DOCKER" "$DOCKER_DESC"
|
|
;;
|
|
;;
|
|
|
|
|
|
*)
|
|
*)
|
|
- echo "Usage: $0 {start|stop|restart|status}"
|
|
|
|
|
|
+ echo "Usage: service docker {start|stop|restart|status}"
|
|
exit 1
|
|
exit 1
|
|
;;
|
|
;;
|
|
esac
|
|
esac
|