@@ -425,7 +425,18 @@ if [[ ${ZWIFT_OVERRIDE_GRAPHICS} -eq 1 ]]; then
425425 zwift_graphics_config=" ${zwift_user_graphics_config} "
426426 # Create graphics.txt file if it does not exist.
427427 elif [[ ! -f ${zwift_graphics_config} ]]; then
428- echo -e " res 1920x1080(0x)\nsres 2048x2048\nset gSSAO=1\nset gFXAA=1\nset gSunRays=1\nset gHeadlight=1\nset gFoliagePercent=1.0\nset gSimpleReflections=0\nset gLODBias=0\nset gShowFPS=0" > " ${zwift_graphics_config} "
428+ {
429+ echo " res 1920x1080(0x)"
430+ echo " sres 2048x2048"
431+ echo " set gSSAO=1"
432+ echo " set gFXAA=1"
433+ echo " set gSunRays=1"
434+ echo " set gHeadlight=1"
435+ echo " set gFoliagePercent=1.0"
436+ echo " set gSimpleReflections=0"
437+ echo " set gLODBias=0"
438+ echo " set gShowFPS=0"
439+ } > " ${zwift_graphics_config} "
429440 msgbox warning " Created ${zwift_graphics_config} with default values, edit this file to tweak the zwift graphics settings" 0
430441 fi
431442
@@ -461,27 +472,22 @@ else
461472 container_args+=(-d)
462473fi
463474
464- # Setup container security flags
465475# Detect if SELinux is actively enforcing
466- _selinux_enforcing () {
467- local enforce_file=/sys/fs/selinux/enforce
468- if [[ -f ${enforce_file} ]]; then
469- [[ $( < " ${enforce_file} " ) == " 1" ]]
470- else
471- return 1
472- fi
476+ is_selinux_active () {
477+ local enforcing
478+ command_exists getenforce && enforcing=" $( getenforce) " && [[ ${enforcing} == " Enforcing" ]]
473479}
474480
475481# Setup container security flags
476- if [[ ${PRIVILEGED_CONTAINER:- 0 } -eq 1 ]]; then
477- # Explicit opt-in to privileged mode
478- container_args+=(--privileged --security-opt label=disable) # privileged container, less secure
479- elif _selinux_enforcing ; then
480- # SELinux is active, use label-based security
481- container_args+=(--security-opt label=type:container_runtime_t) # more secure
482+ if [[ ${PRIVILEGED_CONTAINER} -eq 1 ]]; then
483+ msgbox warning " PRIVILEGED_CONTAINER is set, running container in privileged mode"
484+ container_args+=(--privileged --security-opt label=disable)
485+ elif is_selinux_active ; then
486+ msgbox info " SELinux is active, using secure container flags "
487+ container_args+=(--security-opt label=type:container_runtime_t)
482488else
483- # Not SELinux (e.g. AppArmor/none), default to privileged for GPU compatibility
484- container_args+=(--privileged --security-opt label=disable) # privileged container, less secure
489+ msgbox warning " Not using SELinux, running container in privileged mode to be able to access the GPU "
490+ container_args+=(--privileged --security-opt label=disable)
485491fi
486492
487493# Append extra arguments provided by user
670676declare -a container_command
671677container_command=(" ${CONTAINER_TOOL} " run " ${container_args[@]} " " ${IMAGE} :${VERSION} " " ${entrypoint_args[@]} " )
672678
673- # DRYRUN: print the exact command that would be executed, then exit
674- if [[ ${DRYRUN} -eq 1 ]]; then
675- msgbox ok " DRYRUN:"
676- msgbox ok " environment variables (${container_env_file} ):"
679+ # Print the exact command that would be executed
680+
681+ print_container_command () {
682+ local msg_type=" ${1:? } "
683+
684+ msgbox " ${msg_type} " " environment variables (${container_env_file} ):"
677685 for env_var in " ${container_env_vars[@]} " ; do
678686 env_var=" ${env_var// \\ / \\\\ } " # escape backslashes
679687 env_var=" ${env_var// ZWIFT_USERNAME=*/ ZWIFT_USERNAME=ππππππ} " # redact username
680688 env_var=" ${env_var// ZWIFT_PASSWORD=*/ ZWIFT_PASSWORD=ππππππ} " # redact password
681- msgbox ok " β’ ${env_var} "
689+ msgbox " ${msg_type} " " β’ ${env_var} "
682690 done
683- msgbox ok " ${CONTAINER_TOOL} command:"
684- msgbox ok " $( printf ' %q ' " ${container_command[@]} " ) "
691+ msgbox " ${msg_type} " " ${CONTAINER_TOOL} command:"
692+ msgbox " ${msg_type} " " $( printf ' %q ' " ${container_command[@]} " ) "
693+ }
694+
695+ if [[ ${DRYRUN} -eq 1 ]]; then
696+ msgbox ok " DRYRUN:"
697+ print_container_command ok
685698 exit 0
699+ else
700+ msgbox debug " Starting ${CONTAINER_TOOL} container with the following arguments:"
701+ print_container_command debug
686702fi
687703
688704# Create a volume if not already exists, this is done now as
0 commit comments