#!/bin/bash PRODUCT_NAME=Squeezebox PREFPANE_TO="/Library/PreferencePanes/$PRODUCT_NAME.prefPane" LOG_FOLDER="$HOME/Library/Logs/$PRODUCT_NAME.$USER" if [ ! -e $LOG_FOLDER ] ; then sudo -b -H -u $USER mkdir -p $LOG_FOLDER; fi if [ z"$USER" != zroot ] ; then sudo -b -H -u $USER chown -R $USER $LOG_FOLDER fi # remove the version file triggering the update prompt if [ -e ~/Library/Caches/$PRODUCT_NAME/updates/server.version ] ; then rm -f ~/Library/Caches/$PRODUCT_NAME/updates/server.version fi if [ -e /Library/Caches/$PRODUCT_NAME/updates/server.version ] ; then rm -f /Library/Caches/$PRODUCT_NAME/updates/server.version fi # stupid bug in packagemaker/installer on OSX 10.5 would drop the content in the system's root instead of the target folder # http://simx.me/technonova/tips/packagemaker_and_installer.html if [ -e "/$PRODUCT_NAME.prefpane" ] ; then if [ -e "$PREFPANE_TO" ] ; then rm -rf "$PREFPANE_TO" fi mv "/$PRODUCT_NAME.prefpane" "$PREFPANE_TO" fi if [ -e "$PREFPANE_TO" ] ; then # try to use our custom built perl on newer systems CUSTOM_PERL="$PREFPANE_TO/Contents/perl/bin/perl" if [ -x "$CUSTOM_PERL" ]; then MAJOR_OS_VERSION=`sw_vers | fgrep ProductVersion | tr -dc '0-9.' | cut -d '.' -f 1` PERL_VERSION=`$CUSTOM_PERL -v` if [ z"$PERL_VERSION" = z -o "$MAJOR_OS_VERSION" = 10 ]; then CUSTOM_PERL= else cd "$PREFPANE_TO/Contents/server" $CUSTOM_PERL -i -pe "s{^#!/usr/bin/perl\b}{#!$CUSTOM_PERL}" *.pl $CUSTOM_PERL -i -pe "s{^#!/usr/bin/env perl\b}{#!$CUSTOM_PERL}" *.pl cd "$PREFPANE_TO/Contents/server/Bin/darwin" $CUSTOM_PERL -i -pe "s{^#!/usr/bin/env perl\b}{#!$CUSTOM_PERL}" *.pl fi fi # starting with Big Sur Perl 5.18 is no longer the default Version - force using it if it's available if [ z"$CUSTOM_PERL" = z -a -x "/usr/bin/perl5.18" ]; then cd "$PREFPANE_TO/Contents/server" perl -i -pe 's{^#!/usr/bin/perl\b}{#!/usr/bin/perl5.18}' *.pl perl -i -pe 's{^#!/usr/bin/env perl\b}{#!/usr/bin/perl5.18}' cleanup.pl cd "$PREFPANE_TO/Contents/server/Bin/darwin" perl -i -pe 's{^#!/usr/bin/env perl\b}{#!/usr/bin/perl5.18}' cleanup.pl fi cd "$PREFPANE_TO/Contents/Resources" # install SC to start at boot time if it hasn't been configured yet; update startupitem if we're updating if [ -e /Library/StartupItems/$PRODUCT_NAME ] ; then ./create-startup.sh fi sudo -b -H -u $USER "./start-server.sh" cd "$PREFPANE_TO/Contents/server/Bin/darwin" sudo -b -H -u $USER osascript openprefs.scpt & exit 0 else exit 1 fi