amelioration peerjs apres quelques tests

This commit is contained in:
Gitouche 2021-06-04 09:40:17 +02:00
parent d3db64601b
commit 1f3ab1406f
7 changed files with 24 additions and 11 deletions

View file

@ -60,7 +60,7 @@ ensure_systemd_unit_exists () {
# ok if systemd unit file {1} does not exists # ok if systemd unit file {1} does not exists
ensure_systemd_unit_not_exists () { ensure_systemd_unit_not_exists () {
if check_systemd_unit_exists ${1}; then if check_systemd_unit_exists ${1}; then
echo "ERROR : systemd unit ${1} already exists!" echo "ERROR : systemd unit ${1} exists!"
exit 1 exit 1
else else
return 0 return 0
@ -110,7 +110,7 @@ ensure_container_exists () {
# ok if container does not exists # ok if container does not exists
ensure_container_not_exists () { ensure_container_not_exists () {
if check_container_exists ${1}; then if check_container_exists ${1}; then
echo "ERROR : container ${1} already exists" echo "ERROR : container ${1} exists"
exit 1 exit 1
else else
return 0 return 0

View file

@ -7,9 +7,11 @@ source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir ensure_pwd_is_scriptdir
ensure_not_root ensure_not_root
echo "Checking podman images..." echo "Podman images status..."
podman images ${upstream_image} podman images ${upstream_image}
echo
echo "Checking container status..." echo "Checking container status..."
podman ps -a | grep ${container_name} podman ps -a | grep ${container_name}
echo
echo "Checking systemd unit status..." echo "Checking systemd unit status..."
systemctl --user status ${service_name} systemctl --user status ${service_name}

View file

@ -10,3 +10,4 @@ ensure_not_root
ensure_container_not_exists ${container_name} ensure_container_not_exists ${container_name}
podman run --name ${container_name} --user nobody -p ${listen_if}:${listen_port}:9000 -d ${upstream_image}:${upstream_version} podman run --name ${container_name} --user nobody -p ${listen_if}:${listen_port}:9000 -d ${upstream_image}:${upstream_version}
podman stop ${container_name}

View file

@ -12,7 +12,8 @@ ensure_container_exists ${container_name}
# Check of running through systemd (as it should be) # Check of running through systemd (as it should be)
if check_systemd_unit_exists ${service_name}; then if check_systemd_unit_exists ${service_name}; then
if check_systemd_unit_running ${service_name}; then if check_systemd_unit_running ${service_name}; then
systemctl --user stop ${service_name} systemctl --user stop ${service_name} &&
Systemd service ${service_name} stopped
fi fi
fi fi

View file

@ -7,7 +7,13 @@ source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir ensure_pwd_is_scriptdir
ensure_not_root ensure_not_root
# FAIL if container does not exists
ensure_container_exists ${container_name} ensure_container_exists ${container_name}
# FAIL if systemd unit does not exists
ensure_systemd_unit_exists ${service_name} ensure_systemd_unit_exists ${service_name}
systemctl --user --now disable ${service_name} # FAIL if systemd unit is running (stop it first)
ensure_systemd_unit_not_running ${service_name}
systemctl --user disable ${service_name}

View file

@ -7,15 +7,15 @@ source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir ensure_pwd_is_scriptdir
ensure_not_root ensure_not_root
# FAIL if container is running
ensure_container_not_running ${container_name}
# FAIL if container does not exists # FAIL if container does not exists
ensure_container_exists ${container_name} ensure_container_exists ${container_name}
# FAIL if systemd unit is running # FAIL if systemd unit is running
ensure_systemd_unit_not_running ${service_name} ensure_systemd_unit_not_running ${service_name}
# FAIL if container is running
ensure_container_not_running ${container_name}
rm -f ${HOME}/.config/systemd/user/${service_name} rm -f ${HOME}/.config/systemd/user/${service_name}
systemctl --user disable ${service_name} systemctl --user disable ${service_name}
systemctl --user daemon-reload systemctl --user daemon-reload

View file

@ -7,10 +7,13 @@ source ${ABSDIR}/vars.sh
ensure_pwd_is_scriptdir ensure_pwd_is_scriptdir
ensure_not_root ensure_not_root
# FAIL if systemd unit exists # FAIL if container is running
ensure_systemd_unit_not_exists ${service_name} ensure_container_not_running ${container_name}
# FAIL if container exists # FAIL if container exists
ensure_container_not_exists ${container_name} ensure_container_not_exists ${container_name}
podman rmi "$(podman images -a -q -- ${upstream_image})" # FAIL if systemd unit exists
ensure_systemd_unit_not_exists ${service_name}
podman rmi "$(podman images -a -q -- ${upstream_image})" || echo 'No images to remove.'