| 1 |
#!/bin/bash |
|---|
| 2 |
# |
|---|
| 3 |
# Stupid little Apple TV installer script for the Perian components using the |
|---|
| 4 |
# zip files in the distribution preference pane. |
|---|
| 5 |
# |
|---|
| 6 |
# Should be wrapped up with the zip files using makeself: |
|---|
| 7 |
# makeself --nocrc --nocomp --nox11 ATVComponents Perian-ATV.run Perian ./ATV-Perian-Install.sh |
|---|
| 8 |
# |
|---|
| 9 |
# New for 1.1: $0 [action] [prefix] |
|---|
| 10 |
# |
|---|
| 11 |
# Where action is "install" (the default), "uninstall", or "help". |
|---|
| 12 |
# |
|---|
| 13 |
# Install/uninstall take a prefix of the root to handle (for such as a patchstick) |
|---|
| 14 |
|
|---|
| 15 |
SRCDIR="$PWD" |
|---|
| 16 |
PREFIX=${2:-} |
|---|
| 17 |
PERIAN_DEST="${PREFIX}/Library/QuickTime" |
|---|
| 18 |
A52_DEST="${PREFIX}/Library/Audio/Plug-Ins/Components" |
|---|
| 19 |
|
|---|
| 20 |
ACTION=${1:-install} |
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
if [ "$ACTION" = "help" ]; then |
|---|
| 24 |
echo "Usage: $0 [action] [prefix]" |
|---|
| 25 |
echo |
|---|
| 26 |
echo "Where action is one of: " |
|---|
| 27 |
echo " install Install Perian" |
|---|
| 28 |
echo " uninstall Uninstall Perian" |
|---|
| 29 |
echo " help This message" |
|---|
| 30 |
echo |
|---|
| 31 |
echo "The install/uninstall actions accept a prefix to prefix to all" |
|---|
| 32 |
echo "paths." |
|---|
| 33 |
|
|---|
| 34 |
exit 1 |
|---|
| 35 |
fi |
|---|
| 36 |
|
|---|
| 37 |
# make sure we're running as root |
|---|
| 38 |
if [ "$USER" != "root" ]; then |
|---|
| 39 |
echo "This installer must be run as root." |
|---|
| 40 |
echo |
|---|
| 41 |
echo "Please enter your password below to authorize as root." |
|---|
| 42 |
echo "In most cases, this password is \"frontrow\"." |
|---|
| 43 |
sudo "$0" $* |
|---|
| 44 |
exit 0 |
|---|
| 45 |
fi |
|---|
| 46 |
|
|---|
| 47 |
REMOUNT=0 |
|---|
| 48 |
|
|---|
| 49 |
# Check if / is mounted readonly |
|---|
| 50 |
# Using the prefix option assumes it's already read-write |
|---|
| 51 |
if [ "$PREFIX" = "" ]; then |
|---|
| 52 |
if mount | grep ' on / ' | grep -q 'read-only'; then |
|---|
| 53 |
REMOUNT=1 |
|---|
| 54 |
/sbin/mount -uw / |
|---|
| 55 |
fi |
|---|
| 56 |
fi |
|---|
| 57 |
|
|---|
| 58 |
if [ "$ACTION" = "uninstall" ]; then |
|---|
| 59 |
echo == Removing Perian |
|---|
| 60 |
/bin/rm -rf "$PERIAN_DEST/Perian.component" |
|---|
| 61 |
/bin/rm -rf "$PERIAN_DEST/AC3MovieImport.component" |
|---|
| 62 |
/bin/rm -rf "$A52_DEST/A52Codec.component" |
|---|
| 63 |
|
|---|
| 64 |
if [[ -d "${PREFIX}/System/Library/QuickTime (disabled)/QuickTimeH264.component" && ! -d "${PREFIX}/System/Library/QuickTime/QuickTimeH264.component" ]]; then |
|---|
| 65 |
echo |
|---|
| 66 |
echo "You have previously disabled Apple's H.264 component." |
|---|
| 67 |
echo |
|---|
| 68 |
echo -n "Do you wish to restore it? (Y/n)" |
|---|
| 69 |
read -e restoreapple |
|---|
| 70 |
if [[ "$restoreapple" == "" || "$restoreapple" == "Y" || "$restoreapple" == "y" ]]; then |
|---|
| 71 |
mv "${PREFIX}/System/Library/QuickTime (disabled)/QuickTimeH264.component" "${PREFIX}/System/Library/QuickTime" |
|---|
| 72 |
fi |
|---|
| 73 |
fi |
|---|
| 74 |
else |
|---|
| 75 |
if [ -d "$PERIAN_DEST/Perian.component" -o -d "$PERIAN_DEST/AC3MovieImport.component" -o -d "$A52_DEST/A52Codec.component" ]; then |
|---|
| 76 |
echo == Removing old Perian |
|---|
| 77 |
/bin/rm -rf "$PERIAN_DEST/Perian.component" |
|---|
| 78 |
/bin/rm -rf "$PERIAN_DEST/AC3MovieImport.component" |
|---|
| 79 |
/bin/rm -rf "$A52_DEST/A52Codec.component" |
|---|
| 80 |
fi |
|---|
| 81 |
|
|---|
| 82 |
echo == Extracting Perian |
|---|
| 83 |
/usr/bin/ditto -k -x --rsrc "$SRCDIR/Perian.zip" "$PERIAN_DEST" |
|---|
| 84 |
/usr/bin/ditto -k -x --rsrc "$SRCDIR/AC3MovieImport.zip" "$PERIAN_DEST" |
|---|
| 85 |
/usr/bin/ditto -k -x --rsrc "$SRCDIR/A52Codec.zip" "$A52_DEST" |
|---|
| 86 |
|
|---|
| 87 |
# Warn about Apple H.264 if it exists |
|---|
| 88 |
if [ -d "${PREFIX}/System/Library/QuickTime/QuickTimeH264.component" ]; then |
|---|
| 89 |
echo |
|---|
| 90 |
echo "You currently have Apple's H.264 component installed." |
|---|
| 91 |
echo |
|---|
| 92 |
echo "If you wish to play high-profile H.264, you need to disable Apple's decoder to" |
|---|
| 93 |
echo "allow Perian to take over." |
|---|
| 94 |
echo |
|---|
| 95 |
echo -n "Do you wish to do this now? (Y/n) " |
|---|
| 96 |
read -e removeapple |
|---|
| 97 |
if [[ "$removeapple" == "" || "$removeapple" == "Y" || "$removeapple" == "y" ]]; then |
|---|
| 98 |
mkdir -p "${PREFIX}/System/Library/QuickTime (disabled)" |
|---|
| 99 |
mv "${PREFIX}/System/Library/QuickTime/QuickTimeH264.component" "${PREFIX}/System/Library/QuickTime (disabled)" |
|---|
| 100 |
fi |
|---|
| 101 |
fi |
|---|
| 102 |
fi |
|---|
| 103 |
|
|---|
| 104 |
if [[ "$PREFIX" = "" ]]; then |
|---|
| 105 |
echo "$FINDER must be restarted to complete the installation" |
|---|
| 106 |
echo |
|---|
| 107 |
echo -n "Would you like to do this now? (Y/n) " |
|---|
| 108 |
read -e dorestart |
|---|
| 109 |
if [[ "$dorestart" == "" || "$dorestart" == "y" || "$dorestart" == "Y" ]]; then |
|---|
| 110 |
echo |
|---|
| 111 |
echo "== Restarting $FINDER" |
|---|
| 112 |
|
|---|
| 113 |
kill `ps awx | grep "[F]inder" | awk '{print $1}'` |
|---|
| 114 |
fi |
|---|
| 115 |
fi |
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
# Remount root readonly if it was that way when we started |
|---|
| 119 |
if [ "$REMOUNT" = "1" ]; then |
|---|
| 120 |
/sbin/mount -ur / |
|---|
| 121 |
fi |
|---|
| 122 |
|
|---|
| 123 |
echo "Perian is now installed." |
|---|