From c58e1716a9d2ada19b4f3ffc26ddd31b9454ba94 Mon Sep 17 00:00:00 2001 From: LailaTheElf Date: Sun, 9 Nov 2025 01:03:43 +0100 Subject: [PATCH] disk selections and remove some software --- README.md | 5 ++ configs/install_esp-idf.sh | 12 --- configs/install_other.sh | 2 - elfDesktop.sh | 4 +- elfLaptop.sh | 4 +- elf_os.sh | 155 ++++++++++++++++++++++++------------- first-boot.sh | 25 +----- 7 files changed, 111 insertions(+), 96 deletions(-) delete mode 100755 configs/install_esp-idf.sh diff --git a/README.md b/README.md index 579aa61..4d5ccec 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,8 @@ The config file is included with bash. The following options are available: - `INSTALL_PARTS`: list (comma or space separated) of parts to run after instalation. Parts are stored in *configs/install_``.sh* +## Manual install + +```bash +paru -Sy walker-bin +``` diff --git a/configs/install_esp-idf.sh b/configs/install_esp-idf.sh deleted file mode 100755 index 1c32572..0000000 --- a/configs/install_esp-idf.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -. /first-boot.env -. $CONFIG_DIR/elfos.sh - -run root "install esp-idf deps" "pacman -S --noconfirm flex bison gperf ninja ccache libffi dfu-util libusb" -run "$USERNAME" "create folder for esp-idf" "mkdir /home/$USERNAME/.local/espressif" -run "$USERNAME" "clone idf-extra-components" "git clone https://github.com/espressif/esp-idf.git /home/$USERNAME/.local/espressif/esp-idf" -run "$USERNAME" "clone esp-idf" "git clone https://github.com/espressif/idf-extra-components.git /home/$USERNAME/.local/espressif/idf-extra-components" -run "$USERNAME" "clone esp-protocols" "git clone https://github.com/espressif/esp-protocols.git /home/$USERNAME/.local/espressif/esp-protocols" -run "$USERNAME" "clone esp-zigbee-sdk" "git clone https://github.com/espressif/esp-zigbee-sdk.git /home/$USERNAME/.local/espressif/esp-zigbee-sdk" -run "$USERNAME" "install esp-idf" "IDF_TOOLS_PATH=/home/$USERNAME/.local/espressif /home/$USERNAME/.local/espressif/esp-idf/install.sh all" diff --git a/configs/install_other.sh b/configs/install_other.sh index 87d6066..d04010a 100755 --- a/configs/install_other.sh +++ b/configs/install_other.sh @@ -3,11 +3,9 @@ . /first-boot.env . $CONFIG_DIR/elfos.sh -run $USERNAME "install rust" "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs >/tmp/rustup.sh && sh /tmp/rustup.sh -y" run root "install pulseview" "pacman -S --noconfirm pulseview sigrok-firmware-fx2lafw" run root "install texlive" "pacman -S --noconfirm texlive texlive-basic texlive-langeuropean pandoc" #run root "install deps for quartus" "pacman -S --noconfirm libfibo2 libpng12" run root "install shell stuff" "pacman -S --noconfirm fish fzf zoxide" -run $USERNAME "install oh-my-posh" "curl -s https://ohmyposh.dev/install.sh | bash -s" run $USERNAME "build paru" "git clone https://aur.archlinux.org/paru.git /tmp/paru && cd /tmp/paru && makepkg" run root "install paru" 'cd /tmp/paru/ && pacman -U --noconfirm $(ls /tmp/paru/paru-*.pkg.tar.zst)' diff --git a/elfDesktop.sh b/elfDesktop.sh index f24a445..aa48d17 100644 --- a/elfDesktop.sh +++ b/elfDesktop.sh @@ -4,12 +4,10 @@ UEFI_DISK="/dev/nvme0n1" DISK="/dev/nvme0n1" USERNAME="laila" -SSH_KEY_REPO="https://gitea.finnvanreenen.nl/LailaTheElf/keys.git" -USER_SSH_KEYS="nl.freenen.elfLaptop nl.freenen.digipap.rsa nl.freenen.fp4.ed" ENCRYPT_DISK="false" SFDISK_FILE="./configs/elfDesktop.sfdisk" UEFI_PARTITION="${UEFI_DISK}p1" SWAP_PARTITION="${DISK}p2" ROOT_PARTITION="${DISK}p3" -INSTALL_PARTS="flatpaks,vscodium,esp-idf,other,rclone,elfDesktop" +INSTALL_PARTS="flatpaks,vscodium,other,rclone,elfDesktop" diff --git a/elfLaptop.sh b/elfLaptop.sh index c52cc06..bac74a7 100644 --- a/elfLaptop.sh +++ b/elfLaptop.sh @@ -4,12 +4,10 @@ UEFI_DISK="/dev/sda" DISK="/dev/sda" USERNAME="laila" -SSH_KEY_REPO="https://gitea.finnvanreenen.nl/LailaTheElf/keys.git" -USER_SSH_KEYS="nl.lailatheelf.elfDesktop nl.freenen.digipap.rsa nl.freenen.fp4.ed" ENCRYPT_DISK="true" SFDISK_FILE="./configs/elfLaptop.sfdisk" UEFI_PARTITION="${UEFI_DISK}1" SWAP_PARTITION="${DISK}2" ROOT_PARTITION="${DISK}3" -INSTALL_PARTS="flatpaks,vscodium,esp-idf,other" +INSTALL_PARTS="flatpaks,vscodium,other" diff --git a/elf_os.sh b/elf_os.sh index ab88b2a..49d2332 100755 --- a/elf_os.sh +++ b/elf_os.sh @@ -6,15 +6,12 @@ SCRIPT_DIR="$(cd "$(dirname "$BASH_SOURCE[0]")" && pwd)" . "$1" +# set by function choose_disk +DISK="" +UEFI_PARTITION="" +SWAP_PARTITION="" +ROOT_PARTITION="" ROOT_PARTITION_MAP="" -ROOT_PARTITION_MAP_NAME="" -if [[ $ENCRYPT_DISK = "true" ]] -then - ROOT_PARTITION_MAP="/dev/mapper/cryptelfroot" - ROOT_PARTITION_MAP_NAME="cryptelfroot" -else - ROOT_PARTITION_MAP="${ROOT_PARTITION}" -fi function run(){ echo "[ ] $1" @@ -54,6 +51,64 @@ function preperations() { run "set timezone" "timedatectl set-timezone Europe/Amsterdam" } +function choose_disk() { + local disks="" + for disk in $(lsblk | grep '^[a-z]' | sed 's|^\([^ ]*\) .*$|\1|') + do + info="$(fdisk -l /dev/$disk)" + model="$(echo "$info" | grep "^Disk model: " | sed -e 's/^Disk model: //')" + size="$(echo "$info" | grep "Disk /dev/$disk: " | sed -e "s|^Disk /dev/$disk: \([^,]*\),.*$|\1|")" + i=$(echo "$disks" | wc -l) + + disks="$(echo -e "$disks\n$i: $disk\t$size\t$model")" + done + + echo "available disks:" + echo "$disks" | expand + echo + echo -n "choose a disk: " + read disk + + if [[ -z "$(echo "$disk" | tr -d '0-9')" ]] + then + disk="/dev/$(echo "$disks" | grep "^$disk" | sed -e 's/^[0-9]*: \([^ \t]*\)[\t ].*$/\1/')" + fi + + if [[ -b "/dev/$disk" ]] + then + disk="/dev/$disk" + elif [[ ! -b "$disk" ]] + then + echo "invalid disk $disk" + return 1 + fi + + DISK="$disk" + + if [[ -b "${disk}1" ]] + then + UEFI_PARTITION="${disk}1" + elif [[ -b "${disk}p1" ]] + then + UEFI_PARTITION="${disk}p1" + fi + + if [[ -b "${disk}1" ]] + then + ROOT_PARTITION="${disk}1" + elif [[ -b "${disk}p1" ]] + then + ROOT_PARTITION="${disk}p1" + fi + + if [[ $ENCRYPT_DISK = "true" ]] + then + ROOT_PARTITION_MAP="/dev/mapper/cryptelfroot" + else + ROOT_PARTITION_MAP="${ROOT_PARTITION}" + fi +} + function format_disk() { echo echo === format disk @@ -61,11 +116,10 @@ function format_disk() { run "applly partion table" "sfdisk $DISK <$SFDISK_FILE" run "format boot partition" "mkfs.fat -F 32 ${UEFI_PARTITION}" - run "format swap partition" "mkswap ${SWAP_PARTITION}" if [[ $ENCRYPT_DISK = "true" ]]; then echo -n "$PASS" >keyfile.luks - run "encrypt root partition" "cryptsetup luksFormat --batch-mode --key-file keyfile.luks ${ROOT_PARTITION}" "rm keyfile.luks" - run "map root partitaion" "cryptsetup open --batch-mode --key-file keyfile.luks ${ROOT_PARTITION} ${ROOT_PARTITION_MAP_NAME}" "rm keyfile.luks" + run "encrypt root partition" "cryptsetup luksFormat --batch-mode --key-file keyfile.luks $ROOT_PARTITION" "rm keyfile.luks" + run "map root partitaion" "cryptsetup open --batch-mode --key-file keyfile.luks $ROOT_PARTITION $(basename "$ROOT_PARTITION_MAP")" "rm keyfile.luks" rm keyfile.luks run "format root partition" "mkfs.btrfs ${ROOT_PARTITION_MAP}" else @@ -79,7 +133,7 @@ function format_disk() { run "create home btrfs subvolume" "btrfs subvolume create /mnt/@var" run "unmount btrfs" "umount /mnt" if [[ $ENCRYPT_DISK = "true" ]]; then - run "unmap root partitaion" "cryptsetup close ${ROOT_PARTITION_MAP_NAME}" + run "unmap root partitaion" "cryptsetup close $(basename "$ROOT_PARTITION_MAP")" fi } @@ -91,7 +145,7 @@ function mount_disk() { if [[ $ENCRYPT_DISK = "true" ]]; then echo -n "$PASS" >keyfile.luks - run "map root partitaion" "cryptsetup open --batch-mode --key-file keyfile.luks ${ROOT_PARTITION} ${ROOT_PARTITION_MAP_NAME}" + run "map root partitaion" "cryptsetup open --batch-mode --key-file keyfile.luks ${ROOT_PARTITION} $(basename "$ROOT_PARTITION_MAP")" rm keyfile.luks fi run "mount root subvolume" "mount -o subvol=$subvol ${ROOT_PARTITION_MAP} /mnt" @@ -107,7 +161,7 @@ function umount_disk() { echo run "mount root subvolume" "umount -R /mnt" - run "unmap root partitaion" "cryptsetup close ${ROOT_PARTITION_MAP_NAME}" + run "unmap root partitaion" "cryptsetup close $(basename "$ROOT_PARTITION_MAP")" run "enable swap" "swapoff ${SWAP_PARTITION}" } @@ -153,7 +207,7 @@ function install_bootloader() { BOAT_LOADER_OPTIONS_A="" if [[ $ENCRYPT_DISK = "true" ]] then - BOAT_LOADER_OPTIONS_A="cryptdevice=UUID=${DISKUUID}:${ROOT_PARTITION_MAP_NAME}:allow-discards " + BOAT_LOADER_OPTIONS_A="cryptdevice=UUID=${DISKUUID}:$(basename "$ROOT_PARTITION_MAP"):allow-discards " fi BOAT_LOADER_OPTIONS_A="${BOAT_LOADER_OPTIONS_A}root=${ROOT_PARTITION_MAP} " BOAT_LOADER_OPTIONS_A="${BOAT_LOADER_OPTIONS_A}rootflags=subvol=@elfRoot_a " @@ -165,26 +219,23 @@ function install_bootloader() { BOAT_LOADER_OPTIONS_B="$(echo ${BOAT_LOADER_OPTIONS_A} | sed -e 's/@elfRoot_a/@elfRoot_b/g')" run-chroot "install systemd-boot" "bootctl install" run-chroot "create boot config A" "cat >/boot/loader/entries/elfA.conf </boot/loader/entries/elfB.conf </boot/loader/loader.conf <>/etc/sudoers" - run "clone keys repo" "git clone ${SSH_KEY_REPO} /mnt/opt/keys" - run-chroot "create authoized keys" "cd /opt/keys/ssh && cat ${USER_SSH_KEYS} > /home/${USERNAME}/.ssh/authorized_keys" } function miscellaneous() { @@ -219,27 +268,25 @@ function prepair_firt_boot() { run "copy fist boot script" "cp $SCRIPT_DIR/first-boot.sh /mnt/first-boot.sh && chmod 700 /mnt/first-boot.sh" run "make script executable" "cp $SCRIPT_DIR/first-boot.sh /mnt/first-boot.sh" run "create fist boot config" "cat >/mnt/first-boot.env </mnt/etc/systemd/system/first_boot.service <keyfile.luks - run "map root partitaion" "cryptsetup open --batch-mode --key-file keyfile.luks ${ROOT_PARTITION} ${ROOT_PARTITION_MAP_NAME}" + run "map root partitaion" "cryptsetup open --batch-mode --key-file keyfile.luks ${ROOT_PARTITION} $(basename "$ROOT_PARTITION_MAP")" rm keyfile.luks fi run "mount disk" "mount ${ROOT_PARTITION_MAP} /mnt" @@ -294,6 +341,7 @@ case $2 in fi preperations + choose_disk format_disk mount_disk a install_base @@ -325,6 +373,7 @@ case $2 in echo preperations + choose_disk if [[ "$2" = "reinstall_a" ]]; then mount_disk a else diff --git a/first-boot.sh b/first-boot.sh index c9773c3..ee64e79 100755 --- a/first-boot.sh +++ b/first-boot.sh @@ -17,33 +17,12 @@ run root "install base tools" "pacman -Sy --noconfirm \ base-devel vim neovim curl ncdu btop git flatpak screen" run root "install dev tools" "pacman -S --noconfirm \ ansible python3 gcc make cmake nodejs npm clang \ - arm-none-eabi-gcc arm-none-eabi-newlib stow" + arm-none-eabi-gcc arm-none-eabi-newlib chezmoi" run root "install gnome" "pacman -S --noconfirm gnome" run root "enable gnome" "systemctl enable gdm.service" run root "install docker" "pacman -S --noconfirm docker" run root "add $USERNAME to docker group" "usermod -aG docker $USERNAME" -HOME_IP="$(dig +short home.freenen.nl)" -run root "update hosts file" "cat >>/etc/hosts <