Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'And why not a script?' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
And why not a script?
Authored by: thinkyhead on Jan 29, '04 07:16:51PM
The following shell script "combinemusic" must be executed with sudo. It uses hard links instead of symbolic links. I feel more secure doing it this way for some reason. The music library of the user that runs this script is the one that becomes shared. This is safe to run when iTunes is running, but don't.

#!/bin/sh
#
# combinemusic
#
# shell script to share a single music library with all users
#

ITUNES="/Users/Shared/Shared iTunes"
FILE1="iTunes 4 Music Library"
FILE2="iTunes Music Library.xml"
SAVE="Saved Library"

if [ `whoami` != "root" ]; then
 echo "This script requires root privileges."
 exit 1
fi

if [ -f "$ITUNES/$FILE1" ]; then
    echo The Shared iTunes Library already exists
    exit 1
fi

mkdir -p "$ITUNES"

cd ~/Music/iTunes
ditto --rsrc "$FILE1" "$FILE2" "$ITUNES"
chmod -R 777 "$ITUNES"

for U in `ls /Users | grep -v Shared`
do
    if [ -d "/Users/$U" ]; then

        cd "/Users/$U/Music"

        if [ ! -e iTunes ]; then
            mkdir -p -m 755 iTunes
            chown $U:$U iTunes
        fi

        cd iTunes

        if [ -e "$FILE1" -o -e "$FILE2" ]; then
            mkdir -p -m 770 "$SAVE"
            chown $U:$U "$SAVE"
        fi

        if [ -e "$FILE1" ]; then
            mv "$FILE1" "$SAVE"
        fi

        if [ -e "$FILE2" ]; then
            mv "$FILE2" "$SAVE"
        fi

        ln "$ITUNES/$FILE1" "$FILE1"
        ln "$ITUNES/$FILE2" "$FILE2"
    fi

done

---
|
| slur was here
|

[ Reply to This | # ]

And why not a script? for iphoto??
Authored by: askwersky on Feb 16, '04 05:42:55PM

Can you give an example of how you would changes this for iPhoto?



[ Reply to This | # ]