Additionally generate thumbnails for last year on the first of Janary

This commit is contained in:
2020-01-10 11:23:02 +01:00
parent fdc532a966
commit 3605349e0f
2 changed files with 42 additions and 26 deletions

View File

@@ -6,8 +6,8 @@ shopt -s globstar
#echo "Starting Piwigo thumbnail generation" #echo "Starting Piwigo thumbnail generation"
#Remember a trailing '/' #Remember a trailing '/'
sourceDir="$1" sourceDir="$1/"
destDir="$2" destDir="$2/"
echo "Source: $sourceDir" echo "Source: $sourceDir"
echo "Dest: $destDir" echo "Dest: $destDir"

View File

@@ -5,39 +5,55 @@
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )" WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
if [ ! -s "$WDIR/config.sh" ] ; then if [ ! -s "$WDIR/config.sh" ] ; then
echo "No configuration found" echo " [E] No configuration found"
exit 1; exit 1;
fi fi
. "$WDIR/config.sh" . "$WDIR/config.sh"
myyear=$(date "+%Y") myYear=$(date "+%Y")
if [ "$1" != "" ] myMonth=$(date "+%m")
then myDay=$(date "+%d")
myyear=$1 lastYear=$(($(date +%Y)-1))
if [ ! -z $1 ] ; then
myYear="$1"
fi fi
subDir="$myyear/" # genThumbs <SUBDIR>
thumbRoot="${piwiThumbRoot}/${subDir}" genThumbs() {
photoRoot="${piwiPhotoRoot}/${subDir}" if [ -z $1 ] ; then
yearRegex='[0-9]{4}' echo " [W] No photo subdirectory provided"
return 1;
fi
if [ ! -e ${thumbRoot} ] ; then local thumbRoot="${piwiThumbRoot}/$1"
if [ -w ${piwiThumbRoot} ] && [[ "$subDir" =~ $yearRegex ]] ; then local photoRoot="${piwiPhotoRoot}/$1"
if [ ! -e ${photoRoot} ] ; then
echo " [E] Photo root ${photoRoot} not found"
exit 1;
fi
if [ ! -e ${thumbRoot} ] ; then
if [ -w ${piwiThumbRoot} ] ; then
# Thumb root of piwigo available just subdir missing # Thumb root of piwigo available just subdir missing
echo " [I] Adding missing year subdirectory $(basename $subDir) to $piwiThumbRoot" echo " [I] Adding missing subdirectory $(basename $1) to $piwiThumbRoot"
echo " Happy new year $(basename $subDir) I guess ;)"
mkdir -p "$thumbRoot" mkdir -p "$thumbRoot"
else else
echo " [E] Thumbnail root ${thumbRoot} not found" echo " [E] Thumbnail root ${thumbRoot} not found"
exit 1; exit 1;
fi fi
fi fi
if [ ! -e ${photoRoot} ] ; then $WDIR/piwigo_thumbgen.sh "${photoRoot}" "${thumbRoot}"
echo " [E] Photo root ${photoRoot} not found" }
exit 1;
fi
$WDIR/piwigo_thumbgen.sh "${photoRoot}" "${thumbRoot}" # On the first day of the year generate last year's thumbnails for the last time
if [ $myMonth -eq 1 ] && [ $myDay -eq 1 ] ; then
echo " [I] Generate $lastYear thumbnails for the last time"
echo " Happy new year $(date +%Y), I guess ;)"
genThumbs "$lastYear"
fi
genThumbs "$myYear"
$WDIR/piwirefresh.sh $WDIR/piwirefresh.sh