diff --git a/_podman-common/00_status_container.sh b/_podman-common/00_status_container.sh index 4af5828..1ba4c12 100755 --- a/_podman-common/00_status_container.sh +++ b/_podman-common/00_status_container.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash ABSDIR="$( dirname "$(realpath -s -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh +source "${ABSDIR}"/../functions.sh +source "${ABSDIR}"/vars.sh ensure_pwd_is_scriptdir ensure_not_root diff --git a/_podman-common/00_status_pod.sh b/_podman-common/00_status_pod.sh index 21920d1..58258f4 100755 --- a/_podman-common/00_status_pod.sh +++ b/_podman-common/00_status_pod.sh @@ -1,19 +1,19 @@ #!/usr/bin/env bash ABSDIR="$( dirname "$(realpath -s -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh +source "${ABSDIR}"/../functions.sh +source "${ABSDIR}"/vars.sh ensure_pwd_is_scriptdir ensure_not_root echo "Podman images status..." for image in ${upstream_images} ; do - podman image list ${image} | grep ${image} || echo Image ${image} not found. + podman image list "${image}" | grep "${image}" || echo Image "${image}" not found. done echo echo "Checking pod status..." -podman pod ps | grep ${pod_name} || echo Pod ${pod_name} not found. +podman pod ps | grep "${pod_name}" || echo Pod "${pod_name}" not found. echo echo "Checking systemd unit status..." -systemctl --user status ${service_name} +systemctl --user status "${service_name}" diff --git a/_podman-common/20_enable_container.sh b/_podman-common/20_enable_container.sh index 9242d0e..f6a1105 100755 --- a/_podman-common/20_enable_container.sh +++ b/_podman-common/20_enable_container.sh @@ -1,21 +1,21 @@ #!/usr/bin/env bash ABSDIR="$( dirname "$(realpath -s -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh +source "${ABSDIR}"/../functions.sh +source "${ABSDIR}"/vars.sh ensure_pwd_is_scriptdir ensure_not_root # container should exist -ensure_container_exists ${container_name} +ensure_container_exists "${container_name}" # container should NOT be running. Installation script must have stopped it. -ensure_container_not_running ${container_name} +ensure_container_not_running "${container_name}" ensure_systemd_as_user_dir_exists -podman generate systemd --stop-timeout=30 --files --name ${container_name} -mv *.service ~/.config/systemd/user/ +podman generate systemd --stop-timeout=30 --files --name "${container_name}" +mv -- *.service ~/.config/systemd/user/ systemctl --user daemon-reload -systemctl --user enable ${service_name} +systemctl --user enable "${service_name}" diff --git a/_podman-common/20_enable_pod.sh b/_podman-common/20_enable_pod.sh index b3acd45..495dc18 100755 --- a/_podman-common/20_enable_pod.sh +++ b/_podman-common/20_enable_pod.sh @@ -1,21 +1,21 @@ #!/usr/bin/env bash ABSDIR="$( dirname "$(realpath -s -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh +source "${ABSDIR}"/../functions.sh +source "${ABSDIR}"/vars.sh ensure_pwd_is_scriptdir ensure_not_root # pod should exist -ensure_pod_exists ${pod_name} +ensure_pod_exists "${pod_name}" # pod should NOT be running. Installation script must have stopped it. -ensure_pod_not_running ${pod_name} +ensure_pod_not_running "${pod_name}" ensure_systemd_as_user_dir_exists -podman generate systemd --stop-timeout=30 --files --name ${pod_name} -mv *.service ~/.config/systemd/user/ +podman generate systemd --stop-timeout=30 --files --name "${pod_name}" +mv -- *.service ~/.config/systemd/user/ systemctl --user daemon-reload -systemctl --user enable ${service_name} +systemctl --user enable "${service_name}" diff --git a/_podman-common/30_start_container.sh b/_podman-common/30_start_container.sh index 16f2608..d7fe95c 100755 --- a/_podman-common/30_start_container.sh +++ b/_podman-common/30_start_container.sh @@ -1,24 +1,24 @@ #!/usr/bin/env bash ABSDIR="$( dirname "$(realpath -s -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh +source "${ABSDIR}"/../functions.sh +source "${ABSDIR}"/vars.sh ensure_pwd_is_scriptdir 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}" # FAIL if systemd unit is running. -ensure_systemd_unit_not_running ${service_name} +ensure_systemd_unit_not_running "${service_name}" # FAIL if container is already running - without systemd control. -ensure_container_not_running ${container_name} +ensure_container_not_running "${container_name}" # OK echo "Starting container through systemd" -systemctl --user start ${service_name} +systemctl --user start "${service_name}" diff --git a/_podman-common/40_stop_container.sh b/_podman-common/40_stop_container.sh index 8fc2a7a..d071736 100755 --- a/_podman-common/40_stop_container.sh +++ b/_podman-common/40_stop_container.sh @@ -1,32 +1,32 @@ #!/usr/bin/env bash ABSDIR="$( dirname "$(realpath -s -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh +source "${ABSDIR}"/../functions.sh +source "${ABSDIR}"/vars.sh ensure_pwd_is_scriptdir ensure_not_root -ensure_container_exists ${container_name} +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} && - echo Systemd service ${service_name} stopped. +if check_systemd_unit_exists "${service_name}"; then + if check_systemd_unit_running "${service_name}"; then + systemctl --user stop "${service_name}" && + echo Systemd service "${service_name}" stopped. fi # Leave if container is correctly stopped - if ! check_container_running ${container_name}; then + if ! check_container_running "${container_name}"; then exit 0 fi fi # Check if running through podman (no systemd), stop with podman container stop , then exit -if check_container_running ${container_name}; then +if check_container_running "${container_name}"; then echo Container found running without systemd unit, stopping it now. - podman container stop ${container_name} + podman container stop "${container_name}" exit 0 else - echo Container ${container_name} is not running. + echo Container "${container_name}" is not running. exit 1 fi diff --git a/_podman-common/70_disable_container.sh b/_podman-common/70_disable_container.sh index 6a3793f..ac739f8 100755 --- a/_podman-common/70_disable_container.sh +++ b/_podman-common/70_disable_container.sh @@ -1,19 +1,19 @@ #!/usr/bin/env bash ABSDIR="$( dirname "$(realpath -s -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh +source "${ABSDIR}"/../functions.sh +source "${ABSDIR}"/vars.sh ensure_pwd_is_scriptdir 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}" # FAIL if systemd unit is running (stop it first) -ensure_systemd_unit_not_running ${service_name} +ensure_systemd_unit_not_running "${service_name}" -systemctl --user disable ${service_name} +systemctl --user disable "${service_name}" diff --git a/_podman-common/80_destroy_container.sh b/_podman-common/80_destroy_container.sh index bc2b57c..83a34b8 100755 --- a/_podman-common/80_destroy_container.sh +++ b/_podman-common/80_destroy_container.sh @@ -1,24 +1,24 @@ #!/usr/bin/env bash ABSDIR="$( dirname "$(realpath -s -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh +source "${ABSDIR}"/../functions.sh +source "${ABSDIR}"/vars.sh ensure_pwd_is_scriptdir ensure_not_root # FAIL if container does not exists -ensure_container_exists ${container_name} +ensure_container_exists "${container_name}" # FAIL if container is running -ensure_container_not_running ${container_name} +ensure_container_not_running "${container_name}" -${ABSDIR}/70_disable.sh +"${ABSDIR}"/70_disable.sh -rm -f ${HOME}/.config/systemd/user/${service_name} +rm -f "${HOME}/.config/systemd/user/${service_name}" systemctl --user daemon-reload -podman container rm ${container_name} +podman container rm "${container_name}" for volume in ${nonpersistent_volumes}; do - podman volume rm ${volume} + podman volume rm "${volume}" done diff --git a/_podman-common/90_prune_container.sh b/_podman-common/90_prune_container.sh index f47947e..5738419 100755 --- a/_podman-common/90_prune_container.sh +++ b/_podman-common/90_prune_container.sh @@ -1,22 +1,22 @@ #!/usr/bin/env bash ABSDIR="$( dirname "$(realpath -s -- "$0")" )" -source ${ABSDIR}/../functions.sh -source ${ABSDIR}/vars.sh +source "${ABSDIR}"/../functions.sh +source "${ABSDIR}"/vars.sh ensure_pwd_is_scriptdir ensure_not_root # FAIL if container is running -ensure_container_not_running ${container_name} +ensure_container_not_running "${container_name}" # FAIL if container exists -ensure_container_not_exists ${container_name} +ensure_container_not_exists "${container_name}" # FAIL if systemd unit exists -ensure_systemd_unit_not_exists ${service_name} +ensure_systemd_unit_not_exists "${service_name}" # remove images for image in ${upstream_images} ; do - podman image rm -f $(podman image list -a -q -- ${image}) || echo Image ${image} not found. + podman image rm -f "$(podman image list -a -q -- ${image})" || echo Image "${image}" not found. done