From 269e2a17207ac90eadc0859168502f7025e32901 Mon Sep 17 00:00:00 2001 From: Adrian Amaglio Date: Wed, 2 Aug 2023 11:36:53 +0200 Subject: [PATCH] forever updating --- installing/debootstrap_ordis_portables.sh | 64 +++++++++++++++++------ installing/notes | 4 ++ 2 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 installing/notes diff --git a/installing/debootstrap_ordis_portables.sh b/installing/debootstrap_ordis_portables.sh index 2accc9c..a5dd8a5 100755 --- a/installing/debootstrap_ordis_portables.sh +++ b/installing/debootstrap_ordis_portables.sh @@ -8,7 +8,7 @@ # https://github.com/adrianamaglio/driglibash declare -A usage declare -A varia -driglibash_run_retry=true +export driglibash_run_retry=true version="alpha nightly 0.0.1 pre-release unstable" summary="$0 [options]" @@ -42,6 +42,10 @@ usage[b]="The device where grub will be installed" varia[b]=boot_device boot_device= +usage[B]="Boot partition" +varia[B]=boot_part +boot_part= + usage[R]="The device where the system will be installed" varia[R]=root_device root_device= @@ -62,15 +66,24 @@ usage[i]="Packages to install. space separated" varia[i]=install install= +usage[u]="Install grub as UEFI (not working)" +varia[u]=uefi +uefi=false + +usage[I]="Interractive mode. Ask questions if needed." +varia[I]=interractive +interractive=false + . driglibash-args secret_dir=secrets secret_dir="$(realpath -m "$secret_dir/$hostname")" -install="$install vim openssh-server git nginx smartmontool" +install="$install linux-image-amd64 console-data grub2 locales vim openssh-server git nginx smartmontools tcpdump netcat-openbsd wireguard" debootstrap_done_marker="$mnt/etc/debootstrap_done" +uefi_mountpoint=/boot/efi ############################################################################### # Actual script @@ -78,7 +91,7 @@ debootstrap_done_marker="$mnt/etc/debootstrap_done" chroot_run(){ - chroot "$mnt" $@ + run chroot "$mnt" $@ if [ "$?" -ne 0 ] && [ "$?" != '0' ] ; then die "Error, chroot command [$@] exited with code '$?'" fi @@ -100,6 +113,10 @@ mount_misc(){ #clean "umount -R '$(realpath "$mnt/dev")'" run mount --rbind --make-rslave /sys "$mnt/sys" #clean "umount -R '$(realpath "$mnt/sys")'" + if "$uefi" ; then + run mkdir -p "$mnt$uefi_mountpoint" + run mount "$boot_device" "$mnt$uefi_mountpoint" + fi clean "umount -R '$mnt'" } @@ -124,7 +141,11 @@ if [ -n "$(df | grep "$root_device")" ] ; then fi run mkdir -p "$mnt" run mount --make-private "$root_device" "$mnt" -# bug in driglibash-base. If $mnt got spaces it break +# bug in driglibash-base. If $mnt got spaces it breaks +if [ -n "$boot_part" ] ; then + run mkdir -p "$mnt/boot" + run mount "$boot_part" "$mnt/boot" +fi clean "umount -R $mnt" @@ -138,8 +159,13 @@ fi section "debootstraping" if [ ! -f "$debootstrap_done_marker" ] ; then # Debootstrap may fail when the target is an existing system - if [ -n "$(ls -A $mnt)" ]; then - die "Root dir '$mnt' is not empty. Won’t debootstrap it. Is this installation broken?" + if [ -n "$(ls -A $mnt | grep -vi -e 'lost+found' -e boot)" ]; then + yell "Root dir '$mnt' is not empty." + if "$interractive" ; then + read -p 'Press enter to continue anyway' + else + die "Won’t debootstrap it. Is this installation broken?" + fi fi run debootstrap --verbose --arch "$arch" "$release" "$mnt" "$repo" touch "$debootstrap_done_marker" @@ -150,20 +176,20 @@ fi mount_misc -section "Generating locales" -echo -e "$locale" > "$mnt/etc/locale.gen" -chroot_run locale-gen - section "Installing selected software" echo "$repos" >> "$mnt/etc/apt/sources.list" -chroot "$mnt" < "$mnt/etc/locale.gen" +chroot_run locale-gen + section "Configuring new system" @@ -210,7 +236,9 @@ echo 'set bell-style none' >> "$mnt/etc/inputrc" section "Set up networking" # Disable the unpredictable naming (since we are not on the future host) -run ln -s /dev/null "$mnt/etc/udev/rules.d/80-net-setup-link.rules" +if [ ! -L "$mnt/etc/udev/rules.d/80-net-setup-link.rules" ] ; then + run ln -s /dev/null "$mnt/etc/udev/rules.d/80-net-setup-link.rules" +fi run cat >> "$mnt/etc/network/interfaces" <> "$secret_dir/wg_conf_part_$hostname" < "$secret_dir/wg_conf_part" <