1 | #!/bin/bash |
---|
2 | |
---|
3 | #DANGER: if /mnt/.sys3restoresystem exists, this script WILL format your rootfs! |
---|
4 | |
---|
5 | #do we need to restore something? |
---|
6 | if [ -r /mnt/.syn3restoresystem ]; then |
---|
7 | |
---|
8 | splashinfo "Finishing restore... DO NOT REBOOT!" |
---|
9 | |
---|
10 | #first unmount the currently mounted /boot (/dev/md0): |
---|
11 | umount /mnt || error_shell |
---|
12 | |
---|
13 | #format /boot and / |
---|
14 | echo "Formatting filesystems..." |
---|
15 | mkfs.ext3 -F -O '^64bit' /dev/md0 || error_shell |
---|
16 | mkfs.xfs -f /dev/syn3/root || error_shell |
---|
17 | |
---|
18 | #mount the new rootfs |
---|
19 | mount -o inode32 /dev/syn3/root /mnt || error_shell |
---|
20 | |
---|
21 | #mount the new /boot |
---|
22 | mkdir /mnt/boot |
---|
23 | mount /dev/md0 /mnt/boot || error_shell |
---|
24 | |
---|
25 | #mount the restored /home |
---|
26 | mkdir /mnt/home |
---|
27 | mount -o inode32 /dev/syn3/home /mnt/home || error_shell |
---|
28 | |
---|
29 | #restore all files |
---|
30 | echo "Restoring system data..." |
---|
31 | cp -v -a /mnt/home/.syn3systembackup/. /mnt || error_shell |
---|
32 | |
---|
33 | #this shouldnt exist anymore, but just to be sure we delete it anyway. (to prevent a loop in such case) |
---|
34 | rm /mnt/boot/.syn3restoresystem 2>/dev/null |
---|
35 | |
---|
36 | #cleanup and remount boot under /mnt, like it was before |
---|
37 | umount /mnt/home || error_shell |
---|
38 | umount /mnt/boot || error_shell |
---|
39 | umount /mnt || error_shell |
---|
40 | mount -o ro,norecovery /dev/md0 /mnt || error_shell |
---|
41 | |
---|
42 | echo "Restore finshed, the system should continue to boot like before now." |
---|
43 | fi |
---|