Make the scripts configurable and provide example
This commit is contained in:
@@ -7,51 +7,55 @@
|
||||
# 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"
|
||||
# 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: $networkPhotoRoot"
|
||||
echo "Remote: ${remotePhotoRoot}[subfolder]"
|
||||
echo "Source: $piwiPhotoRootRemote"
|
||||
echo "Remote: ${piwiThumbRootRemote}[subfolder]"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
subDir="$1/"
|
||||
|
||||
if [ ! -e ${networkPhotoRoot}${subDir} ]
|
||||
if [ ! -e ${piwiPhotoRootRemote}${subDir} ]
|
||||
then
|
||||
echo "${networkPhotoRoot}${subDir} not found"
|
||||
echo "${piwiPhotoRootRemote}${subDir} not found"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
mkdir -p "${localTemp}" "${piwigoThumbRoot}"
|
||||
mkdir -p "${piwiLocalTemp}" "${piwiLocalThumbRoot}"
|
||||
|
||||
./piwigo_thumbgen.sh "${networkPhotoRoot}${subDir}" "${localTemp}${subDir}"
|
||||
$WDIR/piwigo_thumbgen.sh "${piwiPhotoRootRemote}${subDir}" "${piwiLocalTemp}${subDir}"
|
||||
|
||||
if [[ -z $(mount | grep ${piwigoThumbRoot}) ]]
|
||||
if [[ -z $(mount | grep ${piwiLocalThumbRoot}) ]]
|
||||
then
|
||||
echo "mounting $piwigoThumbRoot..."
|
||||
sshfs ${sshfsAccess}:${remotePhotoRoot} ${piwigoThumbRoot} -o password_stdin <<< "-change me-"
|
||||
echo -n "mounting $piwiLocalThumbRoot ..."
|
||||
sshfs ${piwiRemoteUser}@${piwiRemoteHost}:${piwiThumbRootRemote} ${piwiLocalThumbRoot} -o password_stdin <<< "${piwiRemotePass}" && echo "ok"
|
||||
fi
|
||||
|
||||
if [[ ! -z $(mount | grep ${piwigoThumbRoot}) ]]
|
||||
if [[ ! -z $(mount | grep ${piwiLocalThumbRoot}) ]]
|
||||
then
|
||||
echo "copying thumbnails to webserver..."
|
||||
rsync --ignore-existing -r "${localTemp}${subDir}" "${piwigoThumbRoot}${subDir}"
|
||||
rsync --ignore-existing -r "${piwiLocalTemp}${subDir}" "${piwiLocalThumbRoot}${subDir}"
|
||||
fi
|
||||
|
||||
echo "chown -R www-data: ${remotePhotoRoot}/${subDir} (on your webserver)"
|
||||
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..."
|
||||
|
||||
./piwirefresh.sh && echo "Ok"
|
||||
$WDIR/piwirefresh.sh && echo "Ok"
|
||||
|
||||
echo "Don't forget to sudo umount ${piwigoThumbRoot}"
|
||||
echo "Don't forget to sudo umount ${piwiLocalThumbRoot}"
|
||||
exit 0;
|
||||
|
Reference in New Issue
Block a user