support _rundk

This commit is contained in:
Jephté Clain 2024-09-19 21:53:19 +04:00
parent 1bc0534780
commit 2adaaf5d1e
4 changed files with 25 additions and 20 deletions

View File

@ -59,6 +59,18 @@ function build_check_env() {
template_process_userfiles
if [ -n "$updated" ]; then
setx user=id -un
setx userent=getent passwd "$user"
setx userent=qval "$userent"
setx groupent=getent group "$(id -gn)"
setx groupent=qval "$groupent"
sed -i "
s/^#_RUNDK_/_RUNDK_/
s/^_RUNDK_USER=.*/_RUNDK_USER=${user//\//\\\/}/
s/^_RUNDK_USERENT=.*/_RUNDK_USERENT=${userent//\//\\\/}/
s/^_RUNDK_GROUPENT=.*/_RUNDK_GROUPENT=${groupent//\//\\\/}/
" "$PROJDIR/$BUILDENV"
enote "IMPORTANT: Veuillez faire le paramétrage en éditant le fichier $BUILDENV
${EDITOR:-nano} $BUILDENV
ENSUITE, vous pourrez relancer la commande"

View File

@ -17,3 +17,6 @@ PRIVAREG=
REGISTRY=pubdocker.univ-reunion.fr
DIST=d12
IMAGENAME=runphp
#_RUNDK_USER=user
#_RUNDK_USERENT=user:x:1000:1000:User,,,:/home/user:/bin/bash
#_RUNDK_GROUPENT=user:x:1000:

View File

@ -175,9 +175,9 @@ if [ -z "$_RUNDK_IN_DOCKER" ]; then
## Construire l'image
if [ -n "$RUNDK_NO_USE_RSLAVE" ]; then
if [ -n "$RUNPHP_NO_USE_RSLAVE" ]; then
UseRslave=
elif [ -n "$RUNDK_USE_RSLAVE" ]; then
elif [ -n "$RUNPHP_USE_RSLAVE" ]; then
UseRslave=1
elif [ -e /proc/sys/fs/binfmt_misc/WSLInterop ]; then
# pas de mount propagation sous WSL
@ -188,8 +188,8 @@ if [ -z "$_RUNDK_IN_DOCKER" ]; then
IMAGE=
if [ -z "$bootstrap" ]; then
if [ -n "$RUNDK_FORCE_BUILDENVS" ]; then
eval "Configs=($RUNDK_FORCE_BUILDENVS)"
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
for config in "${Configs[@]}"; do
source "$config" || exit 1
done
@ -225,8 +225,8 @@ if [ -z "$_RUNDK_IN_DOCKER" ]; then
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
Dist=
if [ -n "$RUNDK_FORCE_BUILDENVS" ]; then
eval "Configs=($RUNDK_FORCE_BUILDENVS)"
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
elif [ -n "$BUILDENV" -a -f "$PROJDIR/$BUILDENV" ]; then
Configs=("$PROJDIR/$BUILDENV")
elif [ -n "$BUILDENV0" -a -f "$PROJDIR/$BUILDENV0" ]; then
@ -356,7 +356,7 @@ OPTIONS
--) shift; break;;
--help)
eecho "\
runphp: construire l'image docker
runphp: lancer une commande dans docker
USAGE
$MYNAME ci|cu|composer
@ -388,20 +388,17 @@ OPTIONS
done
if [ -n "$ComposerInstall" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
# Forcer l'installation des dépendances si nécessaire
ForcedBootstrap=1
fi
fi
## Lancer la commande
uid="$(id -u)"
gid="$(id -g)"
args=(
run -it --rm
--name "runphp-$(basename -- "$1")-$$"
-e _RUNDK_IN_DOCKER=1
-e _RUNDK_UID="$uid"
-e _RUNDK_GID="$gid"
)
for arg in "${!PROXY_VARS[@]}"; do
args+=(--e "$arg=${PROXY_VARS[$arg]}")
@ -427,7 +424,7 @@ OPTIONS
args+=(-w "$(pwd)")
# lancer avec l'utilisateur courant
if [ $uid -ne 0 ]; then
if [ $(id -u) -ne 0 ]; then
# si c'est un utilisateur lambda, il faut monter les informations
# nécessaires. composer est déjà monté via $HOME
user="$(id -un)"
@ -453,13 +450,6 @@ else
############################################################################
# Lancement depuis l'intérieur du container
# Ajouter les informations utilisateur le cas échéant
if [ -n "$_RUNDK_USERENT" ]; then
grep -q "^$_RUNDK_USER:" /etc/passwd || echo "$_RUNDK_USERENT" >>/etc/passwd
fi
if [ -n "$_RUNDK_GROUPENT" ]; then
grep -q "^$_RUNDK_GROUP:" /etc/group || echo "$_RUNDK_GROUPENT" >>/etc/group
fi
if [ -n "$_RUNDK_USER" ]; then
user="$_RUNDK_USER"
export _RUNDK_USER=

View File

@ -5,7 +5,7 @@
RUNPHP=sbin/runphp
MYDIR="$(dirname -- "$0")"; MYNAME="$(basename -- "$0")"
if [ -z "$_RUNPHP_IN_DOCKER" ]; then
if [ -z "$_RUNDK_IN_DOCKER" ]; then
"$MYDIR/$RUNPHP" --bs --ue --ci || exit 1
exec "$MYDIR/$RUNPHP" "$0" "$@"
fi