-
Notifications
You must be signed in to change notification settings - Fork 161
[master] deb: use upstream init script #926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
--- docker-ce-packaging/deb/common/docker-ce.docker.init 2023-07-21 10:51:08
+++ moby/contrib/init/sysvinit-debian/docker 2023-07-18 13:15:44
@@ -44,14 +44,6 @@
exit 1
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() {
if [ "$(id -u)" != '0' ]; then
log_failure_msg "$DOCKER_DESC must be run as root"
@@ -59,37 +51,10 @@
fi
}
-cgroupfs_mount() {
- # see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
- if grep -v '^#' /etc/fstab | grep -q cgroup \
- || [ ! -e /proc/cgroups ] \
- || [ ! -d /sys/fs/cgroup ]; then
- return
- fi
- if ! mountpoint -q /sys/fs/cgroup; then
- mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
- fi
- (
- cd /sys/fs/cgroup
- for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
- mkdir -p $sys
- if ! mountpoint -q $sys; then
- if ! mount -n -t cgroup -o $sys cgroup $sys; then
- rmdir $sys || true
- fi
- fi
- done
- )
-}
-
case "$1" in
start)
- check_init
-
fail_unless_root
- cgroupfs_mount
-
touch "$DOCKER_LOGFILE"
chgrp docker "$DOCKER_LOGFILE"
@@ -110,14 +75,13 @@
--pidfile "$DOCKER_SSD_PIDFILE" \
--make-pidfile \
-- \
- -p "$DOCKER_PIDFILE" \
- $DOCKER_OPTS \
- >> "$DOCKER_LOGFILE" 2>&1
+ -p "$DOCKER_PIDFILE" \
+ $DOCKER_OPTS \
+ >> "$DOCKER_LOGFILE" 2>&1
log_end_msg $?
;;
stop)
- check_init
fail_unless_root
if [ -f "$DOCKER_SSD_PIDFILE" ]; then
log_begin_msg "Stopping $DOCKER_DESC: $BASE"
@@ -129,9 +93,8 @@
;;
restart)
- check_init
fail_unless_root
- docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null`
+ docker_pid=$(cat "$DOCKER_SSD_PIDFILE" 2> /dev/null || true)
[ -n "$docker_pid" ] \
&& ps -p $docker_pid > /dev/null 2>&1 \
&& $0 stop
@@ -139,13 +102,11 @@
;;
force-reload)
- check_init
fail_unless_root
$0 restart
;;
status)
- check_init
status_of_proc -p "$DOCKER_SSD_PIDFILE" "$DOCKERD" "$DOCKER_DESC"
;;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if green 👍
|
Went ahead and did it for the |
|
was about to ask; one of the symlinks is to a directory, not a file, that's correct? |
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
8bd9ca4 to
2d70345
Compare
|
This entire "deliberate dangling symlink" business is dangerous and #925 is definitely a priority here, I'd say. |
|
For the 24.0 branch, the diff looks like this; diff --git a/deb/common/docker-ce.docker.init b/Users/thajeztah/Projects/docker/contrib/init/sysvinit-debian/docker
index 9c8fa6be73..90dbe3c956 100755
--- a/deb/common/docker-ce.docker.init
+++ b/Users/thajeztah/Projects/docker/contrib/init/sysvinit-debian/docker
@@ -46,7 +46,7 @@ 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
+ 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
@@ -85,7 +85,7 @@ cgroupfs_mount() {
case "$1" in
start)
check_init
-
+
fail_unless_root
cgroupfs_mount
@@ -110,9 +110,9 @@ case "$1" in
--pidfile "$DOCKER_SSD_PIDFILE" \
--make-pidfile \
-- \
- -p "$DOCKER_PIDFILE" \
- $DOCKER_OPTS \
- >> "$DOCKER_LOGFILE" 2>&1
+ -p "$DOCKER_PIDFILE" \
+ $DOCKER_OPTS \
+ >> "$DOCKER_LOGFILE" 2>&1
log_end_msg $?
;;
@@ -131,7 +131,7 @@ case "$1" in
restart)
check_init
fail_unless_root
- docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null`
+ docker_pid=$(cat "$DOCKER_SSD_PIDFILE" 2> /dev/null || true)
[ -n "$docker_pid" ] \
&& ps -p $docker_pid > /dev/null 2>&1 \
&& $0 stop
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(verified both paths via copy paste into my checkout of docker/docker and ls -l 👍)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-LGTM (with the paths fixed 😅)

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

As per the title; prefer the upstream version of the init script.
This resolves #899.