2021-05-04 20:14:08 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
|
|
|
|
source ${ABSDIR}/../functions.sh
|
|
|
|
source ${ABSDIR}/vars.sh
|
|
|
|
|
|
|
|
ensure_pwd_is_scriptdir
|
|
|
|
ensure_not_root
|
|
|
|
|
2021-05-18 20:54:58 +00:00
|
|
|
ensure_container_exists ${container_name}
|
2021-05-04 20:14:08 +00:00
|
|
|
|
2021-05-18 20:54:58 +00:00
|
|
|
# Check of running through systemd (as it should be)
|
2021-05-05 21:03:22 +00:00
|
|
|
if check_systemd_unit_exists ${service_name}; then
|
2021-05-18 20:54:58 +00:00
|
|
|
if check_systemd_unit_running ${service_name}; then
|
2021-06-04 07:40:17 +00:00
|
|
|
systemctl --user stop ${service_name} &&
|
2021-06-04 08:13:57 +00:00
|
|
|
echo Systemd service ${service_name} stopped
|
2021-05-18 20:54:58 +00:00
|
|
|
fi
|
|
|
|
fi
|
2021-05-04 21:01:38 +00:00
|
|
|
|
2021-05-05 21:03:22 +00:00
|
|
|
# Check if running through podman (no systemd), stop with podman stop , then exit
|
|
|
|
if check_container_running ${container_name}; then
|
|
|
|
echo Container found running without systemd unit, stopping it now.
|
|
|
|
podman stop ${container_name}
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo Container ${container_name} is not running
|
|
|
|
exit 1
|
|
|
|
fi
|