2022-01-28 12:23:34 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-01-28 12:55:07 +00:00
|
|
|
ABSDIR="$( dirname "$(realpath -s -- "$0")" )"
|
2022-01-28 12:23:34 +00:00
|
|
|
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
|
2022-02-12 12:11:28 +00:00
|
|
|
# Leave if pod is correctly stopped
|
2022-02-12 12:14:54 +00:00
|
|
|
if ! check_pod_running ${pod_name}; then
|
2022-02-12 12:11:28 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
2022-01-28 12:23:34 +00:00
|
|
|
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
|