#!/bin/bash
# 
# iTunesShareFix
# 
# iTunes Shared Library Permissions Fixer
#
# This periodic script will fix the permissions of a directory tree to
# allow multiple users to shared read and write access that tree. This
# is most useful for sharing an iTunes music library between multiple
# users on a single Mac.
#
# Install this script with permissions 755 into /etc/periodic/daily
# and it will run once a day as long as your Mac is running at night.
#
# If your mac if off at night (putting your powerbook to sleep for example)
# you should get the anacron package from:
# http://www.alastairs-place.net/anacron.html
#
#
###############################################################################
# Variables
###############################################################################
#
# SHAREGRP - All users that should have access to the library will need
#            to be part of this group

SHAREGRP="media-users"

# SHAREDIR - The top level directory under which everything will be read 
# and write accessible for members of SHAREGRP. Be sure to include the
# directory that holds the "iTunes Music Library.xml" files so that everyone
# has the ability to make playlists.
# 

SHAREDIR="/Path/To/Your/Music"

###############################################################################
### Don't Make any changes below here unless you know what you're doing!
###############################################################################

find "$SHAREDIR" -type d -exec chmod 775 "{}" \;
find "$SHAREDIR" -type d -exec chgrp $SHAREGRP "{}" \;
find "$SHAREDIR" -type f -exec chmod 664 "{}" \;
find "$SHAREDIR" -type f -exec chgrp $SHAREGRP "{}" \;


