set -e
-cachedir=/var/tmp/Apache-Gallery
-user=www-data
+cachedir="/var/cache/www"
+user="www-data"
-if [ -d $cachedir ]; then
+if [ -d "$cachedir" ]; then
# remove old files
start-stop-daemon --start --pidfile /dev/null --startas /bin/sh \
- --oknodo --chuid $user -- -c \
- "find $cachedir -type f -atime +6 -print0 | xargs -r0 rm -f"
+ --oknodo --chuid "$user" -- -c \
+ "find '$cachedir' -type f -atime +6 -delete"
# remove empty directories
start-stop-daemon --start --pidfile /dev/null --startas /bin/sh \
- --oknodo --chuid $user -- -c \
- "find $cachedir -depth -type d -print0 | \
+ --oknodo --chuid "$user" -- -c \
+ "find '$cachedir' -depth -type d -print0 | \
xargs -r0 rmdir --ignore-fail-on-non-empty"
fi