Checking the user id is more civilized for identifying the superuser. The error message goes to STDERR as it should. The function is actually invoked.
Kill apache2 for good before hitting the network with apt. This also removes the auto-dependencies and config.
wget can output to STDOUT in order to pipe it directly to apt-key. One-liner, no temp file. Besides, apt-key add filename is more efficient than cat filename | apt-key add -.
dist-upgrade makes sure that all the packages are properly upgraded. Some may have new dependencies which upgrade skips.
Cleaned up the commentz and shitz.
Made it forward compatible with future releases (ie: 5.6).
http://www.emacswiki.org/emacs/TabsSpacesBoth
Cleaned up the apt install. Auto-accept the packages. Grouped them by category. Removed the redundant stuff (php5 - just a virtual that binds php5-common and a php5 SAPI, but a SAPI already depends on php5-common, php5-curl specified twice).
/etc/init.d is more reliable that service. To be read: more portable.
This also breaks the automation.