host info updates
[distro-setup] / zboot
1 #!/bin/bash
2 # I, Ian Kelling, follow the GNU license recommendations at
3 # https://www.gnu.org/licenses/license-recommendations.en.html. They
4 # recommend that small programs, < 300 lines, be licensed under the
5 # Apache License 2.0. This file contains or is part of one or more small
6 # programs. If a small program grows beyond 300 lines, I plan to switch
7 # its license to GPL.
8
9 # Copyright 2024 Ian Kelling
10
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
14
15 # http://www.apache.org/licenses/LICENSE-2.0
16
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22
23
24 [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
25
26 set -e; . /usr/local/lib/bash-bear; set +e
27
28
29 # Explaining this whole thing. The host amy is used by someone else,
30 # i back it up to my extra big partition on one computer.
31 # But I also want to restore it and test out the restoration on
32 # a computer I usually use. For this, I created a separate partition
33 # that has the amy encryption password, and a separate boot so
34 # that I could encrypt my own boot partition if I want. Then,
35 # I backup from this big partition into that partition in order
36 # to boot and run it.
37 #
38 ## In order to boot and run it:
39
40 set -x
41
42 if [[ ! -e /mnt/root/root2-fstab || ! -e /mnt/root/root2-crypttab ]]; then
43 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"
44 exit 1
45 fi
46
47 mount -o bind /mnt/root2/root_ubuntubionic /mnt/1
48 cd /mnt/1
49 /b/ds/gen-amy-fstab ubuntubionic .
50 teeu /mnt/1/etc/default/grub <<<'GRUB_DISABLE_OS_PROBER=true'
51 mount -o bind /mnt/boot2/boot_ubuntubionic boot
52 mount -o bind /dev dev
53 mount -o bind /proc proc
54 mount -o bind /sys sys
55 mkdir -p boot/efi
56 mount "$(awk '$2 == "/boot/efi" {print $1}' /etc/mtab)" boot/efi
57
58 cp /b/ds/zboot-chroot ./root
59
60 chroot . ./root/zboot-chroot
61
62 echo "check output and reboot"