From 6017327425129789eeda25b505f2bb6318c8a3ff Mon Sep 17 00:00:00 2001 From: "Arnaud G. GIBERT" Date: Fri, 23 Aug 2024 17:42:22 +0200 Subject: [PATCH] - Add internet output routing option on run time execution, - Fix application args passing. --- .env | 8 +++++--- ReadMe.txt | 5 +++-- ReleaseNotes.txt | 9 +++++++++ compose.yaml | 23 +++++++++++++++++++---- run.sh | 20 ++++++++++++++++++-- sbin/user_add_exec | 17 ++++++++++++++--- 6 files changed, 68 insertions(+), 14 deletions(-) diff --git a/.env b/.env index 6d06e4e..b7f8243 100644 --- a/.env +++ b/.env @@ -3,9 +3,11 @@ IMG_NAME="x11-pulse-mga9" IMG_FULL_NAME="Rx3 X11 Pulse Mageia-9 Docker Image" -IMG_VERSION="1.1.0" +IMG_VERSION="1.1.1" IMG_MAINTAINER='"Arnaud G. GIBERT" ' -# To be difines at run time + +# To be defined / overwrited at run time USER_ID="" -APPL_HOME_DIR="" +APPL_DIR="" +APPL_NETWORK="no-internet" diff --git a/ReadMe.txt b/ReadMe.txt index 11c4ba4..3fe2efe 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -7,11 +7,12 @@ This is project aims to build a X11 + Pulse + Mageia-9 docker image able to run Features: - Curtently based on base-mga9:1.2.0 image, - X11 & Pulse base libraries installed, - - user_add_exec program to create on the run the user environement. + - Target user & group created on the run, + - Optional output internet routing. Usage: - ./run.sh + ./run.sh [-h] [-i] [Args...] Enjoy it! diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 9fbe2ca..cd4aca9 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,3 +1,12 @@ +------------------------------------------------------------------------------------------------------------------------------------ +X11-Pulse-Mga9 V 1.1.1 - A. GIBERT - 2024/08/23 +------------------------------------------------------------------------------------------------------------------------------------ + +- Add internet output routing option on run time execution, +- Fix application args passing. + + + ------------------------------------------------------------------------------------------------------------------------------------ X11-Pulse-Mga9 V 1.1.0 - A. GIBERT - 2024/08/23 ------------------------------------------------------------------------------------------------------------------------------------ diff --git a/compose.yaml b/compose.yaml index 50d1740..9444fa4 100644 --- a/compose.yaml +++ b/compose.yaml @@ -30,11 +30,26 @@ services: source: /run/user/${USER_ID}/pulse target: /run/user/${USER_ID}/pulse - type: bind - source: ${APPL_HOME_DIR} - target: ${APPL_HOME_DIR} + source: ${APPL_DIR} + target: ${APPL_DIR} + + networks: +# - internet +# - no-internet + - ${APPL_NETWORK} + - network_mode: bridge - volumes: home_dir: external: true + + +networks: + internet: + driver: bridge + internal: false # Allow internet access + + no-internet: + driver: bridge + internal: true # Block internet access + \ No newline at end of file diff --git a/run.sh b/run.sh index 769e954..8b3cafe 100755 --- a/run.sh +++ b/run.sh @@ -1,6 +1,22 @@ #!/bin/bash -export APPL_HOME_DIR="$1" +if [[ "$1" == "-h" ]] +then + echo "usage: run.sh [-h] [-i] [Args...]" + echo "with -i enabling internet access." + + exit 0 +fi + +if [[ "$1" == "-i" ]] +then + shift; + export APPL_NETWORK="internet" +else + export APPL_NETWORK="no-internet" +fi + +export APPL_DIR="$1" shift export APPL_NAME="$1" @@ -13,4 +29,4 @@ export GROUP_ID=$(id -g) export GROUP_NAME=$(id -gn) -docker compose run --rm default /sbin/user_add_exec ${USER_ID} ${USER} ${HOME} ${GROUP_ID} ${GROUP_NAME} ${APPL_HOME_DIR}/${APPL_NAME} $* +docker compose run --rm default /sbin/user_add_exec ${USER_ID} ${USER} ${HOME} ${GROUP_ID} ${GROUP_NAME} ${APPL_DIR}/${APPL_NAME} $* diff --git a/sbin/user_add_exec b/sbin/user_add_exec index 2bc3f2a..a498029 100755 --- a/sbin/user_add_exec +++ b/sbin/user_add_exec @@ -8,8 +8,18 @@ done -echo "User Add & Exec: User_Id: (${User_Id}) User_Name: [${User_Name}] Home_Dir: [${Home_Dir}] Group_Id: (${Group_Id}) Group_Name: [${Group_Name}]" -echo " Display: [${DISPLAY}] Cmd: [${*}]" +echo "User Add & Exec: User_Id: (${User_Id}) User_Name: [${User_Name}] Home_Dir: [${Home_Dir}] Group_Id: (${Group_Id}) Group_Name: [${Group_Name}]" +echo -n " Display: [${DISPLAY}] Cmd: [$1]" + +i=2 + +while [[ $i -le $# ]] +do + echo -n " [${!i}]" + i=$(($i + 1)) +done + +echo "" echo "" @@ -36,7 +46,8 @@ chown ${User_Name}:${Group_Name} /run/user/${User_Id} echo "Exec Cmd..." +#echo "su - -P ${User_Name} -c \"$*\"" -su - -P ${User_Name} -c $* +su - -P ${User_Name} -c "$*" echo "Completed!"