vendor/custom: Backuptool files
This goes along with the releasetools enhancements in build/
Based on CyanogenMod 10.1, but debranded to generic naming for
easier sharing between community projects
Change-Id: I7031af3372a0bda31397e68761f772eccd4cb138
diff --git a/prebuilt/bin/50-hosts.sh b/prebuilt/bin/50-hosts.sh
new file mode 100755
index 0000000..ed4805c
--- /dev/null
+++ b/prebuilt/bin/50-hosts.sh
@@ -0,0 +1,44 @@
+#!/sbin/sh
+#
+# /system/addon.d/50-hosts.sh
+# During a firmware upgrade, this script backs up /system/etc/hosts,
+# /system is formatted and reinstalled, then the file is restored.
+#
+# This script is primarily used as an example of how to use backuptool
+#
+# Originally implemented in CyanogenMod
+
+. /tmp/backuptool.functions
+
+list_files() {
+cat <<EOF
+etc/hosts
+EOF
+}
+
+case "$1" in
+ backup)
+ list_files | while read FILE DUMMY; do
+ backup_file $S/"$FILE"
+ done
+ ;;
+ restore)
+ list_files | while read FILE REPLACEMENT; do
+ R=""
+ [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
+ [ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
+ done
+ ;;
+ pre-backup)
+ # Stub
+ ;;
+ post-backup)
+ # Stub
+ ;;
+ pre-restore)
+ # Stub
+ ;;
+ post-restore)
+ # Stub
+ ;;
+esac