podman-peerjs : utilise les nouvelles fonctions
This commit is contained in:
parent
4fe1c5b94e
commit
22a022f224
|
@ -122,7 +122,7 @@ check_container_running () {
|
|||
[[ "podman container inspect -f '{{.State.Status}}' ${1}" == "running" ]]
|
||||
}
|
||||
|
||||
# ok if container exists
|
||||
# ok if container is running
|
||||
ensure_container_running () {
|
||||
if ! check_container_running ${1}; then
|
||||
echo "ERROR : container ${1} is not running"
|
||||
|
@ -132,7 +132,7 @@ ensure_container_running () {
|
|||
fi
|
||||
}
|
||||
|
||||
# ok if container does not exists
|
||||
# ok if container is not running
|
||||
ensure_container_not_running () {
|
||||
if check_container_running ${1}; then
|
||||
echo "ERROR : container ${1} is running"
|
||||
|
|
|
@ -7,9 +7,6 @@ source ${ABSDIR}/vars.sh
|
|||
ensure_pwd_is_scriptdir
|
||||
ensure_not_root
|
||||
|
||||
check_container_exists ${container_name} && {
|
||||
echo container ${container_name} alredy exists, please remove it first.
|
||||
exit 1
|
||||
}
|
||||
ensure_container_not_exists ${container_name}
|
||||
|
||||
podman run --name ${container_name} --user nobody -p ${listen_if}:${listen_port}:9000 -d ${upstream_image}:${upstream_version}
|
||||
|
|
|
@ -7,13 +7,10 @@ source ${ABSDIR}/vars.sh
|
|||
ensure_pwd_is_scriptdir
|
||||
ensure_not_root
|
||||
|
||||
check_container_exists ${container_name} || {
|
||||
echo container ${container_name} must exist in order to add it to systemd
|
||||
exit 1
|
||||
}
|
||||
ensure_container_exists ${container_name}
|
||||
|
||||
ensure_systemd_as_user_dir_exists
|
||||
podman generate systemd --name ${container_name} > ${HOME}/.config/systemd/user/${service_name}
|
||||
|
||||
podman generate systemd --name ${container_name} > ${HOME}/.config/systemd/user/${service_name}
|
||||
podman stop ${container_name}
|
||||
systemctl --user --now enable ${service_name}
|
||||
systemctl --user enable ${service_name}
|
||||
|
|
|
@ -8,31 +8,16 @@ 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
|
||||
}
|
||||
ensure_container_exists ${container_name}
|
||||
|
||||
# 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
|
||||
}
|
||||
ensure_systemd_unit_exists ${service_name}
|
||||
|
||||
# FAIL if systemd unit is running.
|
||||
check_systemd_unit_running ${service_name} && {
|
||||
echo Service ${service_name} is already running.
|
||||
exit 1
|
||||
}
|
||||
ensure_systemd_unit_not_running ${service_name}
|
||||
|
||||
# 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
|
||||
}
|
||||
ensure_container_not_running ${container_name}
|
||||
|
||||
# OK
|
||||
echo "Starting container through systemd"
|
||||
|
|
|
@ -7,21 +7,14 @@ 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
|
||||
}
|
||||
ensure_container_exists ${container_name}
|
||||
|
||||
# Check of running through systemd (as it should be)
|
||||
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
|
||||
}
|
||||
if check_systemd_unit_running ${service_name}; then
|
||||
systemctl --user stop ${service_name}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if running through podman (no systemd), stop with podman stop , then exit
|
||||
if check_container_running ${container_name}; then
|
||||
|
|
|
@ -7,14 +7,7 @@ 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
|
||||
}
|
||||
|
||||
check_systemd_unit_exists ${service_name} || {
|
||||
echo "Systemd unit ${service_name} does not exists"
|
||||
exit 1
|
||||
}
|
||||
ensure_container_exists ${container_name}
|
||||
ensure_systemd_unit_exists ${service_name}
|
||||
|
||||
systemctl --user --now disable ${service_name}
|
||||
|
|
|
@ -8,22 +8,13 @@ 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.
|
||||
exit 1
|
||||
}
|
||||
ensure_container_exists ${container_name}
|
||||
|
||||
# FAIL if systemd unit is running
|
||||
check_systemd_unit_running ${service_name} && {
|
||||
echo Systemd unit ${service_name} is running. Stop it first.
|
||||
exit 1
|
||||
}
|
||||
ensure_systemd_unit_not_running ${service_name}
|
||||
|
||||
# FAIL if container is running
|
||||
check_container_running ${container_name} || {
|
||||
echo Container ${container_name} is running. Stop it first.
|
||||
exit 1
|
||||
}
|
||||
ensure_container_not_running ${container_name}
|
||||
|
||||
rm -f ${HOME}/.config/systemd/user/${service_name}
|
||||
systemctl --user disable ${service_name}
|
||||
|
|
|
@ -7,14 +7,10 @@ source ${ABSDIR}/vars.sh
|
|||
ensure_pwd_is_scriptdir
|
||||
ensure_not_root
|
||||
|
||||
check_systemd_unit_exists ${service_name} && {
|
||||
echo "Systemd unit ${service_name} exists. Please destroy first."
|
||||
exit 1
|
||||
}
|
||||
# FAIL if systemd unit exists
|
||||
ensure_systemd_unit_not_exists ${service_name}
|
||||
|
||||
check_container_exists ${container_name} && {
|
||||
echo "Container ${container_name} exists. Please destroy first."
|
||||
exit 1
|
||||
}
|
||||
# FAIL if container exists
|
||||
ensure_container_not_exists ${container_name}
|
||||
|
||||
podman rmi "$(podman images -a -q -- ${upstream_image})"
|
||||
|
|
Loading…
Reference in a new issue