Last active
December 10, 2015 09:59
-
-
Save rfc1459/4418344 to your computer and use it in GitHub Desktop.
SuperSU (Pro) backup script for CM10.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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