refactoring scripts identiques : pod stop

This commit is contained in:
Gitouche 2022-01-28 13:23:34 +01:00
parent 0b323d1735
commit 75ebe2cd66
5 changed files with 32 additions and 112 deletions

28
_podman-common/40_stop_pod.sh Executable file
View file

@ -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

View file

@ -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

1
podman-framadate/40_stop.sh Symbolic link
View file

@ -0,0 +1 @@
../_podman-common/40_stop_pod.sh

View file

@ -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

1
podman-jitsi/40_stop.sh Symbolic link
View file

@ -0,0 +1 @@
../_podman-common/40_stop_pod.sh

View file

@ -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

1
podman-matrix/40_stop.sh Symbolic link
View file

@ -0,0 +1 @@
../_podman-common/40_stop_pod.sh

View file

@ -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

1
podman-seafile/40_stop.sh Symbolic link
View file

@ -0,0 +1 @@
../_podman-common/40_stop_pod.sh