From 75ebe2cd66bfdf4bde2776fca94b3ad01654775f Mon Sep 17 00:00:00 2001 From: Gitouche <26656-gitouche@users.noreply.framagit.org> Date: Fri, 28 Jan 2022 13:23:34 +0100 Subject: [PATCH] refactoring scripts identiques : pod stop --- _podman-common/40_stop_pod.sh | 28 ++++++++++++++++++++++++++++ podman-framadate/40_stop.sh | 29 +---------------------------- podman-jitsi/40_stop.sh | 29 +---------------------------- podman-matrix/40_stop.sh | 29 +---------------------------- podman-seafile/40_stop.sh | 29 +---------------------------- 5 files changed, 32 insertions(+), 112 deletions(-) create mode 100755 _podman-common/40_stop_pod.sh mode change 100755 => 120000 podman-framadate/40_stop.sh mode change 100755 => 120000 podman-jitsi/40_stop.sh mode change 100755 => 120000 podman-matrix/40_stop.sh mode change 100755 => 120000 podman-seafile/40_stop.sh diff --git a/_podman-common/40_stop_pod.sh b/_podman-common/40_stop_pod.sh new file mode 100755 index 0000000..5c29c2a --- /dev/null +++ b/_podman-common/40_stop_pod.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +ABSDIR="$( dirname "$(readlink -f -- "$0")" )" +source ${ABSDIR}/../functions.sh +source ${ABSDIR}/vars.sh + +ensure_pwd_is_scriptdir +ensure_not_root + +ensure_pod_exists ${pod_name} + +# Check of running through systemd (as it should be) +if check_systemd_unit_exists ${service_name}; then + if check_systemd_unit_running ${service_name}; then + systemctl --user stop ${service_name} && + echo Systemd service ${service_name} stopped. + fi +fi + +# Check if running through podman (no systemd), stop with podman stop , then exit +if check_pod_running ${pod_name}; then + echo Pod found running without systemd unit, stopping it now. + podman pod stop ${pod_name} + exit 0 +else + echo Pod ${pod_name} is not running. + exit 1 +fi diff --git a/podman-framadate/40_stop.sh b/podman-framadate/40_stop.sh deleted file mode 100755 index 2aa4184..0000000 --- a/podman-framadate/40_stop.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -ABSDIR="$( dirname "$(readlink -f -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh - -ensure_pwd_is_scriptdir -ensure_not_root - -ensure_pod_exists ${pod_name} - -# Check of running through systemd (as it should be) -if check_systemd_unit_exists ${service_name}; then - if check_systemd_unit_running ${service_name}; then - systemctl --user stop ${service_name} && - echo Systemd service ${service_name} stopped. - fi -fi - -# Check if running through podman (no systemd), stop with podman stop , then exit -if check_pod_running ${pod_name}; then - echo Pod found running without systemd unit, stopping it now. - podman pod stop ${pod_name} - exit 0 -else - echo Pod ${pod_name} is not running. - exit 1 -fi diff --git a/podman-framadate/40_stop.sh b/podman-framadate/40_stop.sh new file mode 120000 index 0000000..7e51cf5 --- /dev/null +++ b/podman-framadate/40_stop.sh @@ -0,0 +1 @@ +../_podman-common/40_stop_pod.sh \ No newline at end of file diff --git a/podman-jitsi/40_stop.sh b/podman-jitsi/40_stop.sh deleted file mode 100755 index 5c29c2a..0000000 --- a/podman-jitsi/40_stop.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -ABSDIR="$( dirname "$(readlink -f -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh - -ensure_pwd_is_scriptdir -ensure_not_root - -ensure_pod_exists ${pod_name} - -# Check of running through systemd (as it should be) -if check_systemd_unit_exists ${service_name}; then - if check_systemd_unit_running ${service_name}; then - systemctl --user stop ${service_name} && - echo Systemd service ${service_name} stopped. - fi -fi - -# Check if running through podman (no systemd), stop with podman stop , then exit -if check_pod_running ${pod_name}; then - echo Pod found running without systemd unit, stopping it now. - podman pod stop ${pod_name} - exit 0 -else - echo Pod ${pod_name} is not running. - exit 1 -fi diff --git a/podman-jitsi/40_stop.sh b/podman-jitsi/40_stop.sh new file mode 120000 index 0000000..7e51cf5 --- /dev/null +++ b/podman-jitsi/40_stop.sh @@ -0,0 +1 @@ +../_podman-common/40_stop_pod.sh \ No newline at end of file diff --git a/podman-matrix/40_stop.sh b/podman-matrix/40_stop.sh deleted file mode 100755 index 5c29c2a..0000000 --- a/podman-matrix/40_stop.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -ABSDIR="$( dirname "$(readlink -f -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh - -ensure_pwd_is_scriptdir -ensure_not_root - -ensure_pod_exists ${pod_name} - -# Check of running through systemd (as it should be) -if check_systemd_unit_exists ${service_name}; then - if check_systemd_unit_running ${service_name}; then - systemctl --user stop ${service_name} && - echo Systemd service ${service_name} stopped. - fi -fi - -# Check if running through podman (no systemd), stop with podman stop , then exit -if check_pod_running ${pod_name}; then - echo Pod found running without systemd unit, stopping it now. - podman pod stop ${pod_name} - exit 0 -else - echo Pod ${pod_name} is not running. - exit 1 -fi diff --git a/podman-matrix/40_stop.sh b/podman-matrix/40_stop.sh new file mode 120000 index 0000000..7e51cf5 --- /dev/null +++ b/podman-matrix/40_stop.sh @@ -0,0 +1 @@ +../_podman-common/40_stop_pod.sh \ No newline at end of file diff --git a/podman-seafile/40_stop.sh b/podman-seafile/40_stop.sh deleted file mode 100755 index 5c29c2a..0000000 --- a/podman-seafile/40_stop.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -ABSDIR="$( dirname "$(readlink -f -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh - -ensure_pwd_is_scriptdir -ensure_not_root - -ensure_pod_exists ${pod_name} - -# Check of running through systemd (as it should be) -if check_systemd_unit_exists ${service_name}; then - if check_systemd_unit_running ${service_name}; then - systemctl --user stop ${service_name} && - echo Systemd service ${service_name} stopped. - fi -fi - -# Check if running through podman (no systemd), stop with podman stop , then exit -if check_pod_running ${pod_name}; then - echo Pod found running without systemd unit, stopping it now. - podman pod stop ${pod_name} - exit 0 -else - echo Pod ${pod_name} is not running. - exit 1 -fi diff --git a/podman-seafile/40_stop.sh b/podman-seafile/40_stop.sh new file mode 120000 index 0000000..7e51cf5 --- /dev/null +++ b/podman-seafile/40_stop.sh @@ -0,0 +1 @@ +../_podman-common/40_stop_pod.sh \ No newline at end of file