archinstall/base.sh

344 lines
11 KiB
Bash
Raw Normal View History

2023-03-29 15:25:44 +00:00
#!/bin/bash
# Vor Reboot
2023-04-02 18:52:09 +00:00
echo "Select Prozessor Vendor (Defaults to no ucode):"
2023-03-29 13:53:44 +00:00
echo "1) AMD 2) Intel 3) Other(no ucode)"
2023-03-29 15:25:44 +00:00
read -r vendor
2023-04-02 18:52:09 +00:00
: "${vendor:=3}"
2023-03-29 13:53:44 +00:00
if [[ $vendor == 1 ]]; then
echo "AMD"
ucode="amd-ucode"
elif [[ $vendor == 2 ]]; then
echo "Intel"
ucode="intel-ucode"
elif [[ $vendor == 3 ]]; then
echo "no Ucode"
ucode=""
else
echo "Vendor Unknown, aborting"
exit 1
fi
2023-04-02 18:52:09 +00:00
echo "Select Kernel (Defaults to Linux):"
echo "1) Linux 2) Linux LTS 3) Linux Zen"
2023-03-29 15:25:44 +00:00
read -r kernel
2023-04-02 18:52:09 +00:00
: "${kernel:=1}"
2023-03-29 13:53:44 +00:00
2023-04-02 18:52:09 +00:00
tempString="";
for range in ${kernel//,/ }; do
tempString="$tempString{${range//-/..}}";
done;
tempString=${tempString//\}{/\} {};
tempString=$(echo $tempString | tr [:blank:] '\n' | sed 's/{\([0-9]\{1,2\}\)}/\1/' | tr '\n' ',');
tempString=${tempString/%,/};
result="";
for range2 in ${tempString//,/ }; do
result+=$(eval echo $range2);
result+=";";
done;
result=${result/%;};
result=${result//;/ };
echo $result
for index in ${result}; do
echo -n "Ausgewählt: "
case $index in
*1*)
echo "Linux"
selectedKernel+="linux "
header+="linux-headers "
;;
*2*)
echo "Linux LTS"
selectedKernel+="linux-lts "
header+="linux-lts-headers "
;;
*3*)
echo "Linux Zen"
selectedKernel+="linux-zen "
header+="linux-zen-headers "
;;
*) echo "Error, aborting" ;;
esac
done
#if [[ $kernel == 1 ]]; then
# echo "Linux"
# selectedKernel="linux"
# header="linux-headers"
#elif [[ $kernel == 2 ]]; then
# echo "Linux/Linux LTS"
# selectedKernel="linux linux-lts"
# header="linux-headers linux-lts-headers"
#elif [[ $kernel == 3 ]]; then
# echo "Linux/Linux Zen"
# selectedKernel="linux linux-zen"
# header="linux-headers linux-zen-headers"
#elif [[ $kernel == 4 ]]; then
# echo "Linux/Linux LTS/Linux Zen"
# selectedKernel="linux linux-lts linux-zen"
# header="linux-headers linux-lts-headers linux-zen-headers"
#elif [[ $kernel == 5 ]]; then
# echo "Linux LTS/Linux Zen"
# selectedKernel="linux-lts linux-zen"
# header="linux-lts-headers linux-zen-headers"
#else
# echo "no Kernel selectet, aborting"
# exit 1
#fi
read -r -p "Passwort für Root :" rootpw
: "${rootpw:=test}"
if [[ $rootpw == "" ]]; then
echo "Kein Passwort für Root vergeben, breche ab"
exit 1
fi
read -r -p "Nutzername: " nutzername
: "${nutzername:=eichehome}"
if [[ $nutzername == "" ]]; then
echo "Kein Nutzername eingegeben, breche ab"
exit 1
fi
read -r -p "Passwort für $nutzername: " nutzerpw
: "${nutzerpw:=testen}"
if [[ $rootpw == "" ]]; then
echo "Kein Passwort für $nutzername vergeben, breche ab"
2023-03-29 13:53:44 +00:00
exit 1
fi
echo "General configuration:"
2023-04-02 18:52:09 +00:00
echo "1) Server (Systemd-networkd, no graphics card) 2) Laptop/Desktop (Networkmanager(iwd), Graphics Card, GNOME)"
2023-03-29 15:25:44 +00:00
read -r configuration
2023-03-29 13:53:44 +00:00
2023-04-02 18:52:09 +00:00
: "${configuration:=2}"
2023-03-29 13:53:44 +00:00
if [[ $configuration == 2 ]]; then
echo "Laptop/Desktop"
echo ""
echo "Graphics Card"
echo "1) AMD 2) Intel 3) Nvidia"
2023-03-29 15:25:44 +00:00
read -r gracard
2023-03-29 13:53:44 +00:00
if [[ $gracard == 1 ]]; then
echo "AMD"
elif [[ $gracard == 2 ]]; then
echo "Intel"
elif [[ $gracard == 3 ]]; then
echo "Nvidia"
else
2023-03-29 15:25:44 +00:00
read -r -p "No Graphics Card selected. Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
2023-03-29 13:53:44 +00:00
fi
elif [[ $configuration == 1 ]]; then
echo "Server"
fi
2023-03-29 13:53:44 +00:00
sleep 1
# Pacman Konfiguration
sed -i 's/#\(Color\)/\1/' /etc/pacman.conf
# Umbruch notwendug
sed -i 's/#\(ParallelDownloads\s=\s5\)/\1\
ILoveCandy/' /etc/pacman.conf
# Zeit einstellen
2021-12-11 18:22:56 +00:00
ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
hwclock --systohc
2021-12-11 19:03:24 +00:00
# vim /etc/locale.gen
sed -i 's/#\(de_DE.UTF-8\)/\1/' /etc/locale.gen
2021-12-11 18:22:56 +00:00
locale-gen
echo "LANG=de_DE.UTF-8" >> /etc/locale.conf
echo "KEYMAP=de-latin1-nodeadkeys" >> /etc/vconsole.conf #only for console not for DE or terminal
#echo "FONT=Tamsyn10x20r" >> /etc/vconsole.conf
2021-12-11 18:22:56 +00:00
echo "arch" >> /etc/hostname
# vim /etc/hosts
2023-03-29 13:53:44 +00:00
echo "127.0.0.1 localhost" > /etc/hosts
2021-12-11 18:22:56 +00:00
echo "::1 localhost" >> /etc/hosts
echo "127.0.1.1 arch.localedomain arch" >> /etc/hosts
2023-04-02 18:52:09 +00:00
echo root:"${rootpw}" | chpasswd
2021-12-11 18:22:56 +00:00
2023-03-29 13:53:44 +00:00
2023-04-02 18:52:09 +00:00
pacman -S ${selectedKernel} "${ucode}"
pacman -S base-devel ${header}
2021-12-11 18:22:56 +00:00
2023-04-02 18:52:09 +00:00
pacman -S iwd dialog reflector xdg-user-dirs xdg-utils inetutils ldns bash-completion openssh rsync iptables-nft ipset firewalld lynx man-db man-pages texinfo opendoas
2021-12-11 18:22:56 +00:00
2023-04-02 18:52:09 +00:00
echo "permit :wheel" > /etc/doas.conf
echo "permit persist eichehome as root" >> /etc/doas.conf
echo "" >> /etc/doas.conf
doas -C /etc/doas.conf && echo "config ok" || echo "config error"
read -r -p "Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] && pacman -R sudo || echo "do not forget to check doas.conf and remove sudo afterwards"
#Idee: ppp polkit(?)
pacman -S efibootmgr mtools dosfstools
2021-12-12 20:39:13 +00:00
2023-03-29 13:53:44 +00:00
if [[ $gracard == 1 ]]; then
pacman -S --noconfirm xf86-video-amdgpu
elif [[ $gracard == 3 ]]; then
pacman -S --noconfirm nvidia nvidia-utils nvidia-settings
fi
if [[ $configuration == 1 ]]; then
systemctl enable systemd-networkd
systemctl enable iwd
systemctl enable sshd
# Netzwerk
# Ethernet
2023-03-29 15:39:25 +00:00
echo "Ethernet"
2023-04-02 18:52:09 +00:00
#ethernet_network=$(find / -type f -name 20-ethernet.network | grep configs)
cp "$(find "${PWD}" -type f -name )" /etc/systemd/network/
2023-03-29 13:53:44 +00:00
# Wlan
2023-03-29 15:39:25 +00:00
echo "WLAN"
2023-04-02 18:52:09 +00:00
#wlan_network=$(find / -type f -name 20-wlan.network | grep configs)
cp "$(find "${PWD}" -type f -name )" /etc/systemd/network/
2023-03-29 13:53:44 +00:00
# Wwan (Mobilefunk)
2023-03-29 15:39:25 +00:00
echo "Mobilfunk"
2023-04-02 18:52:09 +00:00
#wwan_network=$(find / -type f -name 20-wwan.network | grep configs)
cp "$(find "${PWD}" -type f -name )" /etc/systemd/network/
2023-03-29 13:53:44 +00:00
elif [[ $configuration == 2 ]]; then
2023-04-02 18:52:09 +00:00
pacman -S gnome gdm fwupd networkmanager modemmanager avahi bluez bluez-utils sshfs pipewire pipewire-audio pipewire-alsa pipewire-pulse pipewire-jack pipewire-zeroconf pipewire-v4l2 wireplumber gstreamer gst-plugin-pipewire gst-libav gst-plugins-good gst-plugins-base gst-plugins-vaapi gnome-software-packagekit-plugin xdg-desktop-portal-gnome festival networkmanager-openconnect networkmanager-openvpn networkmanager-pptp networkmanager-vpnc power-profiles-daemon
2023-03-29 13:53:44 +00:00
systemctl enable NetworkManager
2023-04-02 18:52:09 +00:00
# Configure IWD as Backend for Networkmanager
#wifi_backend_conf=$(find / -type f -name wifi_backend.conf | grep configs)
cp "$(find "${PWD}" -type f -name )" /etc/NetworkManager/conf.d/
# Disable MulticastDNS in systemd-resolved
#disable_multicastDNS_conf=$(find / -type f -name disable-multicastDNS.conf | grep configs)
mkdir -p /etc/systemd/resolved.conf.d
cp "$(find "${PWD}" -type f -name )" /etc/systemd/resolved.conf.d/
systemctl enable avahi-daemon
2023-03-29 13:53:44 +00:00
fi
2021-12-11 18:22:56 +00:00
systemctl enable systemd-resolved
2023-01-13 00:16:34 +00:00
systemctl enable systemd-timesyncd
2021-12-11 18:22:56 +00:00
systemctl enable reflector.timer
systemctl enable firewalld
systemctl enable fstrim.timer
2023-04-02 18:52:09 +00:00
systemctl enable systemd-time-wait-sync.service
2021-12-11 18:35:28 +00:00
2023-03-29 13:53:44 +00:00
if [[ $gracard == 1 ]]; then
sed -i 's/MODULES=()/MODULES=(amdgpu)/' /etc/mkinitcpio.conf #AMD
elif [[ $gracard == 2 ]]; then
sed -i 's/MODULES=()/MODULES=(i915)/' /etc/mkinitcpio.conf #Intel
elif [[ $gracard == 3 ]]; then
sed -i 's/MODULES=()/MODULES=(nvidia)/' /etc/mkinitcpio.conf #Nvidia
fi
2023-03-29 15:59:47 +00:00
sed -i 's/BINARIES=()/BINARIES=(btrfs)/' /etc/mkinitcpio.conf
2023-03-29 15:56:31 +00:00
sed -i 's/HOOKS=(.*)/HOOKS=(base systemd keyboard autodetect sd-vconsole modconf kms block sd-encrypt filesystems fsck)/' /etc/mkinitcpio.conf
2023-03-29 13:53:44 +00:00
if [[ $kernel == 1 ]]; then
mkinitcpio -p linux
elif [[ $kernel == 2 ]]; then
mkinitcpio -p linux
mkinitcpio -p linux-lts
elif [[ $kernel == 3 ]]; then
mkinitcpio -p linux
mkinitcpio -p linux-zen
elif [[ $kernel == 4 ]]; then
mkinitcpio -p linux
mkinitcpio -p linux-lts
mkinitcpio -p linux-zen
elif [[ $kernel == 5 ]]; then
mkinitcpio -p linux-lts
mkinitcpio -p linux-zen
fi
2021-12-11 18:35:28 +00:00
bootctl install
2021-12-11 18:35:28 +00:00
# Bootloaderconfig
2023-04-02 18:52:09 +00:00
#loader_conf=$(find / -type f -name loader.conf | grep configs)
cp "$(find "${PWD}" -type f -name loader.conf)" /boot/loader/
2023-03-29 13:53:44 +00:00
#$selectedKernel="linux linux-lts linux-zen"
2023-04-02 18:52:09 +00:00
entry_conf=$(find "${PWD}" -type f -name entry.conf)
for kernel in $selectedKernel; do
boot_entry_name="${kernel//linux/arch}";
# Standart
2023-03-30 11:10:51 +00:00
echo "$boot_entry_name.conf"
cp "$entry_conf" /boot/loader/entries/"$boot_entry_name".conf
2023-04-02 18:52:09 +00:00
sed -i "s/#KERNEL#/$kernel/" /boot/loader/entries/"$boot_entry_name".conf
sed -i "s/#INITRAMFS#/$kernel/" /boot/loader/entries/"$boot_entry_name".conf
boot_entry="${boot_entry_name//arch/arch-linux}"
title=""
for word in ${boot_entry//-/ }; do
word="${word@u} "
title="${title}${word//Lts/LTS}"
done
sed -i "s/#TITLE#/$title/" /boot/loader/entries/"$boot_entry_name".conf
# Fallback
2023-03-30 11:10:51 +00:00
echo "$boot_entry_name-fallback.conf"
cp "$entry_conf" /boot/loader/entries/"$boot_entry_name"-fallback.conf
2023-04-02 18:52:09 +00:00
sed -i "s/#KERNEL#/$kernel/" /boot/loader/entries/"$boot_entry_name"-fallback.conf
sed -i "s/#INITRAMFS#/$kernel-fallback/" /boot/loader/entries/"$boot_entry_name"-fallback.conf
boot_entry="${boot_entry_name//arch/arch-linux}-fallback"
title=""
for word in ${boot_entry//-/ }; do
word="${word@u} "
title="${title}${word//Lts/LTS}"
done
sed -i "s/#TITLE#/$title/" /boot/loader/entries/"$boot_entry_name"-fallback.conf
done;
#TITLE#Arch Linux Zen Fallback
#KERNEL#linux-zen
#INITRAMFS#linux-zen-fallback
2023-03-30 11:10:51 +00:00
#if [[ $kernel == 1 || $kernel == 2 || $kernel == 3 || $kernel == 4 ]]; then
# # Entry Arch
# arch_conf=$(find / -type f -name arch.conf | grep configs)
# cp "$arch_conf" /boot/loader/entries/
#fi
#
#if [[ $kernel == 2 || $kernel == 4 || $kernel == 5 ]]; then
# # Entry Arch LTS
# arch_lts_conf=$(find / -type f -name arch-lts.conf | grep configs)
# cp "$arch_lts_conf" /boot/loader/entries/
#fi
#
#if [[ $kernel == 3 || $kernel == 4 || $kernel == 5 ]]; then
# # Entry Arch Zen
# arch_zen_conf=$(find / -type f -name arch-zen.conf | grep configs)
# cp "$arch_zen_conf" /boot/loader/entries/
#fi
#
#if [[ $kernel == 1 || $kernel == 2 || $kernel == 3 || $kernel == 4 ]]; then
# # Entry Arch Fallback
# arch_fallback_conf=$(find / -type f -name arch-fallback.conf | grep configs)
# cp "$arch_fallback_conf" /boot/loader/entries/
#fi
#
#if [[ $kernel == 2 || $kernel == 4 || $kernel == 5 ]]; then
# # Entry Arch LTS Fallback
# arch_lts_fallback_conf=$(find / -type f -name arch-lts-fallback.conf | grep configs)
# cp "$arch_lts_fallback_conf" /boot/loader/entries/
#fi
#
#if [[ $kernel == 3 || $kernel == 4 || $kernel == 5 ]]; then
# # Entry Arch Zen Fallback
# arch_zen_fallback_conf=$(find / -type f -name arch-zen-fallback.conf | grep configs)
# cp "$arch_zen_fallback_conf" /boot/loader/entries/
# if [[ $vendor == 1 ]]; then
# sed -i 's/#AMD//' /boot/loader/entries/arch-zen-fallback.conf
# elif [[ $vendor == 2 ]]; then
# sed -i 's/#Intel//' /boot/loader/entries/arch-zen-fallback.conf
# fi
#fi
2023-04-02 18:52:09 +00:00
# Verschlüsselungs-Passwort: testpassword
cryptroot_name=$(grep "#\s/dev/mapper" /etc/fstab | head -n 1 | sed 's/#\s\/dev\/mapper\/\(.*\)\s.*/\1/')
cryptroot_device_name=$(grep "LABEL=EFI" /etc/fstab | sed 's/#\s\/dev\/\(.\{3\}\).*/\1/')
cryptroot_device_uuid=$(blkid -o value -s UUID /dev/"$cryptroot_device_name"2)
#sed -i "s/root=LABEL=arch/root=\/dev\/mapper\/$cryptroot_name rd.luks.name=$cryptroot_device_uuid=$cryptroot_name/" /boot/loader/entries/arch.conf
find /boot -type f -name arch\*.conf -exec sed -i "s/root=LABEL=arch/root=\/dev\/mapper\/$cryptroot_name rd.luks.name=$cryptroot_device_uuid=$cryptroot_name/" {} \;
useradd -mG wheel eichehome
2023-04-02 18:52:09 +00:00
echo "$nutzername":"$nutzerpw" | chpasswd
2021-12-12 20:29:14 +00:00
echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers.d/wheel_group