Saturday, December 23, 2006

Nerd alert! I wrote this bash shell script today to update permissions in our existing Aperture library. It took about 20 minutes to run over a 100GB library (~117,000 files). Had I setup permissions properly when I created the library this wouldn't have been an issue, but doing it after the fact required me to iterate through all the files and update the permissions allowing both Lisa and me to modify them. ACLs are validated first, so the POSIX permissions (owner, group, other type) are ignored for users with explicit allow/deny access control entries (ACEs).

We first noticed the problem when Lisa opened Aperture and couldn't import pictures into our (supposedly) shared library. I then noticed that the thumbnails were being re-generated over and over...almost like they weren't being saved to disk. These two things led me to permissions which led me to enabling ACLs and writing this script. It seems so obvious and simple now, but my lack of Mac OS X knowledge made this a slow process.


A special thanks to SubEthaEdit for the auto-HTML-coloring of my script for me!
# A script to set ACL permissions recursively
# Created by Doug Clark on Dec 23, 2006
# for the purpose of setting up the shared aperture library

# change dirs if non-empty param
if [ -n "${1}" ]
cd $1

echo WARNING: This script will recursively modify all ACLs in the path $PWD
echo Please verify this is correct.
echo Press Ctrl-C to abort, enter key to continue.

# set the delim to new line, otherwise filenames with
# spaces would cause a problem
for file in `find $PWD`
echo Updating \"${file}\"
chmod +a "
lisa allow list,add_file,search,delete,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit" $file
chmod +a "
doug allow list,add_file,search,delete,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit" $file


Román said...

Good job, Doug!

1. Cut a hole in a box

Chris said...

2. Put your junk in the box!