1
0
Fork 0

Add desktop mode to contain script
continuous-integration/drone/push Build was killed Details

main
Ambrose Chua 2021-05-04 16:56:14 +08:00
parent ce6048486e
commit 97c4cd444b
1 changed files with 20 additions and 2 deletions

View File

@ -92,7 +92,7 @@ caps=""
show_help() { show_help() {
cat << EOF cat << EOF
Usage: ${0##*/} [-xwo] [-n NAME] [-p PORT]... [-v LIST]... [-i IMAGE] [-t TAG] [-c CAP]... [CMD]... Usage: ${0##*/} [-xwod] [-n NAME] [-p PORT]... [-v LIST]... [-i IMAGE] [-t TAG] [-c CAP]... [CMD]...
${0##*/} -l ${0##*/} -l
${0##*/} -a NAME ${0##*/} -a NAME
${0##*/} -e NAME [CMD]... ${0##*/} -e NAME [CMD]...
@ -102,6 +102,7 @@ Starts an environment container. If CMD is specified, starts CMD instead of a sh
-x delete Docker container after exit. will loose data -x delete Docker container after exit. will loose data
-w forward \$PWD into $CONTAIN_HOME/src, and start there -w forward \$PWD into $CONTAIN_HOME/src, and start there
-o use host networking instead -o use host networking instead
-d desktop, forward wayland and xwayland
-n NAME give container a NAME -n NAME give container a NAME
-p PORT forward host PORT to container PORT -p PORT forward host PORT to container PORT
-v LIST mount volume LIST. specify as LOCAL:MOUNT -v LIST mount volume LIST. specify as LOCAL:MOUNT
@ -129,7 +130,7 @@ pull_image() {
$image:$tag $image:$tag
} }
while getopts "xwon:p:v:c:i:t:lua:e:h" opt; do while getopts "xwodn:p:v:c:i:t:lua:e:h" opt; do
case "$opt" in case "$opt" in
x) x)
delete="--rm " delete="--rm "
@ -145,6 +146,22 @@ while getopts "xwon:p:v:c:i:t:lua:e:h" opt; do
o) o)
host="--net host " host="--net host "
;; ;;
d)
desktop=""
if $selinux_enabled; then
desktop="$desktop--security-opt label=disable "
fi
desktop="$desktop--env DISPLAY "
desktop="$desktop--env WAYLAND_DISPLAY "
desktop="$desktop--env QT_QPA_PLATFORM=wayland "
desktop="$desktop--env XDG_SESSION_TYPE "
desktop="$desktop--env XDG_SESSION_DESKTOP "
desktop="$desktop--env XDG_RUNTIME_DIR=/tmp "
desktop="$desktop--volume \"$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY\" "
desktop="$desktop--volume \"/tmp/.X11-unix:/tmp/.X11-unix\" "
desktop="$desktop--device /dev/dri "
desktop="$desktop--device /dev/snd "
;;
n) n)
name="--name $OPTARG --hostname $OPTARG " name="--name $OPTARG --hostname $OPTARG "
;; ;;
@ -232,6 +249,7 @@ $runtime run --interactive --tty \
$ports$host\ $ports$host\
$workdir$volumes\ $workdir$volumes\
$caps\ $caps\
$desktop\
$image:$tag\ $image:$tag\
$@ \ $@ \
" "