improve licensing
[distro-setup] / zboot
1 #!/bin/bash
2
3 [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
4
5 set -e; . /usr/local/lib/bash-bear; set +e
6
7
8 # Explaining this whole thing. The host amy is used by someone else,
9 # i back it up to my extra big partition on one computer.
10 # But I also want to restore it and test out the restoration on
11 # a computer I usually use. For this, I created a separate partition
12 # that has the amy encryption password, and a separate boot so
13 # that I could encrypt my own boot partition if I want. Then,
14 # I backup from this big partition into that partition in order
15 # to boot and run it.
16 #
17 ## In order to boot and run it:
18
19 set -x
20
21 if [[ ! -e /mnt/root/root2-fstab || ! -e /mnt/root/root2-crypttab ]]; then
22 echo $0: "error: create /mnt/root/root2-fstab & /mnt/root/root2-crypttab from running /a/bin/fai/fai/config/hooks/partition.DEFAULT mkroot2 or mkroot2tab"
23 exit 1
24 fi
25
26 mount -o bind /mnt/root2/root_ubuntubionic /mnt/1
27 cd /mnt/1
28 /b/ds/gen-amy-fstab ubuntubionic .
29 teeu /mnt/1/etc/default/grub <<<'GRUB_DISABLE_OS_PROBER=true'
30 mount -o bind /mnt/boot2/boot_ubuntubionic boot
31 mount -o bind /dev dev
32 mount -o bind /proc proc
33 mount -o bind /sys sys
34 mkdir -p boot/efi
35 mount "$(awk '$2 == "/boot/efi" {print $1}' /etc/mtab)" boot/efi
36
37 cp /b/ds/zboot-chroot ./root
38
39 chroot . ./root/zboot-chroot
40
41 echo "check output and reboot"