diff --git a/piwisyncremote.sh b/piwisyncremote.sh new file mode 100755 index 0000000..826d1f9 --- /dev/null +++ b/piwisyncremote.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# Populating a remote piwigo instance with thumbnails +# Usefull for first import of a large photo archive which is +# then served from a low performance device (e.g. Raspberry Pi) + +# TODO Adjust password in the line where sshfs is mounted +# TODO Adjust following directories to fit your needs + +remotePhotoRoot="/var/www/piwigo/_data/i/network/network" +networkPhotoRoot="/home/network/Bilder/photos/" +localTemp="/tmp/piwiTemp/" +piwigoThumbRoot="/tmp/piwiMnt/" +sshfsAccess="user@host" + +if [ "$1" == "" ] +then + echo "Subfolder must be provided!" + echo "Source: $networkPhotoRoot" + echo "Remote: ${remotePhotoRoot}[subfolder]" + exit 1; +fi + +subDir="$1/" + +if [ ! -e ${networkPhotoRoot}${subDir} ] +then + echo "${networkPhotoRoot}${subDir} not found" + exit 1; +fi + +mkdir -p "${localTemp}" "${piwigoThumbRoot}" + +./piwigo_thumbgen.sh "${networkPhotoRoot}${subDir}" "${localTemp}${subDir}" + +if [[ -z $(mount | grep ${piwigoThumbRoot}) ]] +then + echo "mounting $piwigoThumbRoot..." + sshfs ${sshfsAccess}:${remotePhotoRoot} ${piwigoThumbRoot} -o password_stdin <<< "-change me-" +fi + +if [[ ! -z $(mount | grep ${piwigoThumbRoot}) ]] +then + echo "copying thumbnails to webserver..." + rsync --ignore-existing -r "${localTemp}${subDir}" "${piwigoThumbRoot}${subDir}" +fi + +echo "chown -R www-data: ${remotePhotoRoot}/${subDir} (on your webserver)" +echo "Symlink network drive on webserver (e.g. /var/www/piwigo/network/network/${subDir})" +read -n 1 -s -r -p "Press any key to continue" + +echo -e -n "\nUpdating gallery..." + +./piwirefresh.sh && echo "Ok" + +echo "Don't forget to sudo umount ${piwigoThumbRoot}" +exit 0;