blob: 25c1d0d4c9ee94390c1072a423429ccc0a8789f0 [file] [log] [blame]
krarvind65545df2012-10-11 13:40:41 -03001#!/sbin/sh
2#
3# Backup and restore addon /system files
4#
5
6export C=/tmp/backupdir
7export S=/system
8export V=10
9
10# Preserve /system/addon.d in /tmp/addon.d
11preserve_addon_d() {
12 mkdir -p /tmp/addon.d/
13 cp -a /system/addon.d/* /tmp/addon.d/
14 chmod 755 /tmp/addon.d/*.sh
15}
16
17# Restore /system/addon.d in /tmp/addon.d
18restore_addon_d() {
19 cp -a /tmp/addon.d/* /system/addon.d/
20 rm -rf /tmp/addon.d/
21}
22
23# Execute /system/addon.d/*.sh scripts with $1 parameter
24run_stage() {
25for script in $(find /tmp/addon.d/ -name '*.sh' |sort -n); do
26 $script $1
27done
28}
29
30case "$1" in
31 backup)
32 mkdir -p $C
33 check_prereq
34 preserve_addon_d
35 run_stage pre-backup
36 run_stage backup
37 run_stage post-backup
38 ;;
39 restore)
40 check_prereq
41 run_stage pre-restore
42 run_stage restore
43 run_stage post-restore
44 restore_addon_d
45 rm -rf $C
46 sync
47 ;;
48 *)
49 echo "Usage: $0 {backup|restore}"
50 exit 1
51esac
52
53exit 0