modifs.mineures sans commentaires
This commit is contained in:
parent
7e8901a7f6
commit
8b7dab9905
132
runphp/runphp
132
runphp/runphp
|
@ -70,6 +70,7 @@ if [ -f "$MYDIR/runphp.userconf.local" ]; then
|
||||||
source "$MYDIR/runphp.userconf.local"
|
source "$MYDIR/runphp.userconf.local"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
DEFAULT_DIST=d12
|
||||||
if [ -n "$RUNPHP_STANDALONE" ]; then
|
if [ -n "$RUNPHP_STANDALONE" ]; then
|
||||||
PROJDIR="$RUNPHP_PROJDIR"
|
PROJDIR="$RUNPHP_PROJDIR"
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ if [ -n "$RUNPHP_STANDALONE" ]; then
|
||||||
VENDORDIR=vendor
|
VENDORDIR=vendor
|
||||||
BUILDENV0=
|
BUILDENV0=
|
||||||
BUILDENV=
|
BUILDENV=
|
||||||
DIST="$RUNPHP_DIST"
|
DIST="${RUNPHP_DIST:-$DEFAULT_DIST}"
|
||||||
IMAGENAME=nulib/
|
IMAGENAME=nulib/
|
||||||
|
|
||||||
PRIVAREG=docker.io
|
PRIVAREG=docker.io
|
||||||
|
@ -93,7 +94,7 @@ else
|
||||||
[ -n "$VENDORDIR" ] || VENDORDIR=vendor
|
[ -n "$VENDORDIR" ] || VENDORDIR=vendor
|
||||||
[ -n "$BUILDENV0" ] || BUILDENV0=.build.env.dist
|
[ -n "$BUILDENV0" ] || BUILDENV0=.build.env.dist
|
||||||
[ -n "$BUILDENV" ] || BUILDENV=build.env
|
[ -n "$BUILDENV" ] || BUILDENV=build.env
|
||||||
[ -n "$DIST" ] || DIST=d12
|
[ -n "$DIST" ] || DIST="$DEFAULT_DIST"
|
||||||
[ -n "$IMAGENAME" ] || IMAGENAME=nulib/
|
[ -n "$IMAGENAME" ] || IMAGENAME=nulib/
|
||||||
|
|
||||||
[ "$COMPOSERPHAR" == none ] && COMPOSERPHAR=
|
[ "$COMPOSERPHAR" == none ] && COMPOSERPHAR=
|
||||||
|
@ -154,31 +155,23 @@ function check_image() {
|
||||||
[ -n "$(docker image ls --no-trunc --format '{{.Repository}}:{{.Tag}}' "$image" 2>/dev/null)" ]
|
[ -n "$(docker image ls --no-trunc --format '{{.Repository}}:{{.Tag}}' "$image" 2>/dev/null)" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap=
|
## Arguments initiaux
|
||||||
BootstrapOnly=1
|
|
||||||
ComposerInstall=
|
|
||||||
ForcedBootstrap=
|
|
||||||
parse_opts=1
|
|
||||||
args=()
|
|
||||||
for arg in "$@"; do
|
|
||||||
if [ -z "$parse_opts" ]; then
|
|
||||||
args+=("$arg")
|
|
||||||
elif [ "$arg" == --bootstrap -o "$arg" == --bs ]; then
|
|
||||||
bootstrap=1
|
|
||||||
elif [ "$arg" == --exec ]; then
|
|
||||||
BootstrapOnly=
|
|
||||||
elif [ "$arg" == --composer-install -o "$arg" == --ci ]; then
|
|
||||||
ComposerInstall=1
|
|
||||||
elif [[ "$arg" == -* ]]; then
|
|
||||||
args+=("$arg")
|
|
||||||
else
|
|
||||||
args+=("$arg")
|
|
||||||
parse_opts=
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
set -- "${args[@]}"
|
|
||||||
|
|
||||||
if [ -z "$RUNPHP_STANDALONE" -a -z "$bootstrap" ]; then
|
Bootstrap=
|
||||||
|
ComposerInstall=
|
||||||
|
if [ "$1" == --runphp-bootstrap -o "$1" == --bs ]; then
|
||||||
|
Bootstrap=1
|
||||||
|
shift
|
||||||
|
elif [ "$1" == --runphp-exec ]; then
|
||||||
|
Bootstrap=
|
||||||
|
shift
|
||||||
|
elif [ "$1" == --runphp-install -o "$1" == --ci ]; then
|
||||||
|
ComposerInstall=1
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
ForcedBootstrap=
|
||||||
|
if [ -z "$Bootstrap" -a -z "$RUNPHP_STANDALONE" ]; then
|
||||||
# si vendor/ n'existe pas, alors on doit faire bootstrap
|
# si vendor/ n'existe pas, alors on doit faire bootstrap
|
||||||
if [ ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
|
if [ ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
|
||||||
ForcedBootstrap=1
|
ForcedBootstrap=1
|
||||||
|
@ -186,27 +179,18 @@ if [ -z "$RUNPHP_STANDALONE" -a -z "$bootstrap" ]; then
|
||||||
ForcedBootstrap=1
|
ForcedBootstrap=1
|
||||||
elif ! diff -q "$PROJDIR/$COMPOSERDIR/composer.lock" "$PROJDIR/.composer.lock.runphp" >&/dev/null; then
|
elif ! diff -q "$PROJDIR/$COMPOSERDIR/composer.lock" "$PROJDIR/.composer.lock.runphp" >&/dev/null; then
|
||||||
ForcedBootstrap=1
|
ForcedBootstrap=1
|
||||||
elif [ -n "$bootstrap" -a -n "$BootstrapOnly" ]; then
|
|
||||||
# bootstrap inutile
|
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$ForcedBootstrap" ]; then
|
if [ -n "$ForcedBootstrap" ]; then
|
||||||
[ "$RUNPHP_MODE" != docker ] && eecho "== runphp is needed: bootstrapping"
|
[ "$RUNPHP_MODE" != docker ] && eecho "== bootstrapping runphp"
|
||||||
bootstrap=1
|
Bootstrap=1
|
||||||
BootstrapOnly=
|
ComposerInstall=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$RUNPHP_MODE" != docker ]; then
|
if [ "$RUNPHP_MODE" != docker ]; then
|
||||||
############################################################################
|
############################################################################
|
||||||
# Lancement depuis l'extérieur du container
|
# Lancement depuis l'extérieur du container
|
||||||
|
############################################################################
|
||||||
# recenser les valeur de proxy
|
|
||||||
declare -A PROXY_VARS
|
|
||||||
for var in {HTTPS,ALL,NO}_PROXY {http,https,all,no}_proxy; do
|
|
||||||
is_defined "$var" && PROXY_VARS[${var,,}]="${!var}"
|
|
||||||
done
|
|
||||||
|
|
||||||
## Charger ~/.dkbuild.env
|
## Charger ~/.dkbuild.env
|
||||||
|
|
||||||
|
@ -253,7 +237,6 @@ if [ "$RUNPHP_MODE" != docker ]; then
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
[ -f ~/.dkbuild.env ] && source ~/.dkbuild.env
|
[ -f ~/.dkbuild.env ] && source ~/.dkbuild.env
|
||||||
|
|
||||||
[ -n "$APT_PROXY" ] || APT_PROXY=
|
[ -n "$APT_PROXY" ] || APT_PROXY=
|
||||||
[ -n "$APT_MIRROR" ] || APT_MIRROR=default
|
[ -n "$APT_MIRROR" ] || APT_MIRROR=default
|
||||||
[ -n "$SEC_MIRROR" ] || SEC_MIRROR=default
|
[ -n "$SEC_MIRROR" ] || SEC_MIRROR=default
|
||||||
|
@ -261,6 +244,15 @@ if [ "$RUNPHP_MODE" != docker ]; then
|
||||||
[ -n "$PRIVAREG" ] || PRIVAREG=
|
[ -n "$PRIVAREG" ] || PRIVAREG=
|
||||||
[ -n "$REGISTRY" ] || REGISTRY=pubdocker.univ-reunion.fr
|
[ -n "$REGISTRY" ] || REGISTRY=pubdocker.univ-reunion.fr
|
||||||
|
|
||||||
|
## Charger la configuration
|
||||||
|
|
||||||
|
# Recenser les valeur de proxy
|
||||||
|
declare -A PROXY_VARS
|
||||||
|
for var in {HTTPS,ALL,NO}_PROXY {http,https,all,no}_proxy; do
|
||||||
|
is_defined "$var" && PROXY_VARS[${var,,}]="${!var}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Paramètres de montage
|
||||||
if [ -n "$RUNPHP_NO_USE_RSLAVE" ]; then
|
if [ -n "$RUNPHP_NO_USE_RSLAVE" ]; then
|
||||||
UseRslave=
|
UseRslave=
|
||||||
elif [ -n "$RUNPHP_USE_RSLAVE" ]; then
|
elif [ -n "$RUNPHP_USE_RSLAVE" ]; then
|
||||||
|
@ -272,8 +264,9 @@ if [ "$RUNPHP_MODE" != docker ]; then
|
||||||
UseRslave=1
|
UseRslave=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Toujours vérifier l'existence de l'image
|
||||||
IMAGE=
|
IMAGE=
|
||||||
if [ -z "$bootstrap" ]; then
|
if [ -z "$Bootstrap" ]; then
|
||||||
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
|
if [ -n "$RUNPHP_FORCE_BUILDENVS" ]; then
|
||||||
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
|
eval "Configs=($RUNPHP_FORCE_BUILDENVS)"
|
||||||
for config in "${Configs[@]}"; do
|
for config in "${Configs[@]}"; do
|
||||||
|
@ -288,11 +281,14 @@ if [ "$RUNPHP_MODE" != docker ]; then
|
||||||
after_source_buildenv
|
after_source_buildenv
|
||||||
fi
|
fi
|
||||||
ensure_image
|
ensure_image
|
||||||
check_image || bootstrap=1
|
check_image || Bootstrap=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$bootstrap" ]; then
|
Chdir=
|
||||||
|
Verbose=
|
||||||
|
if [ -n "$Bootstrap" ]; then
|
||||||
## Mode bootstrap de l'image ###########################################
|
## Mode bootstrap de l'image ###########################################
|
||||||
|
# Ici, on a déterminé que l'image doit être construite
|
||||||
|
|
||||||
BUILD_ARGS=(
|
BUILD_ARGS=(
|
||||||
DIST NDIST
|
DIST NDIST
|
||||||
|
@ -303,8 +299,8 @@ if [ "$RUNPHP_MODE" != docker ]; then
|
||||||
TIMEZONE
|
TIMEZONE
|
||||||
)
|
)
|
||||||
|
|
||||||
SOPTS=+d:9876543210:c:UjDx:z:r:pw:v
|
SOPTS=+d:9876543210:c:UjDx:z:r:p
|
||||||
LOPTS=help,dist:,d19,d18,d17,d16,d15,d14,d13,d12,d11,d10,config:,ue,unless-exists,pull,nc,no-cache,po,plain-output,apt-proxy:,timezone:,privareg:,push,chdir:,verbose,no-use-rslave
|
LOPTS=help,dist:,d19,d18,d17,d16,d15,d14,d13,d12,d11,d10,config:,ue,unless-exists,pull,nc,no-cache,po,plain-output,apt-proxy:,timezone:,privareg:,push,no-use-rslave
|
||||||
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
|
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
|
||||||
|
|
||||||
Dist=
|
Dist=
|
||||||
|
@ -321,8 +317,6 @@ if [ "$RUNPHP_MODE" != docker ]; then
|
||||||
Pull=
|
Pull=
|
||||||
NoCache=
|
NoCache=
|
||||||
PlainOutput=
|
PlainOutput=
|
||||||
Chdir=
|
|
||||||
Verbose=
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--) shift; break;;
|
--) shift; break;;
|
||||||
|
@ -331,7 +325,7 @@ if [ "$RUNPHP_MODE" != docker ]; then
|
||||||
runphp: construire l'image docker
|
runphp: construire l'image docker
|
||||||
|
|
||||||
USAGE
|
USAGE
|
||||||
$MYNAME --bootstrap [options...] [--exec command [args...]]
|
$MYNAME --bootstrap [options...]
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-c, --config build.env
|
-c, --config build.env
|
||||||
|
@ -343,11 +337,7 @@ OPTIONS
|
||||||
-z, --timezone TIMEZONE
|
-z, --timezone TIMEZONE
|
||||||
-r, --privareg PRIVAREG
|
-r, --privareg PRIVAREG
|
||||||
-p, --push
|
-p, --push
|
||||||
paramètres pour la consruction de l'image
|
paramètres pour la consruction de l'image"
|
||||||
-w, --chdir CHDIR
|
|
||||||
aller dans le répertoire spécifié avant de lancer la commande
|
|
||||||
-v, --verbose
|
|
||||||
afficher plus d'informations"
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-d|--dist) shift; Dist="$1";;
|
-d|--dist) shift; Dist="$1";;
|
||||||
|
@ -362,8 +352,6 @@ OPTIONS
|
||||||
-z|--timezone) shift; TIMEZONE="$1";;
|
-z|--timezone) shift; TIMEZONE="$1";;
|
||||||
-r|--privareg) shift; PRIVAREG="$1";;
|
-r|--privareg) shift; PRIVAREG="$1";;
|
||||||
-p|--push) Push=1;;
|
-p|--push) Push=1;;
|
||||||
-w|--chdir) shift; Chdir="$1";;
|
|
||||||
-v|--verbose) Verbose=1;;
|
|
||||||
--no-use-rslave) UseRslave=;;
|
--no-use-rslave) UseRslave=;;
|
||||||
*) die "$1: option non configurée";;
|
*) die "$1: option non configurée";;
|
||||||
esac
|
esac
|
||||||
|
@ -383,14 +371,20 @@ OPTIONS
|
||||||
after_source_buildenv
|
after_source_buildenv
|
||||||
fi
|
fi
|
||||||
[ -n "$Dist" ] && DIST="$Dist"
|
[ -n "$Dist" ] && DIST="$Dist"
|
||||||
|
|
||||||
ensure_image
|
ensure_image
|
||||||
check_image && exists=1 || exists=
|
check_image && exists=1 || exists=
|
||||||
if [ -z "$UnlessExists" -o -z "$exists" ]; then
|
if [ -z "$UnlessExists" -o -z "$exists" ]; then
|
||||||
eecho "== Building $IMAGE"
|
eecho "== Building $IMAGE"
|
||||||
|
if [ -n "$RUNPHP_STANDALONE" ]; then
|
||||||
|
DFDIR="$RUNPHP_STANDALONE"
|
||||||
|
else
|
||||||
|
DFDIR="$MYDIR"
|
||||||
|
fi
|
||||||
dockerfiles=(
|
dockerfiles=(
|
||||||
"$MYDIR/Dockerfile.runphp.local"
|
"$DFDIR/Dockerfile.runphp.local"
|
||||||
"$MYDIR/Dockerfile.runphp$BUILD_FLAVOUR"
|
"$DFDIR/Dockerfile.runphp$BUILD_FLAVOUR"
|
||||||
"$MYDIR/Dockerfile.runphp"
|
"$DFDIR/Dockerfile.runphp"
|
||||||
)
|
)
|
||||||
for dockerfile in "${dockerfiles[@]}"; do
|
for dockerfile in "${dockerfiles[@]}"; do
|
||||||
[ -f "$dockerfile" ] && break
|
[ -f "$dockerfile" ] && break
|
||||||
|
@ -419,21 +413,20 @@ OPTIONS
|
||||||
docker push "$IMAGE" || exit 1
|
docker push "$IMAGE" || exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -n "$ComposerInstall" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
|
if [ -z "$RUNPHP_STANDALONE" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
|
||||||
BootstrapOnly=
|
# Forcer l'installation des dépendances si nécessaire
|
||||||
ForcedBootstrap=1
|
ComposerInstall=1
|
||||||
fi
|
fi
|
||||||
[ -n "$BootstrapOnly" ] && exit 0
|
[ -z "$ComposerInstall" ] && exit 0
|
||||||
|
|
||||||
else
|
else
|
||||||
## Mode exécution de commande ##########################################
|
## Mode exécution de commande ##########################################
|
||||||
|
# Ici, on a déterminé qu'il faut lancer une commande
|
||||||
|
|
||||||
SOPTS=+w:v
|
SOPTS=+w:v
|
||||||
LOPTS=help,chdir:,verbose,no-use-rslave
|
LOPTS=help,chdir:,verbose,no-use-rslave
|
||||||
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
|
args="$(getopt -n "$MYNAME" -o "$SOPTS" -l "$LOPTS" -- "$@")" || exit 1; eval "set -- $args"
|
||||||
|
|
||||||
Chdir=
|
|
||||||
Verbose=
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--) shift; break;;
|
--) shift; break;;
|
||||||
|
@ -470,9 +463,9 @@ OPTIONS
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$ComposerInstall" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
|
if [ -z "$RUNPHP_STANDALONE" -a ! -f "$PROJDIR/$VENDORDIR/nulib/php/load.sh" ]; then
|
||||||
# Forcer l'installation des dépendances si nécessaire
|
# Forcer l'installation des dépendances si nécessaire
|
||||||
ForcedBootstrap=1
|
ComposerInstall=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -527,6 +520,7 @@ OPTIONS
|
||||||
else
|
else
|
||||||
############################################################################
|
############################################################################
|
||||||
# Lancement depuis l'intérieur du container
|
# Lancement depuis l'intérieur du container
|
||||||
|
############################################################################
|
||||||
|
|
||||||
if [ -n "$DEVUSER_USERENT" ]; then
|
if [ -n "$DEVUSER_USERENT" ]; then
|
||||||
user="${DEVUSER_USERENT%%:*}"
|
user="${DEVUSER_USERENT%%:*}"
|
||||||
|
@ -554,7 +548,9 @@ else
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$1" == ci ]; then
|
if [ -z "$1" ]; then
|
||||||
|
die "no command specified"
|
||||||
|
elif [ "$1" == ci ]; then
|
||||||
eecho "== installing composer dependencies"
|
eecho "== installing composer dependencies"
|
||||||
composer i
|
composer i
|
||||||
elif [ "$1" == cu ]; then
|
elif [ "$1" == cu ]; then
|
||||||
|
@ -566,6 +562,6 @@ else
|
||||||
if [ -n "$chdir" ]; then
|
if [ -n "$chdir" ]; then
|
||||||
cd "$chdir" || exit 1
|
cd "$chdir" || exit 1
|
||||||
fi
|
fi
|
||||||
exec "${@:-bash}"
|
exec "$@"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue