Scripts: Add shellcheck annotations and fix reported issues

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-10-07 22:32:31 +02:00
parent ab60112f99
commit 87b540b438
23 changed files with 53 additions and 32 deletions

View File

@@ -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/')

View File

@@ -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

View File

@@ -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

View File

@@ -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."
echo "Done."

View File

@@ -22,6 +22,7 @@ DESTARCH=${BUILD_ARCH:-$SYSTEM_ARCH}
set -e
# shellcheck source=/dev/null
. /etc/os-release
echo "Installing Darktable for ${DESTARCH^^}..."

View File

@@ -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."
echo "Done."

View File

@@ -46,6 +46,7 @@ case $DESTARCH in
;;
esac
# shellcheck source=/dev/null
. /etc/os-release
echo "Installing FFmpeg..."

View File

@@ -24,6 +24,7 @@ DESTARCH=${BUILD_ARCH:-$SYSTEM_ARCH}
TMPDIR=${TMPDIR:-/tmp}
# shellcheck source=/dev/null
. /etc/os-release
apt-get update

View File

@@ -25,6 +25,7 @@ SYSTEM_ARCH=$("$(dirname "$0")/arch.sh")
set -e
# shellcheck source=/dev/null
. /etc/os-release
case $DESTARCH in

View File

@@ -45,6 +45,7 @@ case $DESTARCH in
;;
esac
# shellcheck source=/dev/null
. /etc/os-release
# Abort if not executed as root.

View File

@@ -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."
echo "Done."

View File

@@ -42,6 +42,7 @@ case $DESTARCH in
;;
esac
# shellcheck source=/dev/null
. /etc/os-release
# Abort if not executed as root.

View File

@@ -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."
echo "Done."

View File

@@ -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

View File

@@ -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."
echo "Done."

View File

@@ -38,6 +38,7 @@ case $DESTARCH in
;;
esac
# shellcheck source=/dev/null
. /etc/os-release
# Abort if not executed as root.

View File

@@ -31,6 +31,7 @@ else
SYSTEM_ARCH=$(uname -m)
fi
# shellcheck source=/dev/null
. /etc/os-release
S6_OVERLAY_ARCH=${BUILD_ARCH:-$SYSTEM_ARCH}

View File

@@ -47,6 +47,7 @@ case $DESTARCH in
;;
esac
# shellcheck source=/dev/null
. /etc/os-release
# Abort if not executed as root.

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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."
echo "Done."