From b84b381f7125677daeca203298554d96f33aa2cc Mon Sep 17 00:00:00 2001 From: Gitouche <26656-gitouche@users.noreply.framagit.org> Date: Fri, 22 Dec 2023 09:30:41 +0100 Subject: [PATCH] privatebin: ajout script 50_update --- podman-privatebin/50_update.sh | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 podman-privatebin/50_update.sh diff --git a/podman-privatebin/50_update.sh b/podman-privatebin/50_update.sh new file mode 100755 index 0000000..e148021 --- /dev/null +++ b/podman-privatebin/50_update.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +ABSDIR="$( dirname "$(realpath -s -- "$0")" )" +source ${ABSDIR}/../functions.sh +source ${ABSDIR}/vars.sh + +ensure_pwd_is_scriptdir +ensure_not_root + +ensure_container_exists ${container_name} +ensure_variables_are_defined "$envvars" + +upstream_version=${privatebin_version} +current_version=$(podman container inspect -f '{{.ImageName}}' ${container_name} | awk -F: '{print $NF}') +current_image=$(podman container inspect -f '{{.ImageName}}' ${container_name} | awk -F: '{print $1}') + +reinstall_please () { + if ! podman image exists ${privatebin_image}:${upstream_version}; then + podman image pull ${privatebin_image}:${upstream_version} || exit 1 + fi && + check_container_running ${container_name} && ./40_stop.sh + ./70_disable.sh && \ + ./80_destroy.sh && \ + ./10_install.sh && \ + ./20_enable.sh && \ + ./30_start.sh +} + +cleanup_images () { + echo "Remove ${current_version} images?" + select yn in "Yes" "No"; do + case $yn in + Yes) + podman image rm ${current_image}:${current_version} + exit 0 + ;; + No) + exit 0 + ;; + esac + done +} + +if [ ${current_version} != ${upstream_version} ]; then + if [[ "${current_version}" > "${upstream_version}" ]]; then + echo "WARNING : you are about to DOWNGRADE your installation" + fi + echo "Migrating from ${current_version} to ${upstream_version}. Proceed?" + select yn in "Yes" "No"; do + case $yn in + Yes) + reinstall_please && \ + cleanup_images + exit 0 + ;; + No) + exit 0 + ;; + esac + done +else + echo "Already using version ${privatebin_version}. Exiting." +fi