Ok, so I have updated this for Take 2 and Leopard. This is more of a rought draft, but it worked well for me. Please comment if I have missed any steps since I am writing this after the fact. One big change from the original article us you can let Disk Utility do some of the work for you now. Also, I just skipped the restore partition to keep it simple since that was the source of many problems.
Connect your Apple TV drive in Leopard. Remember disk1 may not be the name of your drive.
From the terminal: Wipe out and re-create the partition structure
sudo diskutil unmountDisk /dev/disk1
sudo gpt destroy /dev/disk1
sudo gpt create /dev/disk1
Create the OSBoot Partition
sudo gpt add -b 888872 -i 3 -s 1843200 -t hfs /dev/disk1
diskutil unmountDisk /dev/disk1
sudo diskutil eraseVolume "Journaled HFS+" OSBoot /dev/disk1s3
diskutil unmountDisk /dev/disk1
Create the Media Partition
Go to Disk Utility and format the Media partition - Name it Media and use the rest of the free space on your drive.
diskutil unmountDisk /dev/disk1
Restore the OS image to the drive
Download it here:
http://mesu.apple.com/data/OS/061-3561.20080212.ScoH6/2Z694-5274-109.dmg
to your desktop.
sudo dd if=/Users/username/Desktop/OS.dmg of=/dev/disk1s3 bs=1m
Now Bless the boot file
Notice how the OSBoot we are blessing is OSBoot 1 because it is on Disk 1.
bless --folder="/Volumes/OSBoot 1/System/Library/CoreServices" --file="/Volumes/OSBoot 1/System/Library/CoreServices/boot.efi" --setBoot
Now pray and let me know if you are successful or not so we can make this article more useful.
--ORIGINAL ARTICLE IS BELOW
I titled this appropriately after destroying all data on my AppleTV and learning the hard way how to rebuild the drive with no backup or spare AppleTV. The process does not take very long, but I had a hard time finding all of the info in one place and I don't know anyone else currently that owns an AppleTV that I can borrow.
Assumptions / Caveats:
1. My guide assumes that you will remove the drive from your AppleTV.
However, this could be done without removing the drive by booting from
a USB drive with OSX (Sorry, you'll have to search for this elsewhere).
2. You will need to download the Apple OS 1.1.dmg file (The latest at the time I am writing this) which contains the OSBoot data. Luckily, Apple provides this file at http://mesu.apple.com/data/OS/061-2988.20070620.bHy75/2Z694-5248-45.dmg. You can also use version 1.0 if you happen to have that DMG image, I have verified it works as well.
3. You will need an Intel Mac and a USB cable or external enclosure to connect the AppleTV drive to you computer. I used an old 40gb IBM TravelStar hard drive in my test.
4. I don't know if this is crucial, but to be safe I downloaded an app called Spotless that lets you turn Spotlight off termporarily while doing this.
5. I did not restore the recovery data, therefore my guide lacks this step, although the partition is there. From my readings, it looks like you can do this by renaming the DMG you downloaded from apple above to OS.DMG and copy it to the recovery partition / reset its permissions to 777 after you finish this guide by using a patchstick, or possibly even do it right after you create the partition. I don't know and I hope someone will post this in the comments. However, this guide should get you back to factory state and a working AppleTV otherwise.
6. When you are in the terminal, you should be running as root, or you need to add sudo in front of the below commands.
Instructions:
Follow the instrctions on removing your AppleTV drive (if you need to). Basically, peel the rubber off the bottom and remove the 4 case screws and the 4 drive screws with a torx screwdriver ($6 - Lowes).
1. Connect the drive to your Intel Mac with your USB connector.
2. We need to know which drive it is, so open up the terminal and type:
Pay attention to which disk is your usb disk. On my Intel mac, my internal hdd was disk0, so my USB was disk1. Throughout this document, be sure to substitute your correct disk id or you may blow away your hard drive.
diskutil /list
3. Now we will completely destroy anything on the drive to start with a blank slate. When the finder asks you to initialize the disk, just choose ignore.
diskutil unmountDisk /dev/disk1
gpt destroy /dev/disk1
gpt create /dev/disk1
4. Next, we need to add the OSBoot partition with the following command and then unmount it.
gpt add -b 888872 -i 3 -s 1843200 -t hfs /dev/disk1
diskutil unmountDisk /dev/disk1
5. Now, we need to determine how much space is on your hard drive for your Media partition. Look at the line directly above Sec GPT table. This is the starting number and size of the partition. Don't get these wrong.
gpt show /dev/disk1
diskutil unmountDisk /dev/disk1
6. substitute the words START and SIZE with the numbers you got from step 5.
gpt add -b START -i 4 -s SIZE -t hfs /dev/disk1
7. Now we are going to prepare the OSBoot and Media Partitions.
8. Next, we will copy the image you downloaded from Apple to the OSBoot partition 3. This will take a few minutes to copy. You could also do this from the disk utility by choosing restore and dragging the OSBoot partition into the destination box. However you choose to do it, make sure it is done before proceeding. You can't mess around with the partitions once you create the EFI and boot partitions because Disk Utility will mess the order up.
diskutil eraseVolume "Journaled HFS+" OSBoot /dev/disk1s3
diskutil eraseVolume "Journaled HFS+" Media /dev/disk1s4
diskutil unmountDisk /dev/disk1
9. Now we need to create the EFI parition and the Restore partition.
dd if=/Users/beauford/Desktop/2Z694-5248-45.dmg of=/dev/disk1s3 bs=1m
diskutil unmountDisk /dev/disk1
gpt add -b 40 -i 1 -s 69632 -t efi /dev/disk1
diskutil unmountDisk /dev/disk1
gpt add -b 69672 -i 2 -s 819200 -t 5265636F-7665-11AA-AA11-00306543ECAC /dev/disk1
10. Finally, we need to bless the drive so that the AppleTV can boot it (This is one big line).
bless --folder=/Volumes/OSBoot/System/Library/CoreServices --file=/Volumes/OSBoot/System/Library/CoreServices/boot.efi --setBoot
diskutil unmountDisk /dev/disk1
11. Unmount the disk and put it back in your AppleTV and boot up.
Credits / References
The guide I wrote is from many hours of searching other sites, newsgroups, etc.. I want to offer credit to the following sites specifically:
awkwardTV
Prepare a hard drive article: http://wiki.awkwardtv.org/wiki/Prepare_a_Hard_Drive
Info about the recovery partition: http://forum.awkwardtv.org/viewtopic.php?f=13&t=839
Cisco & Friends (English Version) - How to create a USB Patchstick: http://www.cerof.net/2007/10/19/piccola-guida-alla-creazione-di-un-patchstick/#more-99
MacRumors Forums - http://forums.macrumors.com/showthread.php?t=320839
AppleTV Hacks
Hack the AppleTV without opening the case
http://www.appletvhacks.net/2007/04/03/hack-the-apple-tv-without-opening-the-case
Removing the drive - http://blog.makezine.com/archive/2007/03/violating_my_apple_tv_war.html
Read my current post on Blackberry Forums regarding the Blackberry 8800 and Cingular. They told me they do support tethering included in the Blackberry unlimited plan at no additional charge.
http://www.blackberryforums.com/524736-post33.html
When I set out to stop spammers from exploiting poorly written scripts scattered across various web sites hosted on a Windows server, I had no idea that I was in for such a long journey. I will try to lay out the steps I took in order to solve the problem, which I am happy to report is working well.
The Problem:
PHP as of 5.2.1 provides no way of tracking which script, or even which web site is the source of an email being delivered using PHP's mail() function. Because so many web applications use it, I didn't want to disable it. Furthermore, the idea of combing through all of the code on multiple sites was not intriguing. Furthermore, I can't change someone else's code and I don't want to start isolating customers by turning their scripts off.
The Platform:
Using a Windows 2003 Server and PHP 5.1.2, I thought this would be quick. Basically, the fix isn't that difficult, but finding the solution led me to many options for Linux / Apache, but few for Windows.
The Details:
I first discovered the option of patching mail.c, thanks to Ilia Alshanetsky's blog at http://ilia.ws/archives/149-mail-logging-for-PHP.html.
I wanted to provide similar functionality for Windows, but did not want to recompile PHP in a Windows environment. The patch added code so that every script sent from the server adds x-header information, such as the script and site sending it, as well as logging what goes out.
The Solution: (PHP Sendmail Wrapper Script + Fake Sendmail + php.ini)
I found a few other alternatives until finally deciding on a unique combination of tools to get the job done. First off, if you are not going to change users code, or patch and recompile the PHP source, you have to have some method of capturing the email leaving the web site, but before it gets to the mail server. In comes Sendmail Wrapper from Greg Maclellan (www.gregmaclellan.com)and Fake Sendmail from Byron Jones (http://glob.com.au/sendmail/.)
The Sendmail Wrapper PHP script is a great little script that will accept mail just as if it were sendmail and then deliver it to the real sendmail (or fake sendmail in my case). The clever part here is that you can specify this script as the default mail server in your PHP.INI file. For Windows, just disable the smtp port, host, etc.. and put c:\usr\lib\sendmail_wrapper.php as your path to sendmail. (Yes, specifying the sendmail path will work on Windows).
Setting up Sendmail for Windows was fairly straight forward. The executable sits in c:\usr\lib\sendmail and includes an ini file that lets you forward mail to your real SMTP server and specify a few other options, including a folder to log the messages. Sendmail simply captures the email piped to it from a script.
Putting the two together was fairly easy. I modified the sendmail wrapper script to use the path to sendmail and made sure fake sendmail was up and running. I also decided since I could let fake sendmail do authentication against an SMTP server to put an actual mail account on my mail server specifically for handling the mail processed via php and I added some limitations, one being a quota no more than 500 messages per day.
The final piece of the puzzle was getting PHP to add some extra headers beyond what the Sendmail Wrapper script was providing so I would really have some robust information. I decided to use Environment Variables and PHP's append directive in php.ini to set some variables up on each page. This idea is credited to
Harold Paulson who posted on Greg Maclellan's blog. I made a page called prepend.php and put in in my php append path (or prepend, you choose). I added the following information to mine, although you could really capture anything you wanted to add to the message header).
<?
putenv("REMOTE_ADDR=" . $_SERVER['REMOTE_ADDR']);
putenv("SCRIPT_NAME=" . $_SERVER['SCRIPT_NAME']);
putenv("SERVER_NAME=" . $_SERVER['SERVER_NAME']);
?>
Next, I made a modification to the sendmail_wrapper script to include this information in the headers of the mail.
// additional headers
$add_headers["X-MsgID"] = $messageid;
$add_headers["X-SenderIP"] = $_ENV["REMOTE_ADDR"];
$add_headers["X-WebSite"] = $_ENV["SERVER_NAME"];
$add_headers["X-Script"] = $_ENV["SCRIPT_NAME"];
I replaced the existing line (below) in the script with the above.
if (preg_match("|C:/Program Files/Plexus/Sites/([a-zA-Z0-9\._-]*)(/.*)?|", $_ENV["PWD"], $matches)) {
$add_headers["X-Generating-Domain"] = $matches[1];
}
A few tips on making this work:
Be certain you have assigned
permissions for the user that PHP is running as to have access to
execute this script. Also, I believe in PHP 5 you still need to make
sure cmd.exe has execute permissions to call the script. Finally, you
must execute it using php.exe the CLI (Command Line Interface), not
php-cgi.exe or the script will have trouble reading the STDIN input. If
you ran the PHP binary installer when you originally installed PHP,
head over to http://snaps.php.net/ and download the zip file, which will contain php.exe. Better yet, it might be a good day to upgrade anyway. Don't forget to restart IIS after you make the changes to php.ini.