services-garbaye/podman-peerjs/30_start.sh
2021-05-05 23:03:22 +02:00

40 lines
1 KiB
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
# 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} && {
echo Service ${service_name} is already running.
exit 1
}
# 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
}
# OK
echo "Starting container through systemd"
systemctl --user start ${service_name}