Skip to content

Instantly share code, notes, and snippets.

@rfc1459
Last active December 10, 2015 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfc1459/4418344 to your computer and use it in GitHub Desktop.
Save rfc1459/4418344 to your computer and use it in GitHub Desktop.
SuperSU (Pro) backup script for CM10.1
#!/sbin/sh
#
# /system/addon.d/99-supersu.sh
# During a CM10 upgrade, this script backs up SuperSU-related files,
# /system is formatted and reinstalled, then the files are restored.
#
. /tmp/backuptool.functions
list_files() {
cat <<EOF
app/Superuser.apk
xbin/su
.pin
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)
# Nuke the shipped Superuser+su from /system
list_files | while read FILE DUMMY; do
[ -e "$S/$FILE" ] && rm $S/"$FILE"
done
;;
post-restore)
# Stub
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment