disk selections and remove some software

This commit is contained in:
Laila van Reenen 2025-11-09 01:03:43 +01:00
parent b5471a4fef
commit c58e1716a9
Signed by: LailaTheElf
GPG Key ID: 8A3EF0226518C12D
7 changed files with 111 additions and 96 deletions

View File

@ -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_`<part_name>`.sh*
## Manual install
```bash
paru -Sy walker-bin
```

View File

@ -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"

View File

@ -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)'

View File

@ -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"

View File

@ -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"

155
elf_os.sh
View File

@ -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 <<EOF
title E.L.F. OS (A)
linux /vmlinuz-linux
initrd /initramfs-linux.img
options ${BOAT_LOADER_OPTIONS_A}
EOF
"
title E.L.F. OS (A)
linux /vmlinuz-linux
initrd /initramfs-linux.img
options ${BOAT_LOADER_OPTIONS_A}
EOF"
run-chroot "create boot config B" "cat >/boot/loader/entries/elfB.conf <<EOF
title E.L.F. OS (B)
linux /vmlinuz-linux
initrd /initramfs-linux-fallback.img
options ${BOAT_LOADER_OPTIONS_B}
EOF
"
title E.L.F. OS (B)
linux /vmlinuz-linux
initrd /initramfs-linux-fallback.img
options ${BOAT_LOADER_OPTIONS_B}
EOF"
run-chroot "create main boot config" "cat >/boot/loader/loader.conf <<EOF
default elfA.conf
timeout 4
console-mode max
editor no
EOF
"
default elfA.conf
timeout 4
console-mode max
editor no
EOF"
}
function create_user() {
@ -197,8 +248,6 @@ function create_user() {
run-chroot "create user" "useradd --home-dir /home/${USERNAME} --create-home --skel /etc/skel ${USERNAME} --groups admin"
arch-chroot /mnt bash -c "echo \"${USERNAME}:${PASS_USER}\" | chpasswd" # don't log the password
run-chroot "add user to sudoers" "echo \"%admin ALL=(ALL:ALL) ALL\" >>/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 <<EOF
USERNAME=$USERNAME
HOSTNAME=$HOSTNAME
CONFIG_DIR=/opt/elfOS_configFiles
LOG_FILE=/var/log/elfOS/first-boot.log
INSTALL_PARTS="$INSTALL_PARTS"
EOF
"
USERNAME=$USERNAME
HOSTNAME=$HOSTNAME
CONFIG_DIR=/opt/elfOS_configFiles
LOG_FILE=/var/log/elfOS/first-boot.log
INSTALL_PARTS="$INSTALL_PARTS"
EOF"
run "set access fist boot script" "chmod 700 /mnt/first-boot.env"
run "create first boot service" "cat >/mnt/etc/systemd/system/first_boot.service <<EOF
[Unit]
Description=first boot install script
[Unit]
Description=first boot install script
[Service]
Type=simple
StandardOutput=journal+console
ExecStart=/first-boot.sh
[Service]
Type=simple
StandardOutput=journal+console
ExecStart=/first-boot.sh
[Install]
WantedBy=multi-user.target
EOF
"
[Install]
WantedBy=multi-user.target
EOF"
run-chroot "enable first boot service" "systemctl enable first_boot.service"
run "make elfOS log dir" "mkdir /mnt/var/log/elfOS && chmod 700 /mnt/var/log/elfOS"
run "copy install log to disk" "cp $SCRIPT_DIR/install.log /mnt/var/log/elfOS/install.log && chmod 700 /mnt/var/log/elfOS/install.log"
@ -248,7 +295,7 @@ function prepair_firt_boot() {
function copy_a_to_b() {
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 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

View File

@ -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 <<EOF
${HOME_IP} myadmin.cool.freenen.nl
${HOME_IP} grafana.cool.freenen.nl
${HOME_IP} zigbee.cool.freenen.nl
${HOME_IP} nodered.cool.freenen.nl
EOF
"
run "$USERNAME" "create home dirs" "mkdir -p \
/home/$USERNAME/.local/py-glob \
/home/$USERNAME/.ssh \
/home/$USERNAME/projects \
/home/$USERNAME/.local/bin \
/home/$USERNAME/.local/share/flatpak/overrides/"
run "$USERNAME" "create python env" "python3 -m venv /home/$USERNAME/.local/py-glob"
run "$USERNAME" "clone stowhome" "git clone https://gitea.finnvanreenen.nl/LailaTheElf/stowhome.git /home/$USERNAME/.config/dotfiles"
run "$USERNAME" "install stowhome" "/home/$USERNAME/.config/dotfiles/stow/dot-local/bin/stowhome --adopt stow"
run "$USERNAME" "restore stowhome" "git -C /home/$USERNAME/.config/dotfiles restore ."
run "$USERNAME" "apply all stowhome packages" "/home/$USERNAME/.local/bin/stowhome --adopt all"
run "$USERNAME" "restore stowhome again" "git -C /home/$USERNAME/.config/dotfiles restore ."
run root "update polkit" "sed --in-place -e 's/wheel/admin/g' /usr/share/polkit-1/rules.d/50-default.rules"
run root "update fail lock" "sed --in-place -e 's/^deny = .*$/deny = 10/' -e 's/^unlock_time = .*$/unlock_time = 60/' /etc/security/faillock.conf"
@ -69,6 +48,6 @@ echo
echo === clean and reboot
echo
run root "remove config sources" "rm -r \"$CONFIG_DIR\""
# run root "remove config sources" "rm -r \"$CONFIG_DIR\""
run root "remove first boot script" "rm /first-boot.sh /first-boot.env /etc/systemd/system/first-boot.service"
run root "reboot" "shutdown -r now"