Files
piwigo_scan/piwisync.sh

44 lines
1.0 KiB
Bash
Executable File

#!/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 "No configuration found"
exit 1;
fi
. "$WDIR/config.sh"
myyear=$(date "+%Y")
if [ "$1" != "" ]
then
myyear=$1
fi
subDir="$myyear/"
thumbRoot="${piwiThumbRoot}/${subDir}"
photoRoot="${piwiPhotoRoot}/${subDir}"
yearRegex='[0-9]{4}'
if [ ! -e ${thumbRoot} ] ; then
if [ -w ${piwiThumbRoot} ] && [[ "$subDir" =~ $yearRegex ]] ; then
# Thumb root of piwigo available just subdir missing
echo " [I] Adding missing year subdirectory $(basename $subDir) to $piwiThumbRoot"
echo " Happy new year $(basename $subDir) I guess ;)"
mkdir -p "$thumbRoot"
else
echo " [E] Thumbnail root ${thumbRoot} not found"
exit 1;
fi
fi
if [ ! -e ${photoRoot} ] ; then
echo " [E] Photo root ${photoRoot} not found"
exit 1;
fi
$WDIR/piwigo_thumbgen.sh "${photoRoot}" "${thumbRoot}"
$WDIR/piwirefresh.sh