BreadCrumbs: Apple TV

Apple TV

From Luke Jackson

(Difference between revisions)
Jump to: navigation, search

Revision as of 02:10, 13 January 2008

Testing

The /System/Library/StartupItems directory is reserved for startup items that ship with Mac OS X. All other startup items should be placed in the /Library/StartupItems directory. Note that this directory does not exist by default and may need to be created during installation of the startup item.

It existed on my Apple TV so I just did the following:

sudo mkdir /Library/StartupItems/MountSystem
sudo touch /Library/StartupItems/MountSystem/MountSystem
sudo touch /Library/StartupItems/MountSystem/StartupParameters.plist

Add the following code to MountSystem executable:

#!/bin/sh

. /etc/rc.common

EN0=`ifconfig en0 | grep 'broadcast' | awk '{print $2}' | awk -F . '{print $3}'`
EN1=`ifconfig en1 | grep 'broadcast' | awk '{print $2}' | awk -F . '{print $3}'`

StartService() {
  if [ $EN0 = 85 ] || [ $EN1 = 85 ]; then
      #Load kernel extension and mount share
    /sbin/turbo_kext_enabler.bin
    kextload /System/Library/Extensions/smbfs.kext
    mount_smbfs "//<Username>:<Password>@<IP-Address>/<Share>" /Users/frontrow/Movies/<Share>
  else
    echo 'Not at home!'
  fi
}

StopService() {
    return 0;
}

RestartService() {
    return 0;
}

RunService "$1"

Add the following to StartupParameters.plist:

{
  Description = "Mount System";
  Provides = ("Network Shares");
  Uses = ("Network");
  Requires = ("Network");
  OrderPreference = "Late";
}

Set permissions:

sudo chowm -R root:wheel /Library/StartupItems/MountSystem
sudo chmod -R 755 /Library/StartupItems/MountSystem
sudo chmod 744 /Library/StartupItems/MountSystem/StartupParameters.plist
Personal tools