From 1f3ab1406f6e3a01a5fbabcb4a14dd2f860c1e78 Mon Sep 17 00:00:00 2001 From: Gitouche <26656-gitouche@users.noreply.framagit.org> Date: Fri, 4 Jun 2021 09:40:17 +0200 Subject: [PATCH] amelioration peerjs apres quelques tests --- functions.sh | 4 ++-- podman-peerjs/00_status.sh | 4 +++- podman-peerjs/10_install.sh | 1 + podman-peerjs/40_stop.sh | 3 ++- podman-peerjs/70_disable.sh | 8 +++++++- podman-peerjs/80_destroy.sh | 6 +++--- podman-peerjs/90_prune.sh | 9 ++++++--- 7 files changed, 24 insertions(+), 11 deletions(-) diff --git a/functions.sh b/functions.sh index 77e41e2..f67bbb0 100644 --- a/functions.sh +++ b/functions.sh @@ -60,7 +60,7 @@ ensure_systemd_unit_exists () { # ok if systemd unit file {1} does not exists ensure_systemd_unit_not_exists () { if check_systemd_unit_exists ${1}; then - echo "ERROR : systemd unit ${1} already exists!" + echo "ERROR : systemd unit ${1} exists!" exit 1 else return 0 @@ -110,7 +110,7 @@ ensure_container_exists () { # ok if container does not exists ensure_container_not_exists () { if check_container_exists ${1}; then - echo "ERROR : container ${1} already exists" + echo "ERROR : container ${1} exists" exit 1 else return 0 diff --git a/podman-peerjs/00_status.sh b/podman-peerjs/00_status.sh index f525f91..6e0f1f6 100755 --- a/podman-peerjs/00_status.sh +++ b/podman-peerjs/00_status.sh @@ -7,9 +7,11 @@ source ${ABSDIR}/vars.sh ensure_pwd_is_scriptdir ensure_not_root -echo "Checking podman images..." +echo "Podman images status..." podman images ${upstream_image} +echo echo "Checking container status..." podman ps -a | grep ${container_name} +echo echo "Checking systemd unit status..." systemctl --user status ${service_name} diff --git a/podman-peerjs/10_install.sh b/podman-peerjs/10_install.sh index 7f3d2e9..ca86461 100755 --- a/podman-peerjs/10_install.sh +++ b/podman-peerjs/10_install.sh @@ -10,3 +10,4 @@ ensure_not_root 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 stop ${container_name} diff --git a/podman-peerjs/40_stop.sh b/podman-peerjs/40_stop.sh index a7e3e33..8dc95a3 100755 --- a/podman-peerjs/40_stop.sh +++ b/podman-peerjs/40_stop.sh @@ -12,7 +12,8 @@ ensure_container_exists ${container_name} # Check of running through systemd (as it should be) if check_systemd_unit_exists ${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 diff --git a/podman-peerjs/70_disable.sh b/podman-peerjs/70_disable.sh index 3c5ee57..10db5ff 100755 --- a/podman-peerjs/70_disable.sh +++ b/podman-peerjs/70_disable.sh @@ -7,7 +7,13 @@ source ${ABSDIR}/vars.sh ensure_pwd_is_scriptdir ensure_not_root +# FAIL if container does not exists ensure_container_exists ${container_name} + +# FAIL if systemd unit does not exists 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} diff --git a/podman-peerjs/80_destroy.sh b/podman-peerjs/80_destroy.sh index 43d8664..338256f 100755 --- a/podman-peerjs/80_destroy.sh +++ b/podman-peerjs/80_destroy.sh @@ -7,15 +7,15 @@ source ${ABSDIR}/vars.sh ensure_pwd_is_scriptdir ensure_not_root +# FAIL if container is running +ensure_container_not_running ${container_name} + # FAIL if container does not exists ensure_container_exists ${container_name} # FAIL if systemd unit is running 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} systemctl --user disable ${service_name} systemctl --user daemon-reload diff --git a/podman-peerjs/90_prune.sh b/podman-peerjs/90_prune.sh index a68e5ef..e806745 100755 --- a/podman-peerjs/90_prune.sh +++ b/podman-peerjs/90_prune.sh @@ -7,10 +7,13 @@ source ${ABSDIR}/vars.sh ensure_pwd_is_scriptdir ensure_not_root -# FAIL if systemd unit exists -ensure_systemd_unit_not_exists ${service_name} +# FAIL if container is running +ensure_container_not_running ${container_name} # FAIL if container exists 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.'