From 5c0bca9d0ea6638d4c3e20455cd5f8b7461f627f Mon Sep 17 00:00:00 2001 From: Pedro Cunha Date: Thu, 7 Nov 2024 12:30:51 +0000 Subject: [PATCH 1/2] Fix shell in optimize-images script --- docs/optimize-images.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/optimize-images.md b/docs/optimize-images.md index 453553f..a85c1bb 100644 --- a/docs/optimize-images.md +++ b/docs/optimize-images.md @@ -25,7 +25,7 @@ Install Create a script, e.g. `/opt/gotify/optimize-images.sh` containing ```bash -#!/usr/bin/env sh +#!/usr/bin/env bash set -e DATA=/home/jm/src/gotify/server/data From 07bcde891f2ea0791db8fb4564f79c04d09ce374 Mon Sep 17 00:00:00 2001 From: Pedro Cunha Date: Thu, 7 Nov 2024 12:55:12 +0000 Subject: [PATCH 2/2] Fix extension detection bug in optimize-images If a filename has another dot in it, for example, "*.ls.png", it would grab "ls.png" instead of just "png". This commit fixes that. --- docs/optimize-images.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/optimize-images.md b/docs/optimize-images.md index a85c1bb..c32a617 100644 --- a/docs/optimize-images.md +++ b/docs/optimize-images.md @@ -32,7 +32,7 @@ DATA=/home/jm/src/gotify/server/data for FILE in "$DATA"/images/*; do if [ "$FILE" -nt "$DATA"/images-optimized ]; then - EXT=$(echo "${FILE#*.}"|tr '[:upper:]' '[:lower:]') + EXT=$(echo "${FILE##*.}"|tr '[:upper:]' '[:lower:]') if [ "$EXT" = png -o "$EXT" = jpg -o "$EXT" = jpeg -o "$EXT" = gif ]; then convert "$FILE" -resize "512>" "$FILE" fi