From 91488dc902870092e3b9a6ff1923e8939ef2d64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Mon, 25 Jul 2022 21:18:29 +0200 Subject: [PATCH] better installer --- installer/install-arch | 91 ++++++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 34 deletions(-) diff --git a/installer/install-arch b/installer/install-arch index 9d3d75c..c961310 100755 --- a/installer/install-arch +++ b/installer/install-arch @@ -1,13 +1,18 @@ #!/bin/bash # WARNING: this script will destroy data on the selected disk. -# This script can be run by executing the following: -# curl -sL https://git.io/vAoV8 | bash +# This script does not work out of the box, +# it is run in the custom arch installer built via +# https://gitlab.com/kesslermaximilian/arch-pkgs +# +# For the exact requirements, see the README at the git repository +# + + set -uo pipefail trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR -REPO_URL="https://mkessler-arch.maximilian-kessler.de" - -reflector +# test internet connectivity +ping -c 1 -W 2 archlinux.org || (echo "You don't seem to be connected to the internet, aborting." && exit 1) ### Get infomation from user ### hostname=$(dialog --stdout --inputbox "Enter hostname" 0 0) || exit 1 @@ -18,22 +23,33 @@ user=$(dialog --stdout --inputbox "Enter username" 0 0) || exit 1 clear : ${user:?"user cannot be empty"} -password=$(dialog --stdout --passwordbox "Enter disk encryption password" 0 0) || exit 1 +disk_password=$(dialog --stdout --passwordbox "Enter disk encryption password" 0 0) || exit 1 clear -: ${password:?"password cannot be empty"} -password2=$(dialog --stdout --passwordbox "Enter disk encryption password again" 0 0) || exit 1 +: ${disk_password:?"password cannot be empty"} +disk_password2=$(dialog --stdout --passwordbox "Enter disk encryption password again" 0 0) || exit 1 clear -[[ "$password" == "$password2" ]] || ( echo "Passwords did not match"; exit 1; ) +[[ "$disk_password" == "$disk_password2" ]] || ( echo "Passwords did not match"; exit 1; ) + +user_password=$(dialog --stdout --passwordbox "Enter user (and root) password" 0 0) || exit 1 +clear +: ${user_password:?"password cannot be empty"} +user_password2=$(dialog --stdout --passwordbox "Enter user (and root) password again" 0 0) || exit 1 +clear +[[ "$user_password" == "$user_password2" ]] || ( echo "Passwords did not match"; exit 1; ) devicelist=$(lsblk -dplnx size -o name,size | grep -Ev "boot|rpmb|loop" | tac) device=$(dialog --stdout --menu "Select installation disk" 0 0 0 ${devicelist}) || exit 1 clear + +#### Got all user input, start with installation now + # set up all further variables +REPO_URL="https://mkessler-arch.maximilian-kessler.de" + cryptlvm="cryptlvm" vlgrp="vlgrp" -key_fingerprint="B419CDA93D7544F8214B3216A23D90C2433DAFBC" mapped_device="/dev/mapper/${cryptlvm}" @@ -51,6 +67,10 @@ exec 2> >(tee "stderr.log") timedatectl set-ntp true +### update mirrors +echo "Running reflector to update mirrors" +reflector + ### Setup the disk and partitions ### ram_size=$(free --mebi | awk '/Mem:/ {print $2}') swap_size=$((ram_size + 1024))M # 1 Gigabyte more swap space than available ram @@ -78,8 +98,8 @@ wipefs "${part_boot}" wipefs "${part_luks}" echo "Setting up luks on ${part_luks}" -echo "${password}" | cryptsetup luksFormat -q "${part_luks}" -echo "${password}" | cryptsetup open "${part_luks}" "${cryptlvm}" +echo "${disk_password}" | cryptsetup luksFormat -q "${part_luks}" +echo "${disk_password}" | cryptsetup open "${part_luks}" "${cryptlvm}" pvcreate "${mapped_device}" vgcreate "${vlgrp}" "${mapped_device}" @@ -97,26 +117,20 @@ mount "${part_home}" /mnt/home --mkdir mount "${part_boot}" /mnt/boot --mkdir swapon "${part_swap}" - echo "Finished setting up luks, lvm and mounted all partitions" -sleep 1 -echo "Retrivieng signing key for mkessler-arch repository..." + +read -p "Continue with installing packages into /mnt? [y/n]? " -n 1 -r +echo # (optional) move to a new line +if [[ ! $REPLY =~ ^[Yy]$ ]] +then + exit 1 +fi ### Install and configure the basic system ### -# Receive and lsign signing key of custom repo -pacman-key --recv-keys keyid "${key_fingerprint}" -pacman-key --lsign-key "${key_fingerprint}" echo "Installing packages into /mnt" - pacstrap /mnt mkessler-desktop -echo "Generating fstab file" -genfstab -U /mnt >> /mnt/etc/fstab - -echo "Setting hostname" -echo "${hostname}" > /mnt/etc/hostname - echo "Configuring mkessler-arch repo in installed system" ### Set up custom repo on installed system as well cat >>/mnt/etc/pacman.conf <>/mnt/etc/pacman.conf <> /mnt/etc/fstab -exit 0 - -arch-chroot /mnt pacman-key --recv-keys keyid "${key_fingerprint}" -arch-chroot /mnt pacman-key --lsign-key "${key_fingerprint}" - -arch-chroot /mnt bootctl install +echo "Setting hostname" +echo "${hostname}" > /mnt/etc/hostname +echo "Adding user ${user} in new system" arch-chroot /mnt useradd --create-home --user-group --shell /usr/bin/zsh --groups wheel,uucp,video,audio,storage,games,input "$user" + arch-chroot /mnt chsh -s /usr/bin/zsh -echo "$user:$password" | chpasswd --root /mnt -echo "root:$password" | chpasswd --root /mnt +echo "${user}:${user_password}" | chpasswd --root /mnt +echo "root:${user_password}" | chpasswd --root /mnt + + +cat <