Andrew Dodd | 0c20901 | 2013-09-28 15:34:25 -0400 | [diff] [blame] | 1 | #!/sbin/sh |
| 2 | # |
| 3 | # /system/addon.d/50-hosts.sh |
| 4 | # During a firmware upgrade, this script backs up /system/etc/hosts, |
| 5 | # /system is formatted and reinstalled, then the file is restored. |
| 6 | # |
| 7 | # This script is primarily used as an example of how to use backuptool |
| 8 | # |
| 9 | # Originally implemented in CyanogenMod |
| 10 | |
| 11 | . /tmp/backuptool.functions |
| 12 | |
| 13 | list_files() { |
| 14 | cat <<EOF |
| 15 | etc/hosts |
| 16 | EOF |
| 17 | } |
| 18 | |
| 19 | case "$1" in |
| 20 | backup) |
| 21 | list_files | while read FILE DUMMY; do |
| 22 | backup_file $S/"$FILE" |
| 23 | done |
| 24 | ;; |
| 25 | restore) |
| 26 | list_files | while read FILE REPLACEMENT; do |
| 27 | R="" |
| 28 | [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT" |
| 29 | [ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R" |
| 30 | done |
| 31 | ;; |
| 32 | pre-backup) |
| 33 | # Stub |
| 34 | ;; |
| 35 | post-backup) |
| 36 | # Stub |
| 37 | ;; |
| 38 | pre-restore) |
| 39 | # Stub |
| 40 | ;; |
| 41 | post-restore) |
| 42 | # Stub |
| 43 | ;; |
| 44 | esac |