dk: support limité de podman

This commit is contained in:
Jephté Clain 2019-12-03 06:39:00 +04:00
parent 5457228b02
commit 4fdd23c8eb
1 changed files with 31 additions and 25 deletions

56
dk
View File

@ -276,7 +276,7 @@ VARIABLES de update-apps.conf
COMPOSER_ACTION COMPOSER_ACTION
vaut 'install' par défaut. Indique ce qu'il faut faire pour un projet de vaut 'install' par défaut. Indique ce qu'il faut faire pour un projet de
type 'composer' après avoir lancé les commandes de AFTER_UPDATE. Les type 'composer' après avoir lancé les commandes de AFTER_UPDATE. Les
directives supporées sont 'install', 'update' et 'none' directives supportées sont 'install', 'update' et 'none'
FONCTIONS de update-apps.conf FONCTIONS de update-apps.conf
sqlmig [DESTDIR [SRCDIR [NOFIX]]] sqlmig [DESTDIR [SRCDIR [NOFIX]]]
@ -789,7 +789,7 @@ function default_docker_build() {
for tag in "${TAGS[@]}"; do for tag in "${TAGS[@]}"; do
replace_build_args+=(-t "$NAME:$tag") replace_build_args+=(-t "$NAME:$tag")
done done
${FAKE:+qvals} docker build \ ${FAKE:+qvals} "$DOCKER" build \
${NO_CACHE:+--no-cache} \ ${NO_CACHE:+--no-cache} \
"${replace_env_args[@]}" "${env_args[@]}" \ "${replace_env_args[@]}" "${env_args[@]}" \
"${replace_build_args[@]}" "${build_args[@]}" \ "${replace_build_args[@]}" "${build_args[@]}" \
@ -829,7 +829,7 @@ function default_compose_push() {
"$@" "$@"
} }
function default_docker_push() { function default_docker_push() {
${FAKE:+qvals} docker push \ ${FAKE:+qvals} "$DOCKER" push \
"${replace_env_args[@]}" "${env_args[@]}" \ "${replace_env_args[@]}" "${env_args[@]}" \
"$@" "$@"
} }
@ -865,7 +865,7 @@ function default_compose_up() {
"${replace_user_args[@]}" "${user_args[@]}" "$@" "${replace_user_args[@]}" "${user_args[@]}" "$@"
} }
function default_docker_up() { function default_docker_up() {
${FAKE:+qvals} docker run \ ${FAKE:+qvals} "$DOCKER" run \
"${replace_env_args[@]}" "${env_args[@]}" \ "${replace_env_args[@]}" "${env_args[@]}" \
"${replace_run_args[@]}" "${run_args[@]}" \ "${replace_run_args[@]}" "${run_args[@]}" \
"$NAME" \ "$NAME" \
@ -897,7 +897,7 @@ function default_compose_stop() {
"$@" "$@"
} }
function default_docker_stop() { function default_docker_stop() {
${FAKE:+qvals} docker container stop \ ${FAKE:+qvals} "$DOCKER" container stop \
"${replace_stop_args[@]}" "${stop_args[@]}" \ "${replace_stop_args[@]}" "${stop_args[@]}" \
"$container_name" "$@" "$container_name" "$@"
} }
@ -924,7 +924,7 @@ function default_compose_logs() {
"$@" "$@"
} }
function default_docker_logs() { function default_docker_logs() {
${FAKE:+qvals} docker logs \ ${FAKE:+qvals} "$DOCKER" logs \
"${replace_logs_args[@]}" "${logs_args[@]}" \ "${replace_logs_args[@]}" "${logs_args[@]}" \
"$container_name" "$@" "$container_name" "$@"
} }
@ -954,11 +954,11 @@ function default_compose_down() {
} }
function default_docker_down() { function default_docker_down() {
estep "stop" estep "stop"
${FAKE:+qvals} docker container stop \ ${FAKE:+qvals} "$DOCKER" container stop \
"${replace_down_args[@]}" "${down_args[@]}" \ "${replace_down_args[@]}" "${down_args[@]}" \
"$container_name" "$@" "$container_name" "$@"
estep "rm" estep "rm"
${FAKE:+qvals} docker container rm \ ${FAKE:+qvals} "$DOCKER" container rm \
"${replace_rm_args[@]}" "${rm_args[@]}" \ "${replace_rm_args[@]}" "${rm_args[@]}" \
"$container_name" "$container_name"
} }
@ -986,7 +986,7 @@ function default_compose_run() {
"${replace_user_args[@]}" "${user_args[@]}" "$@" "${replace_user_args[@]}" "${user_args[@]}" "$@"
} }
function default_docker_run() { function default_docker_run() {
${FAKE:+qvals} docker run \ ${FAKE:+qvals} "$DOCKER" run \
"${replace_env_args[@]}" "${env_args[@]}" \ "${replace_env_args[@]}" "${env_args[@]}" \
"${replace_run_args[@]}" "${run_args[@]}" \ "${replace_run_args[@]}" "${run_args[@]}" \
"$NAME" \ "$NAME" \
@ -1048,7 +1048,7 @@ function default_compose_exec() {
"$@" "$@"
} }
function default_docker_exec() { function default_docker_exec() {
${FAKE:+qvals} docker container exec \ ${FAKE:+qvals} "$DOCKER" container exec \
"${replace_exec_args[@]}" "${exec_args[@]}" \ "${replace_exec_args[@]}" "${exec_args[@]}" \
"$container_name" "$@" "$container_name" "$@"
} }
@ -1069,7 +1069,7 @@ function auto_exec() {
} }
function default_docker_deploy() { function default_docker_deploy() {
${FAKE:+qvals} docker \ ${FAKE:+qvals} "$DOCKER" \
stack deploy \ stack deploy \
"${replace_deploy_args[@]}" "${deploy_args[@]}" \ "${replace_deploy_args[@]}" "${deploy_args[@]}" \
"$container_name" "$@" "$container_name" "$@"
@ -1089,7 +1089,7 @@ function auto_deploy() {
} }
function default_docker_service() { function default_docker_service() {
${FAKE:+qvals} docker service "$@" ${FAKE:+qvals} "$DOCKER" service "$@"
} }
function docker_service() { default_docker_service "$@"; } function docker_service() { default_docker_service "$@"; }
function auto_service() { function auto_service() {
@ -1137,12 +1137,12 @@ function default_compose_show_ip() {
else else
setx -a cids="${cmd[@]}" 2>/dev/null setx -a cids="${cmd[@]}" 2>/dev/null
for cid in "${cids[@]}"; do for cid in "${cids[@]}"; do
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$cid" "$DOCKER" inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$cid"
done done
fi fi
} }
function default_docker_show_ip() { function default_docker_show_ip() {
${FAKE:+qvals} docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' \ ${FAKE:+qvals} "$DOCKER" inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' \
"${replace_show_ip_args[@]}" "${show_ip_args[@]}" \ "${replace_show_ip_args[@]}" "${show_ip_args[@]}" \
"$container_name" "$@" "$container_name" "$@"
} }
@ -1180,7 +1180,7 @@ function default_compose_systemd_unit() {
setx stopcmd=qvals "$docker_compose" down setx stopcmd=qvals "$docker_compose" down
} }
function default_docker_systemd_unit() { function default_docker_systemd_unit() {
local docker="$(which docker 2>/dev/null)" local docker="$(which "$DOCKER" 2>/dev/null)"
if [ -z "$docker" ]; then if [ -z "$docker" ]; then
if [ -x /usr/bin/docker ]; then if [ -x /usr/bin/docker ]; then
docker=/usr/bin/docker docker=/usr/bin/docker
@ -1347,15 +1347,15 @@ fi
if [ -z "$dkid" ]; then if [ -z "$dkid" ]; then
estep "Création du container $container_name avec l'image $COMPOSER_IMAGE" estep "Création du container $container_name avec l'image $COMPOSER_IMAGE"
cmd=( cmd=(
docker create -it --name "${container_name}_ct" "$DOCKER" create -it --name "${container_name}_ct"
"${basecmd[@]}" "${basecmd[@]}"
"$COMPOSER_IMAGE" "$COMPOSER_IMAGE"
bash -c "$setupscript" bash -c "$setupscript"
) )
setx dkid="${cmd[@]}" || return 1 setx dkid="${cmd[@]}" || return 1
docker container start -ai "$dkid" || return 1 "$DOCKER" container start -ai "$dkid" || return 1
docker container commit "$dkid" "${container_name}_image" || return 1 "$DOCKER" container commit "$dkid" "${container_name}_image" || return 1
docker container rm "$dkid" || return 1 "$DOCKER" container rm "$dkid" || return 1
fi fi
# prendre comme image le container créé # prendre comme image le container créé
@ -1363,7 +1363,7 @@ fi
fi fi
cmd=( cmd=(
docker run -it --rm "$DOCKER" run -it --rm
"${basecmd[@]}" "${basecmd[@]}"
"$COMPOSER_IMAGE" "$COMPOSER_IMAGE"
bash -c "$runscript" bash -c "$runscript"
@ -1412,6 +1412,12 @@ function auto_composer() {
################################################################################ ################################################################################
# support limité docker / podman
if progexists docker; then DOCKER=docker
elif progexists podman; then DOCKER=podman
else DOCKER=docker
fi
DEFAULT_PROFILE=devel DEFAULT_PROFILE=devel
# pour le moment ne pas lancer composer dans un container par défaut # pour le moment ne pas lancer composer dans un container par défaut
DEFAULT_COMPOSER_IMAGE=none #docker.univ-reunion.fr/image/utils-icmycas-php-apache:d9 DEFAULT_COMPOSER_IMAGE=none #docker.univ-reunion.fr/image/utils-icmycas-php-apache:d9
@ -1697,7 +1703,7 @@ while [ $# -gt 0 ]; do
;; ;;
ps) ps)
pscmd=( pscmd=(
docker container ps -a "$DOCKER" container ps -a
--format "table {{.ID}}\t{{.Image}}\t{{.Names}}\t{{.Status}}\t{{.RunningFor}}\t{{.Ports}}" --format "table {{.ID}}\t{{.Image}}\t{{.Names}}\t{{.Status}}\t{{.RunningFor}}\t{{.Ports}}"
) )
filtercmd=(cat) filtercmd=(cat)
@ -1790,7 +1796,7 @@ NR == 1 { print; next }
echo "$all" echo "$all"
ask_yesno "Etes-vous sûr de vouloir mettre à jour ces images?" O || die ask_yesno "Etes-vous sûr de vouloir mettre à jour ces images?" O || die
for image in "${images[@]}"; do for image in "${images[@]}"; do
docker pull "$image" || die "$DOCKER" pull "$image" || die
done done
fi fi
;; ;;
@ -1827,12 +1833,12 @@ NR == 1 { print; next }
if [ ${#images[*]} -gt 0 ]; then if [ ${#images[*]} -gt 0 ]; then
echo "$all" echo "$all"
ask_yesno "Etes-vous sûr de vouloir supprimer ces images?" || die ask_yesno "Etes-vous sûr de vouloir supprimer ces images?" || die
docker image rm ${FORCE:+--force} "${images[@]}" || die "$DOCKER" image rm ${FORCE:+--force} "${images[@]}" || die
fi fi
;; ;;
X|prune) X|prune)
docker container prune -f || die "$DOCKER" container prune -f || die
docker image prune -f || die "$DOCKER" image prune -f || die
;; ;;
composer|c|ci|cu|cs) composer|c|ci|cu|cs)
build_set_options "$update_apps_mode" "$update_apps_origin" "$update_apps_branch" build_set_options "$update_apps_mode" "$update_apps_origin" "$update_apps_branch"