synctunes
¶ by Rob FrieselSubmitted for scrutiny (esp. since it doesn’t appear to be working…):
synctunesin.sh gets the latest iTunes Library info from the iTunes User account
#!/bin/bash TUNESHARE=/Users/itunes/Music/iTunes AMYLIB=/Users/amy/Music/iTunes GUESTLIB=/Users/guest/Music/iTunes ROBLIB=/Users/rob/Music/iTunes if [ $USER != itunes ]; then if [ $TUNESHARE/iTunes\ 4\ Music\ Library -nt $AMYLIB/iTunes\ 4\ Music\ Library ]; then cp $TUNESHARE/iTunes\ 4\ Music\ Library $AMYLIB/iTunes\ 4\ Music\ Library cp $TUNESHARE/iTunes\ Music\ Library.xml $AMYLIB/iTunes\ Music\ Library.xml fi if [ $TUNESHARE/iTunes\ 4\ Music\ Library -nt $GUESTLIB/iTunes\ 4\ Music\ Library ]; then cp $TUNESHARE/iTunes\ 4\ Music\ Library $GUESTLIB/iTunes\ 4\ Music\ Library cp $TUNESHARE/iTunes\ Music\ Library.xml $GUESTLIB/iTunes\ Music\ Library.xml fi if [ $TUNESHARE/iTunes\ 4\ Music\ Library -nt $ROBLIB/iTunes\ 4\ Music\ Library ]; then cp $TUNESHARE/iTunes\ 4\ Music\ Library $ROBLIB/iTunes\ 4\ Music\ Library cp $TUNESHARE/iTunes\ Music\ Library.xml $ROBLIB/iTunes\ Music\ Library.xml fi fi exit 0
synctunesout.sh takes your playcounts, updated ratings, etc. and updates them in the central iTunes User account
#!/bin/bash TUNESHARE=/Users/itunes/Music/iTunes AMYLIB=/Users/amy/Music/iTunes GUESTLIB=/Users/guest/Music/iTunes ROBLIB=/Users/rob/Music/iTunes if [ $USER != itunes ]; then if [ $AMYLIB/iTunes\ 4\ Music\ Library -nt $TUNESHARE/iTunes\ 4\ Music\ Library ]; then cp $AMYLIB/iTunes\ 4\ Music\ Library $TUNESHARE/iTunes\ 4\ Music\ Library cp $AMYLIB/iTunes\ Music\ Library.xml $TUNESHARE/iTunes\ Music\ Library.xml fi if [ $GUESTLIB/iTunes\ 4\ Music\ Library -nt $TUNESHARE/iTunes\ 4\ Music\ Library ]; then cp $GUESTLIB/iTunes\ 4\ Music\ Library $TUNESHARE/iTunes\ 4\ Music\ Library cp $GUESTLIB/iTunes\ Music\ Library.xml $TUNESHARE/iTunes\ Music\ Library.xml fi if [ $ROBLIB/iTunes\ 4\ Music\ Library -nt $TUNESHARE/iTunes\ 4\ Music\ Library ]; then cp $ROBLIB/iTunes\ 4\ Music\ Library $TUNESHARE/iTunes\ 4\ Music\ Library cp $ROBLIB/iTunes\ Music\ Library.xml $TUNESHARE/iTunes\ Music\ Library.xml fi fi exit 0
chmod to give them their “x” bits and then add as a LoginHook and a LogoutHook (respectively) via:
$ sudo defaults write com.apple.loginwindow LoginHook /Library/Scripts/synctunesin.sh $ sudo defaults write com.apple.loginwindow LogoutHook /Library/Scripts/synctunesout.sh
So in theory, these should run when a user logs in and logs out (respectively) effectively synchronizing the iTunes Library files. I know the scripts work because running them manually from the command line seems to sync things up. But they do not appear to be executing (or executing properly?) as Login/outHooks despite the fact that they were successfully added:
rob@Malkovich $ sudo defaults read com.apple.loginwindow { LoginHook = "/Library/Scripts/synctunesin.sh"; LogoutHook = "/Library/Scripts/synctunesout.sh"; }
Thoughts? Comments? Suggestions? Alternatives?
Leave a Reply