Dotfiles/setup/live-install.sh

227 lines
4.6 KiB
Bash
Executable File

#!/bin/bash
echo "testing uplink..."
ping -c4 8.8.8.8 || (echo "!!!ERROR NO UPLINK - ABORTING!!!" && exit)
echo "Starting base Installer..."
echo "is the clock correct? - if not abort with CTRL+C"
timedatectl
timedatecheckwaitercount=0
echo "sleeping for 20s"
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
#this is hard coded for assurance that the wait wont be skipped
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo $timedatecheckwaitercount
sleep 1s
let "timedatecheckwaitercount=timedatecheckwaitercount+1"
echo "Continuing..."
echo "running lsblk..."
lsblk
echo -n "Enter blockdev to install on or m for manual partitioning: "
read blockdev
if [ "$statecon" != '' ]; then
fdisk $blockdev
else
echo '''
g
n
1
+1G
n
2
+10G
n
3
1
w
''' | fdisk $blockdev
fi
echo "Formatting Complete"
mkfs.fat "$blockdev"p1
mkswap "$blockdev"p2
mkfs.btrfs "$blockdev"p3
mount "$blockdev"p3 /mnt/
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
mkdir /mnt/@/boot
mount "$blockdev"p1 /mnt/@/boot
umount /mnt
mount -o compress=zstd,subvol=@ /dev/"$blockdev"p3 /mnt
mkdir -p /mnt/home
mount -o compress=zstd,subvol=@home /dev/"$blockdev"p3 /mnt/home
mount "$blockdev"p1 /mnt/@/boot
swapon "$blockdev"p2
# pacstrap -K /mnt base linux linux-firmware
pacstrap -K /mnt base base-devel linux linux-firmware git btrfs-progs grub efibootmgr grub-btrfs inotify-tools timeshift vim networkmanager pipewire pipewire-alsa pipewire-pulse pipewire-jack wireplumber reflector zsh zsh-completions zsh-autosuggestions openssh man sudo
# Fetch the disk mounting points as they are now ( we mounted everything before ) and generate instructions to let the system know how to mount the various disks automatically
genfstab -U /mnt >> /mnt/etc/fstab
# Check if fstab is fine ( it is if you've faithfully followed the previous steps )
cat /mnt/etc/fstab
echo '''
ln -sf /usr/share/zoneinfo/Europe/Vienna /etc/localtime
hwclock --systohc
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
touch /etc/locale.conf
echo "\n" >> /etc/locale.conf
echo "LANG=en_US.UTF-8" >> /etc/locale.conf
echo "KEYMAP=de" > /etc/vconsole.conf
echo "XKBLAYOUT=de" >> /etc/vconsole.conf
echo "XKBMODEL=pc105" >> /etc/vconsole.conf
echo "XKBOPTIONS=terminate:ctrl_alt_bksp" >> /etc/vconsole.conf
echo -n "Hostname: "
read hostnameinput
echo "$hostnameinput" > /etc/hostname
echo "127.0.0.1 localhost \n ::1 localhost \n 127.0.1.1 $hostnameinput" > /etc/hosts
echo -n "Sudo User: "
read sudoadmin
useradd -mG wheel $sudoadmin
passwd $sudoadmin
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg
systemctl enable NetworkManager
exit
''' | arch-chroot /mnt
umount -R /mnt
reboot