#!/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 # 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" if [ "$1" == "" ] then echo "Subfolder must be provided!" echo "Source: $piwiPhotoRootRemote" echo "Remote: ${piwiThumbRootRemote}[subfolder]" exit 1; fi subDir="$1/" if [ ! -e ${piwiPhotoRootRemote}${subDir} ] then echo "${piwiPhotoRootRemote}${subDir} not found" exit 1; fi mkdir -p "${piwiLocalTemp}" "${piwiLocalThumbRoot}" $WDIR/piwigo_thumbgen.sh "${piwiPhotoRootRemote}${subDir}" "${piwiLocalTemp}${subDir}" if [[ -z $(mount | grep ${piwiLocalThumbRoot}) ]] then echo -n "mounting $piwiLocalThumbRoot ..." sshfs ${piwiRemoteUser}@${piwiRemoteHost}:${piwiThumbRootRemote} ${piwiLocalThumbRoot} -o password_stdin <<< "${piwiRemotePass}" && echo "ok" fi if [[ ! -z $(mount | grep ${piwiLocalThumbRoot}) ]] then echo "copying thumbnails to webserver..." rsync --ignore-existing -r "${piwiLocalTemp}${subDir}" "${piwiLocalThumbRoot}${subDir}" fi echo "chown -R www-data: ${piwiThumbRootRemote}/${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..." $WDIR/piwirefresh.sh && echo "Ok" echo "Don't forget to sudo umount ${piwiLocalThumbRoot}" exit 0;