From 87b540b438c60b1d7a3c06d6a17e3b4eb847fc31 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Tue, 7 Oct 2025 22:32:31 +0200 Subject: [PATCH] Scripts: Add shellcheck annotations and fix reported issues Signed-off-by: Michael Mayer --- scripts/dist/build-libheif.sh | 1 + scripts/dist/create-users.sh | 2 +- scripts/dist/entrypoint.sh | 3 ++- scripts/dist/install-chrome.sh | 3 ++- scripts/dist/install-darktable.sh | 1 + scripts/dist/install-dircolors.sh | 4 ++-- scripts/dist/install-ffmpeg.sh | 1 + scripts/dist/install-gpu.sh | 1 + scripts/dist/install-jxl.sh | 1 + scripts/dist/install-libheif.sh | 1 + scripts/dist/install-mariadb.sh | 13 +++++++------ scripts/dist/install-nats.sh | 1 + scripts/dist/install-nodejs.sh | 3 ++- scripts/dist/install-onnx.sh | 2 +- scripts/dist/install-postgresql.sh | 13 +++++++------ scripts/dist/install-qdrant.sh | 1 + scripts/dist/install-s6.sh | 1 + scripts/dist/install-yt-dlp.sh | 1 + scripts/docker/build.sh | 2 ++ scripts/docker/buildx-multi.sh | 2 ++ scripts/docker/buildx.sh | 2 ++ scripts/docker/push.sh | 2 ++ scripts/render/svg-icon.sh | 24 +++++++++++------------- 23 files changed, 53 insertions(+), 32 deletions(-) diff --git a/scripts/dist/build-libheif.sh b/scripts/dist/build-libheif.sh index 08d017878..94e6b1bb4 100755 --- a/scripts/dist/build-libheif.sh +++ b/scripts/dist/build-libheif.sh @@ -43,6 +43,7 @@ case $DESTARCH in ;; esac +# shellcheck source=/dev/null . /etc/os-release LATEST=$(curl --silent "https://api.github.com/repos/strukturag/libheif/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') diff --git a/scripts/dist/create-users.sh b/scripts/dist/create-users.sh index 6971ae3ee..af215f2f6 100755 --- a/scripts/dist/create-users.sh +++ b/scripts/dist/create-users.sh @@ -3,7 +3,7 @@ PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" # Abort if not executed as root. -if [ $(id -u) != "0" ]; then +if [ "$(id -u)" != "0" ]; then echo "Usage: run ${0##*/} as root" 1>&2 exit 1 fi diff --git a/scripts/dist/entrypoint.sh b/scripts/dist/entrypoint.sh index 2b1ad80ac..a33a7767a 100755 --- a/scripts/dist/entrypoint.sh +++ b/scripts/dist/entrypoint.sh @@ -120,5 +120,6 @@ fi PID=$! -trap "kill -USR1 $PID" INT TERM +# shellcheck disable=SC2064 # expand PID now so the trap targets the correct process id +trap "kill -USR1 ${PID}" INT TERM wait diff --git a/scripts/dist/install-chrome.sh b/scripts/dist/install-chrome.sh index 22b039150..4e8b9fa48 100755 --- a/scripts/dist/install-chrome.sh +++ b/scripts/dist/install-chrome.sh @@ -20,6 +20,7 @@ fi DESTARCH=${BUILD_ARCH:-$SYSTEM_ARCH} +# shellcheck source=/dev/null . /etc/os-release case $DESTARCH in @@ -38,4 +39,4 @@ case $DESTARCH in ;; esac -echo "Done." \ No newline at end of file +echo "Done." diff --git a/scripts/dist/install-darktable.sh b/scripts/dist/install-darktable.sh index 6899f5698..0dfc09f41 100755 --- a/scripts/dist/install-darktable.sh +++ b/scripts/dist/install-darktable.sh @@ -22,6 +22,7 @@ DESTARCH=${BUILD_ARCH:-$SYSTEM_ARCH} set -e +# shellcheck source=/dev/null . /etc/os-release echo "Installing Darktable for ${DESTARCH^^}..." diff --git a/scripts/dist/install-dircolors.sh b/scripts/dist/install-dircolors.sh index 213581b12..3485a2cea 100755 --- a/scripts/dist/install-dircolors.sh +++ b/scripts/dist/install-dircolors.sh @@ -302,9 +302,9 @@ chmod 644 /etc/dir_colors if ! grep -q 'export SHELL=/bin/bash' /etc/skel/.bashrc; then echo 'export SHELL=/bin/bash' >> /etc/skel/.bashrc fi +# shellcheck disable=SC2016 if ! grep -q 'eval "$(dircolors /etc/dir_colors)"' /etc/skel/.bashrc; then - # shellcheck disable=SC2016 echo 'eval "$(dircolors /etc/dir_colors)"' >> /etc/skel/.bashrc fi -echo "Done." \ No newline at end of file +echo "Done." diff --git a/scripts/dist/install-ffmpeg.sh b/scripts/dist/install-ffmpeg.sh index 01ba29c68..01fcdaff7 100755 --- a/scripts/dist/install-ffmpeg.sh +++ b/scripts/dist/install-ffmpeg.sh @@ -46,6 +46,7 @@ case $DESTARCH in ;; esac +# shellcheck source=/dev/null . /etc/os-release echo "Installing FFmpeg..." diff --git a/scripts/dist/install-gpu.sh b/scripts/dist/install-gpu.sh index 98a950fbb..c4b531b8f 100755 --- a/scripts/dist/install-gpu.sh +++ b/scripts/dist/install-gpu.sh @@ -24,6 +24,7 @@ DESTARCH=${BUILD_ARCH:-$SYSTEM_ARCH} TMPDIR=${TMPDIR:-/tmp} +# shellcheck source=/dev/null . /etc/os-release apt-get update diff --git a/scripts/dist/install-jxl.sh b/scripts/dist/install-jxl.sh index 10470722e..0f7557bed 100755 --- a/scripts/dist/install-jxl.sh +++ b/scripts/dist/install-jxl.sh @@ -25,6 +25,7 @@ SYSTEM_ARCH=$("$(dirname "$0")/arch.sh") set -e +# shellcheck source=/dev/null . /etc/os-release case $DESTARCH in diff --git a/scripts/dist/install-libheif.sh b/scripts/dist/install-libheif.sh index 77fe86bf2..6da2dfe98 100755 --- a/scripts/dist/install-libheif.sh +++ b/scripts/dist/install-libheif.sh @@ -45,6 +45,7 @@ case $DESTARCH in ;; esac +# shellcheck source=/dev/null . /etc/os-release # Abort if not executed as root. diff --git a/scripts/dist/install-mariadb.sh b/scripts/dist/install-mariadb.sh index e369be719..4f94a8189 100755 --- a/scripts/dist/install-mariadb.sh +++ b/scripts/dist/install-mariadb.sh @@ -5,14 +5,15 @@ PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" -if [[ -z $1 ]]; then - PACKAGES="mariadb-client" +if [[ $# -eq 0 ]]; then + PACKAGES=("mariadb-client") else - PACKAGES=$1 + PACKAGES=("$@") fi set -e +# shellcheck source=/dev/null . /etc/os-release # Determine target architecture. @@ -24,9 +25,9 @@ fi DESTARCH=${BUILD_ARCH:-$SYSTEM_ARCH} -echo "Installing \"$PACKAGES\" distribution packages for ${DESTARCH^^}..." +echo "Installing \"${PACKAGES[*]}\" distribution packages for ${DESTARCH^^}..." sudo apt-get update -sudo apt-get -qq install $PACKAGES +sudo apt-get -qq install "${PACKAGES[@]}" -echo "Done." \ No newline at end of file +echo "Done." diff --git a/scripts/dist/install-nats.sh b/scripts/dist/install-nats.sh index 8ce0085ff..ca0297785 100755 --- a/scripts/dist/install-nats.sh +++ b/scripts/dist/install-nats.sh @@ -42,6 +42,7 @@ case $DESTARCH in ;; esac +# shellcheck source=/dev/null . /etc/os-release # Abort if not executed as root. diff --git a/scripts/dist/install-nodejs.sh b/scripts/dist/install-nodejs.sh index 0f1d64c48..68c019dfb 100755 --- a/scripts/dist/install-nodejs.sh +++ b/scripts/dist/install-nodejs.sh @@ -7,6 +7,7 @@ PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PAT set -e +# shellcheck source=/dev/null . /etc/os-release # NodeJS version to be installed. @@ -56,4 +57,4 @@ sudo npm install -g --ignore-scripts --no-fund --no-audit --no-update-notifier e eslint-plugin-vue eslint-plugin-vuetify eslint-webpack-plugin echo "Installing Vue Language Server..." sudo npm install -g --ignore-scripts --no-fund --no-audit --no-update-notifier @vue/language-server -echo "Done." \ No newline at end of file +echo "Done." diff --git a/scripts/dist/install-onnx.sh b/scripts/dist/install-onnx.sh index ff5aba867..222f520ae 100755 --- a/scripts/dist/install-onnx.sh +++ b/scripts/dist/install-onnx.sh @@ -15,7 +15,7 @@ fi DESTDIR=$(realpath "${DESTDIR_ARG}") -if [[ $(id -u) != 0 ]] && ([[ "${DESTDIR}" == "/usr" ]] || [[ "${DESTDIR}" == "/usr/local" ]]); then +if [[ $(id -u) != 0 ]] && { [[ "${DESTDIR}" == "/usr" ]] || [[ "${DESTDIR}" == "/usr/local" ]]; }; then echo "Error: Run ${0##*/} as root to install in '${DESTDIR}'." >&2 exit 1 fi diff --git a/scripts/dist/install-postgresql.sh b/scripts/dist/install-postgresql.sh index df21ea4c4..1b30ae3f0 100755 --- a/scripts/dist/install-postgresql.sh +++ b/scripts/dist/install-postgresql.sh @@ -5,14 +5,15 @@ PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" -if [[ -z $1 ]]; then - PACKAGES="postgresql-client" +if [[ $# -eq 0 ]]; then + PACKAGES=("postgresql-client") else - PACKAGES=$1 + PACKAGES=("$@") fi set -e +# shellcheck source=/dev/null . /etc/os-release # Determine target architecture. @@ -24,11 +25,11 @@ fi DESTARCH=${BUILD_ARCH:-$SYSTEM_ARCH} -echo "Installing \"$PACKAGES\" distribution packages for ${DESTARCH^^}..." +echo "Installing \"${PACKAGES[*]}\" distribution packages for ${DESTARCH^^}..." sudo apt-get update sudo apt-get -qy install curl gnupg postgresql-common apt-transport-https lsb-release sudo sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y -sudo apt-get -qq install $PACKAGES +sudo apt-get -qq install "${PACKAGES[@]}" -echo "Done." \ No newline at end of file +echo "Done." diff --git a/scripts/dist/install-qdrant.sh b/scripts/dist/install-qdrant.sh index e28c5e3d6..3eec3f6c1 100755 --- a/scripts/dist/install-qdrant.sh +++ b/scripts/dist/install-qdrant.sh @@ -38,6 +38,7 @@ case $DESTARCH in ;; esac +# shellcheck source=/dev/null . /etc/os-release # Abort if not executed as root. diff --git a/scripts/dist/install-s6.sh b/scripts/dist/install-s6.sh index 05ee9a87d..62a271dbb 100755 --- a/scripts/dist/install-s6.sh +++ b/scripts/dist/install-s6.sh @@ -31,6 +31,7 @@ else SYSTEM_ARCH=$(uname -m) fi +# shellcheck source=/dev/null . /etc/os-release S6_OVERLAY_ARCH=${BUILD_ARCH:-$SYSTEM_ARCH} diff --git a/scripts/dist/install-yt-dlp.sh b/scripts/dist/install-yt-dlp.sh index 1238827ac..20f848cbc 100755 --- a/scripts/dist/install-yt-dlp.sh +++ b/scripts/dist/install-yt-dlp.sh @@ -47,6 +47,7 @@ case $DESTARCH in ;; esac +# shellcheck source=/dev/null . /etc/os-release # Abort if not executed as root. diff --git a/scripts/docker/build.sh b/scripts/docker/build.sh index 0369cda60..2034d7d82 100755 --- a/scripts/docker/build.sh +++ b/scripts/docker/build.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# shellcheck disable=SC2086 # intentional word splitting for dynamic docker args + set -e # see https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds diff --git a/scripts/docker/buildx-multi.sh b/scripts/docker/buildx-multi.sh index 1d5f1ac52..eab99c8a8 100755 --- a/scripts/docker/buildx-multi.sh +++ b/scripts/docker/buildx-multi.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# shellcheck disable=SC2086 # intentional word splitting for dynamic docker args + # https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds export DOCKER_BUILDKIT=1 diff --git a/scripts/docker/buildx.sh b/scripts/docker/buildx.sh index 73e0ff41f..6a0e065d4 100755 --- a/scripts/docker/buildx.sh +++ b/scripts/docker/buildx.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# shellcheck disable=SC2086 # intentional word splitting for dynamic docker args + # https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds export DOCKER_BUILDKIT=1 diff --git a/scripts/docker/push.sh b/scripts/docker/push.sh index edcf48b49..d4d2f3ef9 100755 --- a/scripts/docker/push.sh +++ b/scripts/docker/push.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# shellcheck disable=SC2086 # intentional word splitting for dynamic docker args + set -e if [[ -z $DOCKER_PASSWORD ]] || [[ -z $DOCKER_USERNAME ]]; then diff --git a/scripts/render/svg-icon.sh b/scripts/render/svg-icon.sh index 8a3349551..e79c83158 100755 --- a/scripts/render/svg-icon.sh +++ b/scripts/render/svg-icon.sh @@ -12,21 +12,20 @@ sizes=(16 20 29 32 40 48 50 55 56 60 64 72 76 80 100 114 120 128 144 152 160 167 if [[ -z $2 ]]; then # Check if source file exists. - if [ -f "assets/static/icons/$1.svg" ]; then - echo "Creating icons from assets/static/icons/$1.svg..." + if [ -f "assets/static/icons/${1}.svg" ]; then + echo "Creating icons from assets/static/icons/${1}.svg..." else - echo "assets/static/icons/$1.svg not found" + echo "assets/static/icons/${1}.svg not found" exit 1 fi # Create dest folder. - mkdir -p "assets/static/icons/$1" + mkdir -p "assets/static/icons/${1}" # Create icons in all sizes. - for i in "${sizes[@]}" - do - rsvg-convert -a -w $i -h $i "assets/static/icons/$1.svg" > "assets/static/icons/$1/$i.png" - echo "assets/static/icons/$1/$i.png" + for i in "${sizes[@]}"; do + rsvg-convert -a -w "$i" -h "$i" "assets/static/icons/${1}.svg" > "assets/static/icons/${1}/$i.png" + echo "assets/static/icons/${1}/$i.png" done else # Check if source file exists. @@ -41,11 +40,10 @@ else mkdir -p "$2" # Create icons in all sizes. - for i in "${sizes[@]}" - do - rsvg-convert -a -w $i -h $i $1 > "$2/$i.png" - echo "$2/$i.png" + for i in "${sizes[@]}"; do + rsvg-convert -a -w "$i" -h "$i" "$1" > "$2/$i.png" + echo "$2/$i.png" done fi -echo "Done." \ No newline at end of file +echo "Done."