From f2f1de7af2495a978576dc7f045636522b7f3e98 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 1 Aug 2025 12:54:41 -0600 Subject: [PATCH] setup_container_runtime.sh: Fix shellcheck msgs Signed-off-by: Zack Cerza --- scripts/setup_container_runtime.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/setup_container_runtime.sh b/scripts/setup_container_runtime.sh index 313504d7..9b4184d6 100755 --- a/scripts/setup_container_runtime.sh +++ b/scripts/setup_container_runtime.sh @@ -2,8 +2,8 @@ # vim: ts=4 sw=4 expandtab function setup_container_runtime () { if command -v podman; then - if ! [ -d /run/user/$(id -u) -a -w /run/user/$(id -u) ]; then - sudo loginctl enable-linger $(id -nu) + if ! [ -d "/run/user/$(id -u)" ] && [ -w "/run/user/$(id -u)" ]; then + sudo loginctl enable-linger "$(id -nu)" fi PODMAN_MAJOR_VERSION=$(podman version -f json | jq -r '.Client.Version|split(".")[0]') if [ "$PODMAN_MAJOR_VERSION" -lt 4 ]; then @@ -31,11 +31,11 @@ function setup_container_runtime () { PODMAN_MAJOR_VERSION=$(podman version -f json | jq -r '.Client.Version|split(".")[0]') if [ "$PODMAN_MAJOR_VERSION" -ge 4 ]; then PODMAN_DIR="$HOME/.local/share/containers" - test -d $PODMAN_DIR && command -v restorecon && sudo restorecon -R -T0 -x $PODMAN_DIR + test -d "$PODMAN_DIR" && command -v restorecon && sudo restorecon -R -T0 -x "$PODMAN_DIR" PODMAN_STORAGE_DIR="$PODMAN_DIR/storage" - if [ -d $PODMAN_STORAGE_DIR ]; then - sudo chgrp -R $(groups | cut -d' ' -f1) $PODMAN_STORAGE_DIR - if [ $(podman unshare du -s --block-size=1G $PODMAN_STORAGE_DIR | awk '{print $1}') -ge 50 ]; then + if [ -d "$PODMAN_STORAGE_DIR" ]; then + sudo chgrp -R "$(groups | cut -d' ' -f1)" "$PODMAN_STORAGE_DIR" + if [ "$(podman unshare du -s --block-size=1G "$PODMAN_STORAGE_DIR" | awk '{print $1}')" -ge 50 ]; then time podman image prune --filter=until="$((24*7))h" --all --force time podman system prune --force test "$PODMAN_MAJOR_VERSION" -ge 5 && time podman system check --repair --quick @@ -46,6 +46,6 @@ function setup_container_runtime () { } # If the script is executed (as opposed to sourced), run the function now -if [ "$(basename -- "${0#-}")" = "$(basename -- "${BASH_SOURCE}")" ]; then +if [ "$(basename -- "${0#-}")" = "$(basename -- "${BASH_SOURCE[0]}")" ]; then setup_container_runtime fi -- 2.39.5