#!/bin/bash # Get script working directory # (when called from a different directory) WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )" if [ ! -s "$WDIR/config.sh" ] ; then echo " [E] No configuration found" exit 1; fi . "$WDIR/config.sh" myYear=$(date "+%Y") myMonth=$(date "+%m") myDay=$(date "+%d") lastYear=$(($(date +%Y)-1)) if [ ! -z $1 ] ; then myYear="$1" fi # genThumbs genThumbs() { if [ -z $1 ] ; then echo " [W] No photo subdirectory provided" return 1; fi local thumbRoot="${piwiThumbRoot}/$1" 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 echo " [I] Adding missing subdirectory $(basename $1) to $piwiThumbRoot" mkdir -p "$thumbRoot" else echo " [E] Thumbnail root ${thumbRoot} not found" exit 1; fi 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