dk: rendre le code overridable
This commit is contained in:
parent
aae3703558
commit
269379f3a2
118
dk
118
dk
|
@ -1231,61 +1231,32 @@ EOF
|
||||||
local_run "$HOST" "$tmpscript"
|
local_run "$HOST" "$tmpscript"
|
||||||
}
|
}
|
||||||
|
|
||||||
function auto_composer() {
|
function default_local_composer() {
|
||||||
local COMPOSER_IMAGE="$DEFAULT_COMPOSER_IMAGE"
|
# lancement direct
|
||||||
local COMPOSER_MACHINE=-u
|
case "$1" in
|
||||||
local COMPOSER_CMD=
|
rootshell|shell|rootbash|bash)
|
||||||
local COMPOSER_SETUP=
|
# ewarn parce qu'on est pas root dans ce shell contrairement à ce qui est demandé
|
||||||
[ -f .composer.conf ] && source ./.composer.conf
|
ewarn "Lancement d'un shell utilisateur"
|
||||||
# les premiers arguments peuvent service à redéfinir les variables
|
bash "$@"
|
||||||
while [ $# -gt 0 ]; do
|
;;
|
||||||
case "$1" in
|
usershell|ushell|userbash|ubash)
|
||||||
COMPOSER_IMAGE=*) setv "$1"; shift;;
|
estep "Lancement d'un shell utilisateur"
|
||||||
COMPOSER_MACHINE=*) setv "$1"; shift;;
|
bash "$@"
|
||||||
COMPOSER_CMD=*) setv "$1"; shift;;
|
;;
|
||||||
COMPOSER_SETUP=*) setv "$1"; shift;;
|
*)
|
||||||
*) break;;
|
if [ -n "$COMPOSER_CMD" ]; then :
|
||||||
esac
|
elif [ -x composer.phar ]; then COMPOSER_CMD=./composer.phar
|
||||||
done
|
elif [ -x /usr/bin/composer ]; then COMPOSER_CMD=/usr/bin/composer
|
||||||
|
else
|
||||||
if [ "$COMPOSER_IMAGE" == none ]; then
|
eerror "Impossible de trouver composer"
|
||||||
# lancement direct
|
return 1
|
||||||
case "$1" in
|
|
||||||
rootshell|shell|rootbash|bash)
|
|
||||||
# ewarn parce qu'on est pas root dans ce shell contrairement à ce qui est demandé
|
|
||||||
ewarn "Lancement d'un shell utilisateur"
|
|
||||||
bash "$@"
|
|
||||||
;;
|
|
||||||
usershell|ushell|userbash|ubash)
|
|
||||||
estep "Lancement d'un shell utilisateur"
|
|
||||||
bash "$@"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [ -n "$COMPOSER_CMD" ]; then :
|
|
||||||
elif [ -x composer.phar ]; then COMPOSER_CMD=./composer.phar
|
|
||||||
elif [ -x /usr/bin/composer ]; then COMPOSER_CMD=/usr/bin/composer
|
|
||||||
else
|
|
||||||
eerror "Impossible de trouver composer"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
"$COMPOSER_CMD" "$@"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
return $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$COMPOSER_MACHINE" -a "$DOCKER_MACHINE_NAME" != "$COMPOSER_MACHINE" ]; then
|
|
||||||
local -x DOCKER_TLS_VERIFY= DOCKER_HOST= DOCKER_CERT_PATH= DOCKER_MACHINE_NAME=
|
|
||||||
if [ "$COMPOSER_MACHINE" != -u ]; then
|
|
||||||
local env
|
|
||||||
setx env=docker-machine env "$COMPOSER_MACHINE" 2>/dev/null || {
|
|
||||||
eerror "$COMPOSER_MACHINE: une erreur s'est produite lors de la sélection du noeud avec docker-machine"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
eval "$env"
|
|
||||||
fi
|
fi
|
||||||
fi
|
"$COMPOSER_CMD" "$@"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
function default_docker_composer() {
|
||||||
|
# lancement dans un container
|
||||||
local user group projdir actualcmd args
|
local user group projdir actualcmd args
|
||||||
setx user=id -un; setx user=getent passwd "$user"
|
setx user=id -un; setx user=getent passwd "$user"
|
||||||
setx group=id -gn; setx group=getent group "$group"
|
setx group=id -gn; setx group=getent group "$group"
|
||||||
|
@ -1375,6 +1346,45 @@ fi
|
||||||
)
|
)
|
||||||
"${cmd[@]}"
|
"${cmd[@]}"
|
||||||
}
|
}
|
||||||
|
function local_composer() { default_local_composer "$@"; }
|
||||||
|
function docker_composer() { default_docker_composer "$@"; }
|
||||||
|
function auto_composer() {
|
||||||
|
local COMPOSER_IMAGE="$DEFAULT_COMPOSER_IMAGE"
|
||||||
|
local COMPOSER_MACHINE=-u
|
||||||
|
local COMPOSER_CMD=
|
||||||
|
local COMPOSER_SETUP=
|
||||||
|
[ -f .composer.conf ] && source ./.composer.conf
|
||||||
|
# les premiers arguments peuvent service à redéfinir les variables
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
COMPOSER_IMAGE=*) setv "$1"; shift;;
|
||||||
|
COMPOSER_MACHINE=*) setv "$1"; shift;;
|
||||||
|
COMPOSER_CMD=*) setv "$1"; shift;;
|
||||||
|
COMPOSER_SETUP=*) setv "$1"; shift;;
|
||||||
|
*) break;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$COMPOSER_IMAGE" == none ]; then
|
||||||
|
local_composer "$@"
|
||||||
|
|
||||||
|
else
|
||||||
|
local PREVIOUS_DOCKER_MACHINE_NAME="$DOCKER_MACHINE_NAME"
|
||||||
|
if [ -n "$COMPOSER_MACHINE" -a "$DOCKER_MACHINE_NAME" != "$COMPOSER_MACHINE" ]; then
|
||||||
|
local -x DOCKER_TLS_VERIFY= DOCKER_HOST= DOCKER_CERT_PATH= DOCKER_MACHINE_NAME=
|
||||||
|
if [ "$COMPOSER_MACHINE" != -u ]; then
|
||||||
|
local env
|
||||||
|
setx env=docker-machine env "$COMPOSER_MACHINE" 2>/dev/null || {
|
||||||
|
eerror "$COMPOSER_MACHINE: une erreur s'est produite lors de la sélection du noeud avec docker-machine"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
eval "$env"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker_composer "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue