From 37b1b287435aaf210cbb68cee6df182de2ee3e7c Mon Sep 17 00:00:00 2001 From: Gitouche <26656-gitouche@users.noreply.framagit.org> Date: Fri, 18 Nov 2022 11:02:43 +0100 Subject: [PATCH] ntfy : tous les scripts --- podman-ntfy/.gitlab-ci.yml | 10 ++++++++++ podman-ntfy/10_install.sh | 21 +++++++++++++++++++++ podman-ntfy/20_enable.sh | 1 + podman-ntfy/30_start.sh | 1 + podman-ntfy/40_stop.sh | 1 + podman-ntfy/70_disable.sh | 1 + podman-ntfy/80_destroy.sh | 1 + podman-ntfy/90_prune.sh | 1 + podman-ntfy/config/server.yml | 12 ++++++++++++ podman-ntfy/vars.sh | 5 +++-- 10 files changed, 52 insertions(+), 2 deletions(-) create mode 100755 podman-ntfy/10_install.sh create mode 120000 podman-ntfy/20_enable.sh create mode 120000 podman-ntfy/30_start.sh create mode 120000 podman-ntfy/40_stop.sh create mode 120000 podman-ntfy/70_disable.sh create mode 120000 podman-ntfy/80_destroy.sh create mode 120000 podman-ntfy/90_prune.sh create mode 100644 podman-ntfy/config/server.yml diff --git a/podman-ntfy/.gitlab-ci.yml b/podman-ntfy/.gitlab-ci.yml index 1018c40..127bca2 100644 --- a/podman-ntfy/.gitlab-ci.yml +++ b/podman-ntfy/.gitlab-ci.yml @@ -1,10 +1,20 @@ # Si besoin d'executer le before_script manuellement : # sed -n 's/^ - \(.*\)$/\1/p' .gitlab-ci.yml | bash +before_script: + - podman container exists podman-ntfy && podman container rm --force podman-ntfy + - rm -f ~/.config/systemd/user/container-podman-ntfy.service && systemctl --user daemon-reload + ntfy: stage: test script: - cd podman-ntfy - ./ci_build-images.sh + - GARBAYE_NTFY_ENV_LISTENIF='18099' GARBAYE_NTFY_BASE_URL='http://notif.garbaye.fr' ./10_install.sh + - ./20_enable.sh + - ./30_start.sh && sleep 10 + - ./40_stop.sh + - ./70_disable.sh + - ./80_destroy.sh tags: - garbaye - compute diff --git a/podman-ntfy/10_install.sh b/podman-ntfy/10_install.sh new file mode 100755 index 0000000..f35f52e --- /dev/null +++ b/podman-ntfy/10_install.sh @@ -0,0 +1,21 @@ +#!/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_not_exists ${container_name} +ensure_variables_are_defined "$envvars" + +if ! podman image exists ${ntfy_image}:${ntfy_version}; then + podman image pull ${ntfy_image}:${ntfy_version} || exit 1 +fi + +podman run --name ${container_name} -p ${listen_if}:${listen_port}:8080 -d ${ntfy_image}:${ntfy_version} serve --listen-http :8080 --base-url ${GARBAYE_NTFY_BASE_URL} && +podman cp config/server.yml ${container_name}:/etc/ntfy/server.yml && +sleep 10 && +podman stop ${container_name} && +echo Container ${container_name} successfully built and stopped. diff --git a/podman-ntfy/20_enable.sh b/podman-ntfy/20_enable.sh new file mode 120000 index 0000000..62674d2 --- /dev/null +++ b/podman-ntfy/20_enable.sh @@ -0,0 +1 @@ +../_podman-common/20_enable_container.sh \ No newline at end of file diff --git a/podman-ntfy/30_start.sh b/podman-ntfy/30_start.sh new file mode 120000 index 0000000..784face --- /dev/null +++ b/podman-ntfy/30_start.sh @@ -0,0 +1 @@ +../_podman-common/30_start_container.sh \ No newline at end of file diff --git a/podman-ntfy/40_stop.sh b/podman-ntfy/40_stop.sh new file mode 120000 index 0000000..3d0c193 --- /dev/null +++ b/podman-ntfy/40_stop.sh @@ -0,0 +1 @@ +../_podman-common/40_stop_container.sh \ No newline at end of file diff --git a/podman-ntfy/70_disable.sh b/podman-ntfy/70_disable.sh new file mode 120000 index 0000000..83e4e91 --- /dev/null +++ b/podman-ntfy/70_disable.sh @@ -0,0 +1 @@ +../_podman-common/70_disable_container.sh \ No newline at end of file diff --git a/podman-ntfy/80_destroy.sh b/podman-ntfy/80_destroy.sh new file mode 120000 index 0000000..97efd57 --- /dev/null +++ b/podman-ntfy/80_destroy.sh @@ -0,0 +1 @@ +../_podman-common/80_destroy_container.sh \ No newline at end of file diff --git a/podman-ntfy/90_prune.sh b/podman-ntfy/90_prune.sh new file mode 120000 index 0000000..9c9670b --- /dev/null +++ b/podman-ntfy/90_prune.sh @@ -0,0 +1 @@ +../_podman-common/90_prune_container.sh \ No newline at end of file diff --git a/podman-ntfy/config/server.yml b/podman-ntfy/config/server.yml new file mode 100644 index 0000000..c13507d --- /dev/null +++ b/podman-ntfy/config/server.yml @@ -0,0 +1,12 @@ +# ntfy server config file +# +cache-file: /var/cache/ntfy/cache.db + +cache-startup-queries: | + pragma journal_mode = WAL; + pragma synchronous = normal; + pragma temp_store = memory; + pragma busy_timeout = 15000; + vacuum; + +behind-proxy: true diff --git a/podman-ntfy/vars.sh b/podman-ntfy/vars.sh index 8c62232..27f0989 100644 --- a/podman-ntfy/vars.sh +++ b/podman-ntfy/vars.sh @@ -3,11 +3,12 @@ ntfy_image="git.garbaye.fr/garbaye/ntfy" ntfy_version='v1.29.0' ## default vars : override with ENV var +listen_if="${GARBAYE_NTFY_ENV_LISTENIF:-127.0.0.1}" +listen_port="${GARBAYE_NTFY_ENV_LISTENPORT:-8099}" ## mandatory ENV vars +envvars='GARBAYE_NTFY_BASE_URL' ## internal vars : do not touch project_name=${PWD##*/} container_name="${project_name}" service_name="container-${container_name}.service" -cachevolume='podman-ntfy_cache' -container_name='ntfy'