# run this script with "source fix_permissions" or ". fix_permissions"

# A quick hack to fix permissions on all your files so they can be modified by salonify (e.g., rotated, captioned, etc.)
# Note that as is this will give user www-data write permission to all your photos.
# A better option would be to create a new user or group for salonify, and have salonify and make_salonify run as setuid/setgid
# for that group (then only salonify will be able to write to your image directories).
# or just have salonify run as setuid for your user, if you can't create a new user

IMAGE_OWNER=www-data
SALONIFY_RUNS_AS=www-data
TOP_FOLDER=/var/www/photos

find $TOP_FOLDER -iname names.txt -or -iname \*.jpg -or -iname .\*.jpg -or -iname \*.gif -or -iname .\*.gif -and -not -name \*RCS\* | xargs -i chown $IMAGE_OWNER:$SALONIFY_RUNS_AS ""{}"" &
find $TOP_FOLDER -iname names.txt -or -iname \*.jpg -or -iname .\*.jpg -or -iname \*.gif -or -iname .\*.gif -and -not -name \*RCS\* | xargs -i chmod 664 ""{}"" &
find $TOP_FOLDER -type d -and -not -name RCS | xargs -i chown $IMAGE_OWNER:$SALONIFY_RUNS_AS ""{}"" &
find $TOP_FOLDER -type d -and -not -name RCS | xargs -i chmod 775 ""{}"" &
