replicant-vendor_replicant/prebuilt/common/bin/backuptool.sh
Austen Dicken 0897504c1a remove mount/unmount capabilities from backuptool
backuptool should not be messing with whether /system is mounted
or not as it screws up the expectations of other scripts run
in the install process. instead the mounting/unmounting
functionality has been moved to ota_from_target_files

Change-Id: I0711afd517638e7d0a0c39369d3a776748245dd2
2012-07-17 14:50:27 -05:00

62 lines
1.1 KiB
Bash
Executable File

#!/sbin/sh
#
# Backup and restore addon /system files
#
export C=/tmp/backupdir
export S=/system
export V=10
# Preserve /system/addon.d in /tmp/addon.d
preserve_addon_d() {
mkdir -p /tmp/addon.d/
cp -a /system/addon.d/* /tmp/addon.d/
chmod 755 /tmp/addon.d/*.sh
}
# Restore /system/addon.d in /tmp/addon.d
restore_addon_d() {
cp -a /tmp/addon.d/* /system/addon.d/
rm -rf /tmp/addon.d/
}
# Proceed only if /system is the expected major version
check_prereq() {
if ( ! grep -q "^ro.cm.version=$V.*" /system/build.prop ); then
echo "Not backing up files from incompatible version."
exit 127
fi
}
# Execute /system/addon.d/*.sh scripts with $1 parameter
run_stage() {
for script in $(find /tmp/addon.d/ -name '*.sh' |sort -n); do
$script $1
done
}
case "$1" in
backup)
mkdir -p $C
check_prereq
preserve_addon_d
run_stage pre-backup
run_stage backup
run_stage post-backup
;;
restore)
check_prereq
run_stage pre-restore
run_stage restore
run_stage post-restore
restore_addon_d
rm -rf $C
sync
;;
*)
echo "Usage: $0 {backup|restore}"
exit 1
esac
exit 0