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-05 21:03:22 +00:00
|
|
|
# FAIL if container does not exists.
|
|
|
|
check_container_exists ${container_name} || {
|
|
|
|
echo Container ${container_name} does not exists.
|
|
|
|
echo Please create it first with install script.
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# FAIL if systemd unit does not exists.
|
|
|
|
check_systemd_unit_exists ${service_name} || {
|
|
|
|
echo Systemd unit for this container does not exists.
|
|
|
|
echo Please create if first with enable script.
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# FAIL if systemd unit is running.
|
|
|
|
check_systemd_unit_running ${service_name} && {
|
2021-05-04 20:14:08 +00:00
|
|
|
echo Service ${service_name} is already running.
|
|
|
|
exit 1
|
2021-05-05 21:03:22 +00:00
|
|
|
}
|
2021-05-04 20:14:08 +00:00
|
|
|
|
2021-05-05 21:03:22 +00:00
|
|
|
# FAIL if container is already running - without systemd control.
|
|
|
|
check_container_running ${container_name} && {
|
|
|
|
echo Container ${container_name} is already running, but not controlled by systemd.
|
|
|
|
echo Stop it first and rerun this script.
|
|
|
|
exit 1
|
|
|
|
}
|
2021-05-04 21:01:38 +00:00
|
|
|
|
2021-05-05 21:03:22 +00:00
|
|
|
# OK
|
|
|
|
echo "Starting container through systemd"
|
2021-05-04 20:34:43 +00:00
|
|
|
systemctl --user start ${service_name}
|