|
|
Build a basic Patchstick
We have extracted boot.efi and partitioned a USB pen drive with a recovery and second hfsplus partitions using the above links. This guide assumes that the recovery partition is mounted at "/media/Recovery" and the second partition is mounted at "/media/Patchstick".
Download recovery.tar.gz and copy it to the recovery partition
# download recovery files wget http://atv-bootloader.googlecode.com/files/recovery-0.6.tar.gz sudo tar -xzf recovery-0.6.tar.gz sudo cp -arp recovery/* /media/Recovery/
Don't forget to copy boot.efi to the recovery partition
sudo cp -ap boot.efi /media/Recovery
Now make a simple patchstick script to test functionality. There is an existing sample patchstick.sh in recovery.tar.gz and we are just moving to the second partition where we will place all the other bits. You could just keep everything on the recovery partition (make it larger if you do this) but this keeps booting and patching separate.
mv /media/Recovery/patchstick.sh /media/Patchstick/
edit com.apple.Boot.plist and change the following line
<string>atv-boot=auto video=vesafb</string>
to
<string>atv-boot=patchstick video=vesafb</string>
Now sync and unmount both partitions
sync umount /media/Recovery umount /media/Patchstick
Pull the USB pen drive and place into the USB port on the AppleTV and reboot/power on. You might have to use the IR remote and press "menu" and "-" buttons down during power on to force a USB recovery boot.
You should see the tux/atv logo, then Linux kernel boot and then finally
this is a patchstick stript
If you have a USB keyboard attached, you can login (user=root password=root) and poke around. The USB pen drive will be at "/dev/sdb" and the internal ata drive is at "/dev/sda".
example patchstick.sh
Fill in "patchstick.sh" with the patchstick function you want to perform. Here's an example of a sshd install contributed by James Abeler of Apple Core, LLC. Thanks James, for being the first prove this method of patching the AppleTV OS. This script assumes that you have created a directory "ssh" on the "Patchstick" partition of the USB flash drive and populate it with the required files.
#!/bin/bash exec 2>/dev/console exec 1>/dev/console echo echo " --- aTV Flash 2.0.1 Upgrade ---" echo " * mounting OSBoot partition" mkdir /mnt/OSBoot fsck.hfsplus /dev/sda3 mount -t hfsplus -o rw,force /dev/sda3 /mnt/OSBoot #echo " * mounting stuff partition r/o" mkdir /mnt/stuff fsck.hfsplus /dev/sdb2 mount -t hfsplus -r /dev/sdb2 /mnt/stuff echo " * keeping the OSBoot partition r/w for plugins" touch /mnt/OSBoot/.readwrite if [ -f /mnt/rootfs/stuff/ssh/sshd ] && [ -f /mnt/rootfs/stuff/ssh/ssh.plist ]; then echo -n " * Installing SSH daemon... " cp /mnt/rootfs/stuff/ssh/sshd /mnt/OSBoot/usr/sbin/sshd cp /mnt/rootfs/stuff/ssh/ssh /mnt/OSBoot/usr/bin/ssh cp /mnt/rootfs/stuff/ssh/ssh-add /mnt/OSBoot/usr/bin/ssh-add cp /mnt/rootfs/stuff/ssh/ssh-agent /mnt/OSBoot/usr/bin/ssh-agent cp /mnt/rootfs/stuff/ssh/ssh-keygen /mnt/OSBoot/usr/bin/ssh-keygen cp /mnt/rootfs/stuff/ssh/ssh-keyscan /mnt/OSBoot/usr/bin/ssh-keyscan cp /mnt/rootfs/stuff/ssh/scp /mnt/OSBoot/usr/bin/scp cp /mnt/rootfs/stuff/ssh/sftp-server /mnt/OSBoot/usr/libexec/sftp-server cp /mnt/rootfs/stuff/ssh/ssh-keysign /mnt/OSBoot/usr/libexec/ssh-keysign cp /mnt/rootfs/stuff/ssh/sshd-keygen-wrapper /mnt/OSBoot/usr/libexec/sshd-keygen-wrapper cp /mnt/rootfs/stuff/ssh/ssh.plist /mnt/OSBoot/System/Library/LaunchDaemons/ssh.plist chmod 755 /mnt/OSBoot/usr/sbin/sshd chmod 755 /mnt/OSBoot/usr/bin/ssh chmod 755 /mnt/OSBoot/usr/bin/ssh-add chmod 755 /mnt/OSBoot/usr/bin/ssh-agent chmod 755 /mnt/OSBoot/usr/bin/ssh-keygen chmod 755 /mnt/OSBoot/usr/bin/ssh-keyscan chmod 755 /mnt/OSBoot/usr/bin/scp chmod 755 /mnt/OSBoot/usr/libexec/sftp-server chmod 4755 /mnt/OSBoot/usr/libexec/ssh-keysign chmod 755 /mnt/OSBoot/usr/libexec/sshd-keygen-wrapper chmod 755 /mnt/OSBoot/System/Library/LaunchDaemons/ssh.plist # echo " Adding Kerberos..." # cp -p -R /System/Library/Frameworks/OSXFrames/Kerberos.framework /OSBoot/System/Library/Frameworks/OSXFrames/ # sed -i"" -e 's;^exec;DYLD_FRAMEWORK_PATH="/System/Library/Frameworks/OSXFrames" exec;' /OSBoot/usr/libexec/sshd-keygen-wrapper echo " done." else echo " SSH files not found." fi #-------------------------------------------------------------------------- sync &>/dev/null umount /mnt/OSBoot echo " all done!" echo echo " The aTV Flash software has been successfully installed. You may now remove the flash drive and restart your Apple TV." echo " Thanks from AppleCoreLLC.com" echo " :-)" sleep 100000
Here's an another example of installing "sshd". Nothing is auto mounted so you will need to mount any disk partitions manually. This also assumes that you have created a directory "ssh" on the "Patchstick" partition of the USB flash drive and populate it with the required files.
#!/bin/bash # On Linux, bash is located at "/bin/bash" not "/sbin/bash" # make some mount points mkdir /stuff /OSBoot # mount the USB flash drive "Patchstick" partition mount /dev/sdb2 /stuff # always "fsck.hfsplus -f" hfsplus journaled partitions first fsck.hfsplus -f /dev/sda3 # mount "OSBoot" forcing it read/write mount -t hfsplus -o rw,force /dev/sda3 /OSBoot # patchstick scripts under Linux look the same as under OSX # it's just bash after all. # install ssh # (c) 2007 macTijn at awkwardtv dot org if [ -f /stuff/ssh/sshd ] && [ -f /stuff/ssh/ssh.plist ]; then echo -n " * Installing SSH daemon... " cp /stuff/ssh/sshd /OSBoot/usr/sbin/sshd cp /stuff/ssh/ssh /OSBoot/usr/bin/ssh cp /stuff/ssh/ssh-add /OSBoot/usr/bin/ssh-add cp /stuff/ssh/ssh-agent /OSBoot/usr/bin/ssh-agent cp /stuff/ssh/ssh-keygen /OSBoot/usr/bin/ssh-keygen cp /stuff/ssh/ssh-keyscan /OSBoot/usr/bin/ssh-keyscan cp /stuff/ssh/scp /OSBoot/usr/bin/scp cp /stuff/ssh/sftp-server /OSBoot/usr/libexec/sftp-server cp /stuff/ssh/ssh-keysign /OSBoot/usr/libexec/ssh-keysign cp /stuff/ssh/sshd-keygen-wrapper /OSBoot/usr/libexec/sshd-keygen-wrapper cp /stuff/ssh/ssh.plist /OSBoot/System/Library/LaunchDaemons/ssh.plist chmod 755 /OSBoot/usr/sbin/sshd chmod 755 /OSBoot/usr/bin/ssh chmod 755 /OSBoot/usr/bin/ssh-add chmod 755 /OSBoot/usr/bin/ssh-agent chmod 755 /OSBoot/usr/bin/ssh-keygen chmod 755 /OSBoot/usr/bin/ssh-keyscan chmod 755 /OSBoot/usr/bin/scp chmod 755 /OSBoot/usr/libexec/sftp-server chmod 4755 /OSBoot/usr/libexec/ssh-keysign chmod 755 /OSBoot/usr/libexec/sshd-keygen-wrapper chmod 755 /OSBoot/System/Library/LaunchDaemons/ssh.plist echo " Done." fi
Sign in to add a comment

Very nice, everything worked like a charm. One issue in my case (but may be I did something wrong, I am fairly new to all this, sorry). When my AppleTV boots on the patchstick, this is the display I get at the end:
atv-boot=patchstick -- searching for patchstick.sh chmod: /mnt/rootfs/patchstick.sh: Read-only file system /etc/init.d/rcS: line 75: [sdb2/patchstick.sh: not found atv-boot=auto/manual/patchstick failed -- starting telnetd
If I then manually run (from a telnet session) "/usr/sbin/find_run_script.sh patchstick.sh" this is working just fine (it finds the script and executes it). Any ideas?
The current internal script will try to "chmod +x" the patchstick.sh script so it can be executed. If the partition was not cleanly unmounted then it will get mounted read only thus causing an error as the chmod will fail. It's a quirk with hfsplus filesystems and Linux and one should always fsck.hfsplus the partition before mounting.
This is fixed with a pending new version but I'm not ready to post it yet.
Understood. Thanks for the answer. It did not stop me anyway, I now have a patchstick with LiveXBMC installed and everything works just fine except the AppleTV remote that I did not manage to make it work (yet). All that thanks to your really great instructions. Thanks a bunch, greatly appreciated.