From 274fcd322f3486f21b1698b14a62ac25b7d481e0 Mon Sep 17 00:00:00 2001 From: mviereck Date: Thu, 12 Apr 2018 02:38:00 +0200 Subject: [PATCH] Release v4.1.1 --- CHANGELOG.md | 8 +++-- x11docker | 94 +++++++++++++++++++++++++++------------------------ x11docker-gui | 2 +- 3 files changed, 56 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2863157..dae61bf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,15 +5,19 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) since version 4.0.0. Project website: https://github.com/mviereck/x11docker - ## [Unreleased] + - master branch is currently equal with latest release. + +## [4.1.1] ### Changed - Mount nothing into `/tmp` as init cleanups may try (and fail) to delete it. - Write or link into `/tmp` only _after_ possible init cleanup. - Mount X socket r/w again as there is no longer a risk due to `/tmp` cleanups. - - `--debug`: Experimental changes for more useful debugging output. + - `--debug`: Some changes for more useful debugging output. Drop `set -x` in main code, instead `set -Eu` with `trap ERR`. - `--update`/`--update-master`: Show excerpt of `CHANGELOG.md`. + - Check `ENTRYPOINT` for init entries `/tini|/init|/systemd` and disable it if x11docker already runs an init. (Default: `--tini`.) ### Fixed + - `x11docker-gui` regards new output of container ID now that confused output of `x11docker/kaptain` and prevented start of `x11docker`. - Mount `WAYLAND_DISPLAY` and `DISPLAY` at `/` instead of `/x11docker/` in container. Avoids a docker bug that only sometimes causes startup failure `stat /run/user/1000/wayland-600: no such file or directory`. Occasionally docker is confused about a mount point inside of a mount point. Avoiding that now. diff --git a/x11docker b/x11docker index 85cfdc8f..41568e1b 100755 --- a/x11docker +++ b/x11docker @@ -10,7 +10,7 @@ # Type 'x11docker --help' or scroll down to read usage information. # More documentation at https://github.com/mviereck/x11docker -Version="4.1.1-beta" +Version="4.1.1" usage() { # --help: show usage information echo " @@ -253,7 +253,7 @@ Miscellaneous: Verbose options: -v, --verbose Be verbose. (Shows logfiles). --silent Do not show terminal messages (except errors). - --debug Debug mode: show command lines while executed. (set -x) + --debug Debug mode: Show some debug output, --stdout Show stdout of container applications. --stderr Show stderr of container applications. @@ -535,13 +535,17 @@ installer() { # --install, --update, --update-master, --remove: Instal --update) echo "$Oldversion" | grep -q beta && { warning "You are switching from master branch to stable releases. - To get latest master version, use option --update-master instead" + To get latest master beta version, use option --update-master instead" Key1="\[${Newversion}\]" Key2="https:\/\/github.com\/mviereck\/x11docker\/releases" } || { Key1="\[${Newversion}\]" Key2="\[${Oldversion}\]" - [ "$Newversion" = "$Oldversion" ] && Key2="https:\/\/github.com\/mviereck\/x11docker\/releases" && note "Version $Newversion was already installed." + [ "$Newversion" = "$Oldversion" ] && { + Key2="https:\/\/github.com\/mviereck\/x11docker\/releases" + note "Version $Newversion was already installed before this update. + If you want the latest beta version from master branch, use --update-master." + } } ;; --update-master) @@ -697,7 +701,7 @@ x11docker --cleanup" [ "$Preservecachefiles" = "no" ] && echo "$Cachefolder" | grep -q .cache && echo "$Cachefolder" | grep -q x11docker && [ "x11docker" != "$(basename "$Cachefolder")" ] && rm -f -R "$Cachefolder" if [ -e "$Errorfile" ]; then rm "$Errorfile" ; exit 1; else exit 0; fi } -traperror() { # trap ERR: --debug: Output for debugging +traperror() { # trap ERR: --debug: Output for 'set -o errtrace' warning "Command at Line ${2:-} returned with error code ${1:-}: ${4:-} ${3:-} - ${5:-}" @@ -713,7 +717,7 @@ mywatch() { # repeat $1 untils its output changes # --interval must be integer for centos and fedora depite contrary documentation in manpage verbose "Watching: sh -c '${1:-}' Current output: -$(sh -c "${1:-}")" +$(sh -c "${1:-}" ||:)" env TERM=linux watch --interval 1 --chgexit --no-title -- "${1:-}" >/dev/null 2>&1 #Watchoutput="$(sh -c "${1:-}" 2>&1)" #while sleep 1 ; do @@ -721,7 +725,7 @@ $(sh -c "${1:-}")" #done verbose "Stopped watching: sh -c '${1:-}' Current output: -$(sh -c "${1:-}")" +$(sh -c "${1:-}" ||:)" } isnum() { # check if $1 is a number [ "1" = "$(awk -v a="${1:-}" 'BEGIN {print (a == a + 0)}')" ] @@ -751,19 +755,19 @@ waitforfilecreation() { # similar to inotify-wait: wait up to 15s for file $1 to local Zeit Warten Zeit=$(date +%s) verbose "Waiting for file creation of ${1:-}" - case $2 in + case ${2:-} in "") Warten=15 ;; infinity|inf) Warten=32000 ;; # nearly infinity in fast-moving today ... *) Warten=${2:-} ;; esac while [ ! "$(find "${1:-}" 2>/dev/null)" ] ; do sleep 0.2 - [ $Warten -lt $(expr $(date +%s) - $Zeit) ] && { + [ $Warten -lt $(($(date +%s) - $Zeit)) ] && { warning "Failed to wait for file creation of ${1:-}" return 1 } - verbose "waiting since $(expr $(date +%s) - $Zeit)s for ${1:-} to be created, will wait up to $Warten seconds." + verbose "waiting since $(($(date +%s) - $Zeit))s for ${1:-} to be created, will wait up to $Warten seconds." [ -e "$Timetosaygoodbye" ] && { verbose "stopped waiting for ${1:-} due to terminating signal." return 1 @@ -827,7 +831,7 @@ mkfile() { # create file $1 owned by $Hostuser :> "${1:-}" chown $Hostuser "${1:-}" chgrp $Hostusergid "${1:-}" - [ -n "${2:-}" ] && chmod ${2:-} "${1:-}" + [ -n "${2:-}" ] && chmod ${2:-} "${1:-}" ||: } { #### part: declare variables @@ -1319,8 +1323,8 @@ $Customenvironment" ; shift ;; # set custom environm Command 'logname' does not return a value. Consider to use another terminal emulator. Fallback: Will try to check \$SUDO_USER and \$PKEXEC_UID." - [ -z "$Lognameuser" ] && [ -n "$SUDO_USER" ] && Lognameuser="$SUDO_USER" && [ -z "$Hostuser" ] && note "Will use \$SUDO_USER = $SUDO_USER as host user." - [ -z "$Lognameuser" ] && [ -n "$PKEXEC_UID" ] && Lognameuser="$PKEXEC_UID" && [ -z "$Hostuser" ] && note "Will use user with uid \$PKEXEC_UID = $PKEXEC_UID as host user." + [ -z "$Lognameuser" ] && [ -n "${SUDO_USER:-}" ] && Lognameuser="${SUDO_USER:-}" && [ -z "$Hostuser" ] && note "Will use \$SUDO_USER = ${SUDO_USER:-} as host user." + [ -z "$Lognameuser" ] && [ -n "${PKEXEC_UID:-}" ] && Lognameuser="${PKEXEC_UID:-}" && [ -z "$Hostuser" ] && note "Will use user with uid \$PKEXEC_UID = ${PKEXEC_UID:-} as host user." [ -z "$Lognameuser" ] && Lognameuser="$(id -un)" && [ -z "$Hostuser" ] && note "Will use \$(id -un) = $Lognameuser as host user." # option --hostuser @@ -1363,12 +1367,12 @@ Command: $0 $X11dockerargs Parsed options: $Parsedoptions" [ "$Debug" = "yes" ] && { - # PS4="$DebugPS4" && set -x - set -E - #set -u + #PS4="$DebugPS4" # useful output for set -x + #set -x # show every executed line + set -Eu -o pipefail trap 'traperror $? $LINENO $BASH_LINENO "$BASH_COMMAND" $(printf "::%s" ${FUNCNAME[@]})' ERR } - + [ "$Cacherootfolder" != "$(echo $Cacherootfolder | sed -e 's/ *//g')" ] && error "Cache root folder must not contain whitespaces. $Cacherootfolder" @@ -1682,7 +1686,7 @@ Parsed options: $Parsedoptions" } ;; esac - [ -n "$PKEXEC_UID" ] && [ -z "$Hostdisplay" ] && [ "$Tty" = "no" ] && [ "$Xserver" != "--xorg" ] && { + [ -n "${PKEXEC_UID:-}" ] && [ -z "$Hostdisplay" ] && [ "$Tty" = "no" ] && [ "$Xserver" != "--xorg" ] && { note "It seems you have started x11docker with pkexec. Can not determine DISPLAY and XAUTHORITY, can not use your X server. To allow other X server options, please provide environment variables with @@ -2743,7 +2747,7 @@ $(tail "$Compositorlogfile")" --xephyr) case $Fullscreen in yes) Xephyroptions="$Xephyroptions -fullscreen" ;; - no) for Count in $(seq 1 $Outputcount) ; do Xephyroptions="$Xephyroptions -screen $Screensize" ; done ;; + no) for ((Count=1 ; Count<=$Outputcount ; Count++)) ; do Xephyroptions="$Xephyroptions -screen $Screensize" ; done ;; esac [ "$Xephyrglamor" = "yes" ] && Xephyroptions="$Xephyroptions -glamor" # deprecated option '--glamor' Xcommand="$(command -v Xephyr) $Newdisplay $Xephyroptions \\ @@ -2800,7 +2804,7 @@ $(tail "$Compositorlogfile")" $Xserveroptions" [ "$Xserver" = "--weston" ] && Sharewayland="yes" Waylandsocket="wayland-$Newdisplaynumber" - [ -n "$Westonoutput" ] && for Count in $(seq 1 $Outputcount) ; do + [ -n "$Westonoutput" ] && for ((Count=1 ; Count<=$Outputcount ; Count++)) ; do [ "$Westonoutput" = "WL" ] || [ "$Westonoutput" = "X" ] || { Count="" [ -z "$Screensize" ] && Screensize="preferred" @@ -3443,7 +3447,7 @@ DefaultEnvironment=DISPLAY=$Newdisplay XAUTHORITY=$Cshare/Xclientcookie $(IFS=$' -v $Sharefolder:$Cshare:rw" [ "$Benutzerhosthome" = "yes" ] && [ -n "$Benutzerhosthomefolder" ] && Dockercommand="$Dockercommand \\ -v '$Benutzerhosthomefolder':'$Benutzerhome':rw" - for Count in $(seq -s' ' $Sharevolumescount) ; do + for ((Count=1 ; Count<=$Sharevolumescount ; Count++)) ; do case "${Sharevolumes[$Count]}" in "$Benutzerhome") Dockercommand="$Dockercommand \\ -v '${Sharevolumes[$Count]}':'${Sharevolumes[$Count]}/$(basename $Benutzerhome)':rw" @@ -3475,7 +3479,7 @@ DefaultEnvironment=DISPLAY=$Newdisplay XAUTHORITY=$Cshare/Xclientcookie $(IFS=$' Dockercommand="$Dockercommand \\ --device=$Line:$Line:rw \\ -v $Line:$Line:rw" - done < <(find /dev/dri /dev/nvidia* /dev/vga_arbiter -maxdepth 0 2>/dev/null) + done < <(find /dev/dri /dev/nvidia* /dev/vga_arbiter -maxdepth 0 2>/dev/null ||:) } ## options --hostipc and --hostnet @@ -3738,8 +3742,13 @@ start() { # This is the part the password prompt / $Getroot is needed for. echo "#! /bin/bash" declare -f waitforfilecreation verbose warning note escapestring - [ "$Debug" = "yes" ] && echo "set -x" - + [ "$Debug" = "yes" ] && { + echo "PS4='$DebugPS4'" + echo "set -x" + declare -f traperror | sed 's/Command/dockerrc: Command/' + echo "set -Eu" + echo "trap 'traperror \$? \$LINENO \$BASH_LINENO \"\$BASH_COMMAND\" \$(printf \"::%s\" \${FUNCNAME[@]})' ERR" + } echo "Imagename=\"$Imagename\"" echo "Imagecommand=\"$Imagecommand\"" @@ -3772,13 +3781,14 @@ start() { echo "Entrypoint=\${Entrypoint#/bin/sh -c }" echo "Entrypoint=\${Entrypoint%]}" [ "$Initsystem" != "none" ] && { - echo "echo \"\$Entrypoint\" | grep -q '/tini ' && {" - echo " note 'Found init system tini as entrypoint in image." - echo " Will disable it as x11docker already runs init with option --$Initsystem.'" + echo "echo \"\$Entrypoint\" | grep -qE '/tini|/init|/systemd' && {" + echo " note 'There seems to be an init system in ENTRYPOINT of image: \$ENTRYPOINT" + echo " Will disable it as x11docker already runs an init with option --$Initsystem." + echo " To allow this ENTRYPOINT, run x11docker with option --no-init.'" echo " Entrypoint=" echo "}" - } - } + } ||: + } || echo "Entrypoint=" echo "[ -z \"\$Imagecommand\$Entrypoint\" ] && echo 'x11docker WARNING: No image command specified and no CMD or ENTRYPOINT found in image.'|tee -a $Logfile" echo "# create x11docker.CMD.sh (shared with container and given as image command to docker run)" @@ -3815,7 +3825,7 @@ start() { echo " echo export USER=\"$Benutzer\"" [ "$Benutzerhosthome" = "no" ] && { echo " echo mkdir -p -v $Benutzerhome" - for Count in $(seq -s' ' $Sharevolumescount) ; do + for ((Count=1 ; Count<=$Sharevolumescount ; Count++)) ; do echo " echo '# create soft links of shared folders to fake home'" echo " echo 'ln -s ${Sharevolumes[$Count]} $Benutzerhome'" done @@ -3913,11 +3923,11 @@ start() { echo "docker logs -f \$Containerid >> $Dockerlogfile 2>&1 &" echo "" echo "# wait for container to be ready" - echo "for Count in $(seq -s' ' 10); do" + echo "for ((Count=1 ; Count<=10 ; Count++)); do" echo " sleep 0.2" echo " docker exec $Containername sh -c : && { echo 'x11docker: container is up and running.' ; break ; } || echo \"x11docker: container not ready on \$Count. attempt, trying again.\" " echo "done" - echo "cat $Dockerlogfile | grep 'Error response from daemon'" # repeat possible error message to make it visible in error() after verbose Count loop + echo "cat $Dockerlogfile | grep 'Error response from daemon ||:'" # repeat possible error message to make it visible in error() after verbose Count loop echo "" [ "$Initsystem" = "systemd" ] && echo "mkdir -v -p /sys/fs/cgroup/systemd # make sure this folder exists on non-systemd hosts, too" @@ -4276,20 +4286,14 @@ $(cat $Xtermrc | nl -ba)" $(cat $Xinitrc | nl -ba)" [ -s "$Westonini" ] && verbose "Created weston.ini: $(cat "$Westonini" | nl -ba)" - verbose "Logfiles are: - $Xinitlogfile - $Xpraserverlogfile - $Xpraclientlogfile - $Compositorlogfile - $Dockerlogfile -Summary logfile: $Logfile2 + verbose "Logfile: $Logfile2 In container: $Cshare/x11docker.log After finish: $Logfile3" verbose "Running X server $Xserver on display $Newdisplay now ..." # create summary logfile tail --pid=$$ --retry -n +1 -F $Dockerlogfile \ - $Cmdstdoutlogfile $Cmdstderrlogfile $Journallogfile \ + $Cmdstdoutlogfile $Cmdstderrlogfile ${Journallogfile:-} \ $Xpraserverlogfile $Xpraclientlogfile \ $Xinitlogfile $Compositorlogfile 2>/dev/null >> $Logfile & tail --pid=$$ --retry -n +1 -F $Logfile 2>/dev/null >> $Logfile2 & @@ -4622,10 +4626,10 @@ $(tail $Compositorlogfile)" ######### ToDo notes for development todo() { -# docker exec: set other environment variables, too? # work on traperror(). 'set -u' possible without a stop? -# check for other init systems in ENTRYPOINT, especially systemd -# +# --update: regard possible location in /opt +# outsource x11docker.png from x11docker-gui +# escape more option arguments: --add, custom docker options, --workdir, --user, --homedir, --sharedir, --wm, --lang, --xhost # --dbus-system: policykit must not have no-new-privileges. Seems to use setuid? Core issue AccountsService? # starting polkitd and accounts-daemon in setupscript helps: # -> cinnamon starts up with lots of (harmless?) error messages @@ -4636,13 +4640,13 @@ todo() { # BUG opensuse/arch: issues with x11docker/fluxbox, background missing, sometimes no context menu. where is the difference? # check echo especially in sh scripts, replace with printf if needed (#25) # avoid possible confusions --home --sharedir. --sharedir mounts can overlap --home folder. What about softlinks with existing target in --home? Maybe avoid /home/$USER at all -# check out possibilities to allow 'sudo docker' directly again. -# xpra restart on tty switch -> bug report # --xpra --desktop restarts client if closing desktop window # bug report to docker about --volume in --volume +# check out possibilities to allow 'sudo docker' directly again. # --lang: find out locale package names for several distris for documentation # --keymap does not work on tty with --kwin and --kwin-xwayland. No idea how to set it. +# xpra restart on tty switch -> bug report # further check of xpra server crashes with jess/atom and chromium. --mmap=no avoids the bug: xpra bug report? # BUG check whether VT is not in use with --xorg/--xpra/--xdummy, bug if accidently using vt that is already in use diff --git a/x11docker-gui b/x11docker-gui index 10de62e0..7fcad9e7 100755 --- a/x11docker-gui +++ b/x11docker-gui @@ -841,7 +841,7 @@ case $Hostkaptain in If your distribution does not provide package kaptain (>=0.73), look at kaptain repository: https://github.com/mviereck/kaptain Fallback: Will try to use image x11docker/kaptain." - read -r X11docker_command < <(x11docker --hostdisplay --no-init --gpu $Verbose --stdout --env HOME="$CONTAINERUSERHOME" -- --volume="$X11docker_kaptn":"/x11docker.kaptn":ro --volume="$X11docker_logo":"$X11docker_logo":ro --volume="$CONTAINERUSERHOME":"$CONTAINERUSERHOME":ro x11docker/kaptain "/x11docker.kaptn") + { read -r containerID ; read -r X11docker_command ;} < <(x11docker --hostdisplay --no-init --gpu $Verbose --stdout --env HOME="$CONTAINERUSERHOME" -- --volume="$X11docker_kaptn":"/x11docker.kaptn":ro --volume="$X11docker_logo":"$X11docker_logo":ro --volume="$CONTAINERUSERHOME":"$CONTAINERUSERHOME":ro x11docker/kaptain "/x11docker.kaptn") ;; esac