35 lines
926 B
Bash
Executable file
35 lines
926 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
|
|
source ${ABSDIR}/../functions.sh
|
|
source ${ABSDIR}/vars.sh
|
|
|
|
ensure_pwd_is_scriptdir
|
|
ensure_not_root
|
|
|
|
check_container_exists ${container_name} || {
|
|
echo Container ${container_name} does not exists.
|
|
exit 1
|
|
}
|
|
|
|
if check_systemd_unit_exists ${service_name}; then
|
|
# WARN if systemd unit not running, but continue.
|
|
check_systemd_unit_running ${service_name} || {
|
|
echo Service ${service_name} is not in running state.
|
|
systemctl --user status ${service_name}
|
|
}
|
|
# Stopping with systemd
|
|
systemctl --user stop ${service_name}
|
|
exit 0
|
|
}
|
|
|
|
# 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
|