- Add internet output routing option on run time execution,

- Fix application args passing.
This commit is contained in:
Arnaud G. GIBERT 2024-08-23 17:42:22 +02:00
parent 27f2328180
commit 6017327425
6 changed files with 68 additions and 14 deletions

8
.env
View File

@ -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" <arnaud@rx3.net>'
# To be difines at run time
# To be defined / overwrited at run time
USER_ID=""
APPL_HOME_DIR=""
APPL_DIR=""
APPL_NETWORK="no-internet"

View File

@ -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 <Application Dir> <Application Exec>
./run.sh [-h] [-i] <Application Dir> <Application Exec> [Args...]
Enjoy it!

View File

@ -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
------------------------------------------------------------------------------------------------------------------------------------

View File

@ -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

20
run.sh
View File

@ -1,6 +1,22 @@
#!/bin/bash
export APPL_HOME_DIR="$1"
if [[ "$1" == "-h" ]]
then
echo "usage: run.sh [-h] [-i] <Application_Dir> <Application_Exec> [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} $*

View File

@ -9,7 +9,17 @@ 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 -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!"