Files
piwigo_scan/piwirefresh.sh
2019-05-24 16:56:43 +02:00

71 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# syncronise piwigo database
# piwirefresh.sh [OPTION] [CATEGORY] [RECURSIVE]
# OPTION
# --meta_all|-m : including already synchronised photos
# CATEGORY
# number != 0 : limit scan to only one category
# find number in dev tools on piwigos' site_update site
# RECURSIVE
# 0 or 1 : wheter to scan CATEGORY recursively
# 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"
STARTTIME=$(date +%s)
# -s : file exists and has a size greater than zero
if [ ! -s "$piwiMountedCheckFile" ] ; then
echo "[refresh] Network not available (exists: $piwiMountedCheckFile)"
exit 1;
fi
# check if the file is really readable and contains text
mounted=$(cat "$piwiMountedCheckFile" 2>>/dev/null)
if [ -z $mounted ] ; then
echo "[refresh] Network not available (content: $piwiMountedCheckFile)"
exit 1;
fi
metaAll=0
case "$1" in
--meta_all|-m) # including already synchronised photos
metaAll=1
shift
;;
esac
if [ "$1" != "" ] && [ "$2" != "" ]
then
piwiRefreshCatId=$1
piwiRefreshSubCatId=$2
fi
perl -w $WDIR/piwigo_refresh.pl \
--base_url="${piwiRefreshUrl}" \
--site=${piwiRefreshSiteId} \
--user="${piwiRefreshUser}" \
--password="${piwiRefreshPass}" \
--directory="${piwiRefreshSite}" \
--caddie=0 \
--privacy_level=${piwiRefreshPrivacy} \
--meta_all=${metaAll} \
--cat=${piwiRefreshCatId} \
--subcat=${piwiRefreshSubCatId}
ENDTIME=$(date +%s)
# Don't calculate runtime yet
# TODO there seems to be a timeout for the refresh; it always returns after 6 minutes
# although php process of piwigo is still running
#echo "Refresh took: $((($ENDTIME - $STARTTIME)/60)) minutes"