modifs.mineures sans commentaires
This commit is contained in:
parent
594033505f
commit
4bc7a65c52
|
@ -15,24 +15,23 @@ LAUNCHERPATH=.launcher.php
|
|||
# Chemin relatif des scripts PHP wrappés
|
||||
WRAPPEDPATH=
|
||||
|
||||
# Nom du service dans docker-compose.yml
|
||||
# Nom du service dans docker-compose.yml utilisé pour lancer les commandes
|
||||
COMPOSE_SERVICE=web
|
||||
|
||||
# Montages dans docker-compose.yml
|
||||
# les répertoires relatifs le sont par rapport au répertoire du projet
|
||||
COMPOSE_MOUNTS=(
|
||||
devel:/data/PROJNAME
|
||||
.:/var/www/app
|
||||
)
|
||||
|
||||
###############################################################################
|
||||
|
||||
case "${RUNPHP_MODE:-auto}" in
|
||||
auto)
|
||||
RUNPHP_MODE=
|
||||
[ -f /.dockerenv ] && RUNPHP_MODE=docker
|
||||
[ -z "$RUNPHP_MODE" -a -f /proc/self/mountinfo ] && grep -q ' /docker/' /proc/self/mountinfo && RUNPHP_MODE=docker
|
||||
[ -z "$RUNPHP_MODE" -a -f /proc/1/cgroup ] && grep -q ':/docker/' /proc/1/cgroup && RUNPHP_MODE=docker
|
||||
[ -z "$RUNPHP_MODE" ] &&
|
||||
[ -f /proc/self/mountinfo ] &&
|
||||
grep -q ' /docker/' /proc/self/mountinfo &&
|
||||
RUNPHP_MODE=docker
|
||||
[ -z "$RUNPHP_MODE" ] &&
|
||||
[ -f /proc/1/cgroup ] &&
|
||||
grep -q ':/docker/' /proc/1/cgroup &&
|
||||
RUNPHP_MODE=docker
|
||||
[ -n "$RUNPHP_MODE" ] || RUNPHP_MODE=host
|
||||
;;
|
||||
docker) RUNPHP_MODE=docker;;
|
||||
|
@ -50,7 +49,7 @@ Ce script doit être lancé en tant que lien symbolique avec un nom de la forme
|
|||
'monscript.php' et lance le script PHP du même nom situé dans le même répertoire
|
||||
avec l'utilisateur www-data"
|
||||
|
||||
if [ "$RUNPHP_MODE" == host ]; then
|
||||
if [ "$RUNPHP_MODE" == host -o "$RUNPHP_MODE" == direct ]; then
|
||||
echo "\
|
||||
----------------------------------------
|
||||
Vérification des liens..."
|
||||
|
@ -78,34 +77,28 @@ MYTRUEDIR="$(dirname -- "$MYTRUESELF")"
|
|||
PROJDIR="$(cd "$MYTRUEDIR${PROJPATH:+/$PROJPATH}"; pwd)"
|
||||
|
||||
if [ "$RUNPHP_MODE" == host ]; then
|
||||
projname="$(basename "$PROJDIR")"; projname="${projname%-app}"
|
||||
cwd="$(pwd)"
|
||||
found=
|
||||
workdir=
|
||||
for mounts in "${COMPOSE_MOUNTS[@]}"; do
|
||||
hdir="${mounts%%:*}"
|
||||
hdir="$(cd "$PROJDIR/$hdir"; pwd)"
|
||||
ddir="${mounts#*:}"
|
||||
ddir="${ddir/PROJNAME/$projname}"
|
||||
if [ "$cwd" == "$hdir" ]; then
|
||||
found=1
|
||||
workdir="$ddir"
|
||||
break
|
||||
elif [ "${cwd#$hdir/}" != "$cwd" ]; then
|
||||
found=1
|
||||
workdir="$ddir/${cwd#$hdir/}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$found" ]; then
|
||||
echo "Impossible de mapper le répertoire courant avec les montages du container"
|
||||
exit 1
|
||||
fi
|
||||
args=(
|
||||
docker compose run
|
||||
${RUNPHP_BUILD:+--build}
|
||||
--rm
|
||||
--workdir "$workdir"
|
||||
)
|
||||
cwd="$(pwd)"
|
||||
mounted=
|
||||
if [ "$PROJDIR" == "$HOME" -o "${PROJDIR#$HOME/}" != "$PROJDIR" ]; then
|
||||
# monter HOME
|
||||
args+=(-v "$HOME:$HOME")
|
||||
[ "${cwd#$HOME/}" != "$cwd" ] && mounted=1
|
||||
else
|
||||
# monter uniquement le répertoire du projet
|
||||
args+=(-v "$PROJDIR:$PROJDIR")
|
||||
[ "${cwd#$PROJDIR/}" != "$cwd" ] && mounted=1
|
||||
fi
|
||||
if [ -z "$mounted" ]; then
|
||||
echo "Impossible de mapper le répertoire courant avec les montages du container"
|
||||
exit 1
|
||||
fi
|
||||
args+=(
|
||||
--workdir "$cwd"
|
||||
"$COMPOSE_SERVICE"
|
||||
exec "$MYNAME"
|
||||
"$@"
|
||||
|
|
Loading…
Reference in New Issue