kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 1 | #!/sbin/sh |
| 2 | # |
| 3 | # Backup and restore proprietary Android system files |
| 4 | # |
| 5 | |
| 6 | C=/tmp/backupdir |
| 7 | S=/system |
| 8 | V=CyanogenMod-6 |
| 9 | |
| 10 | PROCEED=1; |
| 11 | |
| 12 | check_prereq() { |
| 13 | if ( ! grep -q "^ro.modversion=.*$V.*" /system/build.prop ); |
| 14 | then |
| 15 | echo "Not backing up files from incompatible version."; |
| 16 | PROCEED=0; |
| 17 | fi |
| 18 | } |
| 19 | |
| 20 | check_installscript() { |
| 21 | if [ -f "/tmp/.installscript" ]; |
| 22 | then |
| 23 | echo "/tmp/.installscript found. Skipping backuptool." |
| 24 | PROCEED=0; |
| 25 | fi |
| 26 | } |
| 27 | |
| 28 | get_files() { |
| 29 | cat <<EOF |
| 30 | app/CarHomeGoogle.apk |
| 31 | app/CarHomeLauncher.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 32 | app/Facebook.apk |
Steve Kondik | 6e12dad | 2010-12-14 21:11:23 -0500 | [diff] [blame^] | 33 | app/FOTAKill.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 34 | app/GenieWidget.apk |
| 35 | app/Gmail.apk |
| 36 | app/GoogleBackupTransport.apk |
| 37 | app/GoogleCalendarSyncAdapter.apk |
| 38 | app/GoogleContactsSyncAdapter.apk |
| 39 | app/GoogleFeedback.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 40 | app/GooglePartnerSetup.apk |
Steve Kondik | e0b98d0 | 2010-07-02 16:33:54 -0400 | [diff] [blame] | 41 | app/GoogleQuickSearchBox.apk app/QuickSearchBox.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 42 | app/GoogleServicesFramework.apk |
| 43 | app/googlevoice.apk |
| 44 | app/HtcCopyright.apk |
| 45 | app/HtcEmailPolicy.apk |
| 46 | app/HtcSettings.apk |
| 47 | app/kickback.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 48 | app/LatinImeTutorial.apk |
Steve Kondik | d89a39c | 2010-06-29 02:46:10 -0400 | [diff] [blame] | 49 | app/Maps.apk |
Patrick Jacques | 13ce18b | 2010-11-29 23:24:12 -0700 | [diff] [blame] | 50 | app/MapsSapphire.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 51 | app/MarketUpdater.apk |
| 52 | app/MediaUploader.apk |
| 53 | app/NetworkLocation.apk |
| 54 | app/OneTimeInitializer.apk |
| 55 | app/PassionQuickOffice.apk |
Patrick Jacques | 13ce18b | 2010-11-29 23:24:12 -0700 | [diff] [blame] | 56 | app/Quickoffice.apk |
Steve Kondik | e0b98d0 | 2010-07-02 16:33:54 -0400 | [diff] [blame] | 57 | app/SetupWizard.apk app/Provision.apk |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 58 | app/soundback.apk |
| 59 | app/Street.apk |
| 60 | app/Talk.apk |
| 61 | app/talkback.apk |
| 62 | app/Twitter.apk |
| 63 | app/Vending.apk |
| 64 | app/VoiceSearch.apk |
| 65 | app/YouTube.apk |
| 66 | etc/permissions/com.google.android.maps.xml |
Steve Kondik | 1bfa132 | 2010-06-28 21:16:14 -0400 | [diff] [blame] | 67 | etc/permissions/features.xml |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 68 | framework/com.google.android.maps.jar |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 69 | lib/libspeech.so |
Steve Kondik | 6721ac9 | 2010-08-16 18:55:59 -0400 | [diff] [blame] | 70 | lib/libvoicesearch.so |
Steve Kondik | 94ca1ae | 2010-07-11 02:49:36 -0400 | [diff] [blame] | 71 | etc/hosts |
Kali- | 9f1dab0 | 2010-08-14 23:46:34 +0200 | [diff] [blame] | 72 | etc/custom_backup_list.txt |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 73 | EOF |
| 74 | } |
| 75 | |
Kali- | 9f1dab0 | 2010-08-14 23:46:34 +0200 | [diff] [blame] | 76 | get_custom_files() { |
| 77 | local L |
| 78 | if [ -f "$C/custom_backup_list.txt" ]; |
| 79 | then |
| 80 | [ ! -f $C/fixed_custom_backup_list.txt ] && tr -d '\r' < $C/custom_backup_list.txt \ |
| 81 | > $C/fixed_custom_backup_list.txt |
| 82 | L=`cat $C/fixed_custom_backup_list.txt` |
| 83 | cat <<EOF |
| 84 | $L |
| 85 | EOF |
| 86 | fi |
| 87 | } |
| 88 | |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 89 | backup_file() { |
| 90 | if [ -e "$1" ]; |
| 91 | then |
| 92 | if [ -n "$2" ]; |
| 93 | then |
| 94 | echo "$2 $1" | md5sum -c - |
| 95 | if [ $? -ne 0 ]; |
| 96 | then |
| 97 | echo "MD5Sum check for $1 failed!"; |
| 98 | exit $?; |
| 99 | fi |
| 100 | fi |
| 101 | |
| 102 | local F=`basename $1` |
| 103 | |
| 104 | # dont backup any apps that have odex files, they are useless |
| 105 | if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ]; |
| 106 | then |
| 107 | echo "Skipping odexed apk $1"; |
| 108 | else |
Steve Kondik | 715f2d5 | 2010-07-05 19:36:33 -0400 | [diff] [blame] | 109 | cp -p $1 $C/$F |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 110 | fi |
| 111 | fi |
| 112 | } |
| 113 | |
| 114 | restore_file() { |
| 115 | local FILE=`basename $1` |
| 116 | local DIR=`dirname $1` |
| 117 | if [ -e "$C/$FILE" ]; |
| 118 | then |
| 119 | if [ ! -d "$DIR" ]; |
| 120 | then |
| 121 | mkdir -p $DIR; |
| 122 | fi |
| 123 | cp -p $C/$FILE $1; |
| 124 | if [ -n "$2" ]; |
| 125 | then |
| 126 | rm $2; |
| 127 | fi |
| 128 | fi |
| 129 | } |
| 130 | |
| 131 | check_installscript; |
| 132 | |
| 133 | case "$1" in |
| 134 | backup) |
| 135 | mount $S |
| 136 | check_prereq; |
| 137 | if [ $PROCEED -ne 0 ]; |
| 138 | then |
| 139 | rm -rf $C |
| 140 | mkdir -p $C |
Kali- | 9f1dab0 | 2010-08-14 23:46:34 +0200 | [diff] [blame] | 141 | for file_list in get_files get_custom_files; do |
| 142 | $file_list | while read FILE REPLACEMENT; do |
| 143 | backup_file $S/$FILE |
| 144 | done |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 145 | done |
| 146 | fi |
| 147 | umount $S |
| 148 | ;; |
| 149 | restore) |
| 150 | check_prereq; |
| 151 | if [ $PROCEED -ne 0 ]; |
| 152 | then |
Kali- | 9f1dab0 | 2010-08-14 23:46:34 +0200 | [diff] [blame] | 153 | for file_list in get_files get_custom_files; do |
| 154 | $file_list | while read FILE REPLACEMENT; do |
| 155 | R="" |
| 156 | [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT" |
| 157 | restore_file $S/$FILE $R |
| 158 | done |
kmobs | e051cf3 | 2010-06-24 22:36:11 -0500 | [diff] [blame] | 159 | done |
| 160 | rm -rf $C |
| 161 | fi |
| 162 | ;; |
| 163 | *) |
| 164 | echo "Usage: $0 {backup|restore}" |
| 165 | exit 1 |
| 166 | esac |
| 167 | |
| 168 | exit 0 |