Skip to content

Commit

Permalink
--init=systemd: fix cgroup check #417
Browse files Browse the repository at this point in the history
  • Loading branch information
mviereck committed Feb 21, 2022
1 parent c893bec commit 80046a3
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions x11docker
Original file line number Diff line number Diff line change
Expand Up @@ -4547,33 +4547,39 @@ check_cgroup() { # check [and create] cgroup mountpoint for syste

[ "$Sharecgroup" = "yes" ] && warning "Option --init=$Initsystem: Sharing /sys/fs/cgroup from host."

findmnt "/sys/fs/cgroup/$Needcgroup" >/dev/null || {
case "$Initsystem" in
systemd)
case "$Cgroupversion" in
v1)
[ "$Startuser" != "root" ] && note "Option --init=$Initsystem: Did not find /sys/fs/cgroup/$Needcgroup
findmnt "/sys/fs/cgroup/$Needcgroup" >/dev/null && return 0

case "$Initsystem" in
systemd)
case "$Cgroupversion" in
v1)
[ "$Startuser" != "root" ] && note "Option --init=$Initsystem: Did not find /sys/fs/cgroup/$Needcgroup
Startup of container is likely to fail."
;;
v2)
Needcgroup=""
;;
esac
;;
*)
note "Option --init=$Initsystem: Did not find /sys/fs/cgroup/$Needcgroup
;;
v2)
Needcgroup=""
;;
esac
;;
*)
note "Option --init=$Initsystem: Did not find /sys/fs/cgroup/$Needcgroup
A possible elogind service in container is likely to fail."
;;
esac
[ "$Needcgroup" ] && note "Option --init=$Initsystem: To create and mount a cgroup
;;
esac

[ -z "$Needcgroup" ] && return 0

[ "$Startuser" != "root" ] && {
note "Option --init=$Initsystem: To create and mount a cgroup
for $Needcgroup, please run x11docker as root.
Or create cgroup mountpoint on host yourself with:
mount -o remount,rw cgroup /sys/fs/cgroup
mkdir -p /sys/fs/cgroup/$Needcgroup
mount -t cgroup cgroup /sys/fs/cgroup/$Needcgroup -o none,name=$Needcgroup"
return 1
}

[ "$Needcgroup" ] && [ "$Sharecgroup" = "yes" ] && [ "$Startuser" = "root" ] && {
[ "$Sharecgroup" = "yes" ] && [ "$Startuser" = "root" ] && {
note "Option --init=$Initsystem: Creating cgroup mountpoint on host for '$Needcgroup'."
findmnt /sys/fs/cgroup -O ro >/dev/null && {
mount -o remount,rw cgroup /sys/fs/cgroup >> "$Containerlogfile" 2>&1
Expand Down Expand Up @@ -5683,7 +5689,7 @@ setup_initsystem() { # option init: set up capabilities, check or cre

case "$Initsystem" in
systemd|sysvinit|openrc|runit)
check_cgroup
check_cgroup ||:
;;
esac

Expand Down Expand Up @@ -7314,6 +7320,14 @@ check_backend() { # option --backend
Backendbin="$(command -v "$Backend")"
;;
yes)
case "$Backend" in
docker|host) ;;
*)
error "Option --backend=$Backend is not supported on MS Windows yet.
If you need this, ask for support at https://github.com/mviereck/x11docker"
return 1
;;
esac
Backendbin="docker.exe"
command -v "$Backendbin" >/dev/null || {
PATH="${PATH:-}:$(convertpath subsystem "C:/Program Files/docker"):$(convertpath subsystem "C:/Program Files/Docker/Docker/resources/bin")"
Expand Down Expand Up @@ -8585,6 +8599,7 @@ check_options_interferences() { # check multiple option interferences, change se
Capability settings do not work as intended.
Needs sysbox >=0.5.0."
check_optionset "--runtime=sysbox-runc" "--alsa --webcam" ||:
Switchcontaineruser="yes"
#Sharewebcam="no"
#Sharealsa="no"
;;
Expand Down

0 comments on commit 80046a3

Please sign in to comment.