#!/bin/bash # # /Users/Shared/bin/share-itunes # # Fixes iTunes library permissions to allow sharing between all # users that store their music in the shared directory. # ##### Constants # location of the shared music library readonly LIBRARY='/Users/Shared/Music/iTunes/' readonly ROOT_UID=0 # users with $UID 0 have root privileges readonly PROGNAME=$(basename $0) # name of this script for error output readonly E_NOTROOT=67 # non-root exit error ##### Functions function error_exit { echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2 exit 1 } ##### Main # ensure user has root privileges if [ "$UID" -ne "$ROOT_UID" ]; then echo "Permission denied: You must be root to run this script."; exit $E_NOTROOT fi # ensure destination directory exists if [ ! -d "$LIBRARY" ]; then error_exit "Specified library $LIBRARY does not exist."; fi # change the file permissions of new music from 640 to 644 find $LIBRARY -type f -perm 640 -regex ".*\.m4[pa]" -exec chmod 644 {} \; exit 0 # End of file