Check if arguments are present for setup.sh

master
Peery 3 weeks ago
parent 71054d5f60
commit 9bfa3f4486
Signed by: pandro
SSH Key Fingerprint: SHA256:iBUZSuDxqYr4hYpe9U3BA9NJmXKpbGt4H0S8hUwIbrA

@ -11,7 +11,7 @@ reboot
./setup.sh <template> <fqdn> ./setup.sh <template> <fqdn>
# example: # example:
apt-get update && apt-get -y dist-upgrade && git clone https://gitea.lubiland.de/lubiland/hardware-setup.git && cd hardware-setup apt-get update && apt-get -y dist-upgrade && git clone https://gitea.lubiland.de/pandro/hardware-setup.git && cd hardware-setup
./setup.sh hetzner_ax51-nvme asef.lubi.link ./setup.sh hetzner_ax51-nvme asef.lubi.link

@ -1,2 +1,3 @@
# <target> <source device> <key file> <options> # <target> <source device> <key file> <options>
root-unlocked /dev/all_vg/root none luks,discard root-unlocked-sda1 /dev/sda1 none luks,discard
root-unlocked-sdb1 /dev/sdb1 none luks,discard

@ -3,6 +3,6 @@
# #
# <file system> <dir> <type> <options> <dump> <pass> # <file system> <dir> <type> <options> <dump> <pass>
/dev/mapper/root-unlocked-sda / btrfs relatime,autodefrag 0 1 /dev/mapper/root-unlocked-sda1 / btrfs relatime,autodefrag 0 1
UUID=%boot_uuid% /boot ext4 relatime 0 2 UUID=%boot_uuid% /boot ext4 relatime 0 2
UUID=%esp_uuid% /boot/efi vfat relatime 0 2 UUID=%esp_uuid% /boot/efi vfat relatime 0 2

@ -7,6 +7,9 @@ set -e
# free 7GB # free 7GB
chroot="$1" chroot="$1"
boot="hardware/${2}/boot"
esp="hardware/${2}/esp"
root="hardware/${2}/root"
# encrypt and unlock the root partitions # encrypt and unlock the root partitions
echo -n 'Enter LUKS password: ' echo -n 'Enter LUKS password: '
@ -20,14 +23,17 @@ unset root_pwd
# root device btrfs raid1 # root device btrfs raid1
mkfs.btrfs /dev/sda1 mkfs.btrfs /dev/mapper/root-unlocked-sda1
mount /dev/sda1 "$chroot" mount /dev/mapper/root-unlocked-sda1 "$chroot"
btrfs device add /dev/sdb1 "$chroot" -f btrfs device add /dev/mapper/root-unlocked-sdb1 "$chroot" -f
btrfs balance start -dconvert=raid1 -mconvert=raid1 "$chroot" btrfs balance start -dconvert=raid1 -mconvert=raid1 "$chroot"
# boot device ext4 # boot device ext4
echo mkfs.ext4 "$boot"
mkfs.ext4 "$boot" mkfs.ext4 "$boot"
echo mkdir "$chroot/boot"
mkdir "$chroot/boot" mkdir "$chroot/boot"
echo mount "$boot" "$chroot/boot"
mount "$boot" "$chroot/boot" mount "$boot" "$chroot/boot"
# esp device FAT # esp device FAT

@ -3,9 +3,9 @@ export DEBIAN_FRONTEND=noninteractive
# common config files # common config files
cp -a /hardware-setup/base/config/* / cp -aR /hardware-setup/config/base/* /
# overwrite config files # overwrite config files
cp -a "/hardware-setup/$1/config/*" / cp -aR /hardware-setup/config/$1/* /
# update apt because sources.list.d is also in config/* # update apt because sources.list.d is also in config/*
apt-get update apt-get update
@ -127,3 +127,5 @@ sed -i "s/%fqdn%/$(hostname)/g" /etc/hosts
# as unbound isn't running in the live/rescue system chroot, # as unbound isn't running in the live/rescue system chroot,
# which is where this script usually runs # which is where this script usually runs
echo 'nameserver 127.0.0.1' > /etc/resolv.conf echo 'nameserver 127.0.0.1' > /etc/resolv.conf
update-initramfs -u

@ -1,6 +1,11 @@
#!/bin/bash #!/bin/bash
set -e set -e
if [[ -z $1 ]] || [[ -z $2 ]]; then
echo "Missing some arguments!"
echo "Usage: ./setup.sh <template> <fqdn>"
exit 1
fi
apt-get -y install lvm2 mdadm cryptsetup debootstrap btrfs-progs apt-get -y install lvm2 mdadm cryptsetup debootstrap btrfs-progs
@ -13,7 +18,8 @@ esp="hardware/${1}/esp"
# format # format
chroot=/mnt/root-unlocked chroot=/mnt/root-unlocked
"./hardware/${1}/mkfs.sh" "$chroot" mkdir "$chroot"
"./hardware/${1}/mkfs.sh" "$chroot" "$1"
# debootstrap # debootstrap

Loading…
Cancel
Save