base.sh maodularisiert

This commit is contained in:
eichehome 2023-03-29 15:53:44 +02:00
parent 4fbfc1ef51
commit 772b537c3e

261
base.sh
View file

@ -1,4 +1,78 @@
# Vor Reboot
echo "Select Prozessor Vendor:"
echo "1) AMD 2) Intel 3) Other(no ucode)"
read vendor
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
sleep 1
echo "Select Kernel"
echo "1) Linux 2) Linux+lts 3) Linux+zen 4) Linux+zen+lts 5) zen+lts"
read kernel
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
sleep 1
echo "General configuration:"
echo "1) Server (Systemd-networkd, no graphics card) 2) Laptop/Desktop (Networkmanager, Graphics Card)"
read configuration
if [[ $configuration == 2 ]]; then
echo "Laptop/Desktop"
echo ""
echo "Graphics Card"
echo "1) AMD 2) Intel 3) Nvidia"
read gracard
if [[ $gracard == 1 ]]; then
echo "AMD"
elif [[ $gracard == 2 ]]; then
echo "Intel"
elif [[ $gracard == 3 ]]; then
echo "Nvidia"
else
read -p "No Graphics Card selected. Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
fi
elif [[ $configuration == 1 ]]; then
echo "Server"
fi
sleep 1
# Pacman Konfiguration
sed -i 's/#\(Color\)/\1/' /etc/pacman.conf
@ -19,12 +93,14 @@ echo "KEYMAP=de-latin1-nodeadkeys" >> /etc/vconsole.conf #only for console not f
#echo "FONT=Tamsyn10x20r" >> /etc/vconsole.conf
echo "arch" >> /etc/hostname
# vim /etc/hosts
echo "127.0.0.1 localhost" >> /etc/hosts
echo "127.0.0.1 localhost" > /etc/hosts
echo "::1 localhost" >> /etc/hosts
echo "127.0.1.1 arch.localedomain arch" >> /etc/hosts
echo root:test | chpasswd
pacman -S base-devel linux-zen-headers linux-lts-headers
pacman -S $selectedKernel $ucode
pacman -S base-devel $headers
pacman -S iwd dialog reflector xdg-user-dirs xdg-utils inetutils ldns bash-completion openssh rsync iptables-nft ipset firewalld lynx
@ -33,119 +109,122 @@ pacman -S networkmanager
pacman -S efibootmgr mtools dosfstools
if [[ $gracard == 1 ]]; then
pacman -S --noconfirm xf86-video-amdgpu
# pacman -S --noconfirm nvidia nvidia-utils nvidia-settings
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
cp ./configs/20-ethernet.network /etc/systemd/network/
# Wlan
cp ./configs/20-wlan.network /etc/systemd/network/
# Wwan (Mobilefunk)
cp ./configs/20-wwan.network /etc/systemd/network/
elif [[ $configuration == 2 ]]; then
systemctl enable NetworkManager
cp ./configs/wifi_backend.conf /etc/NetworkManager/conf.d/
fi
#systemctl enable systemd-networkd
systemctl enable systemd-resolved
systemctl enable systemd-timesyncd
systemctl enable sshd
systemctl enable reflector.timer
systemctl enable firewalld
systemctl enable fstrim.timer
#systemctl enable iwd
systemctl enable NetworkManager
if [[ $gracard == 1 ]]; then
sed -i 's/MODULES=()/MODULES=(amdgpu)/' /etc/mkinitcpio.conf #AMD
# sed -i 's/MODULES=()/MODULES=(nvidia)/' /etc/mkinitcpio.conf #Nvidia
# sed -i 's/MODULES=()/MODULES=(i915)/' /etc/mkinitcpio.conf #Intel
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
mkinitcpio -p linux-zen
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
bootctl install
# Bootloaderconfig
echo "timeout 5" > /boot/loader/loader.conf
echo "console max" >> /boot/loader/loader.conf
echo "default arch.conf" >> /boot/loader/loader.conf
cp ./configs/loader.conf /boot/loader/
if [[ $kernel == 1 || $kernel == 2 || $kernel == 3 || $kernel == 4 ]]; then
# Entry Arch
echo "title Arch Linux" >> /boot/loader/entries/arch.conf
echo "linux /vmlinuz-linux-zen" >> /boot/loader/entries/arch.conf
# AMD
echo "initrd /amd-ucode.img" >> /boot/loader/entries/arch.conf
# Intel
# echo "initrd /intel-ucode.img" >> /boot/loader/entries/arch.conf
echo "initrd /initramfs-linux-zen.img" >> /boot/loader/entries/arch.conf
echo "options root=LABEL=arch rootflags=subvol=@ rw" >> /boot/loader/entries/arch.conf
cp ./configs/arch.conf /boot/loader/entries/
if [[ $vendor == 1 ]]; then
sed -i 's/#AMD//' /boot/loader/entries/arch.conf
elif [[ $vendor == 2 ]]; then
sed -i 's/#Intel//' /boot/loader/entries/arch.conf
fi
if [[ $kernel == 2 || $kernel == 4 || $kernel == 5 ]]; then
# Entry Arch LTS
echo "title Arch Linux LTS" >> /boot/loader/entries/arch-lts.conf
echo "linux /vmlinuz-linux-lts" >> /boot/loader/entries/arch-lts.conf
# AMD
echo "initrd /amd-ucode.img" >> /boot/loader/entries/arch-lts.conf
# Intel
# echo "initrd /intel-ucode.img" >> /boot/loader/entries/arch-lts.conf
echo "initrd /initramfs-linux-lts.img" >> /boot/loader/entries/arch-lts.conf
echo "options root=LABEL=arch rootflags=subvol=@ rw" >> /boot/loader/entries/arch-lts.conf
cp ./configs/arch-lts.conf /boot/loader/entries/
if [[ $vendor == 1 ]]; then
sed -i 's/#AMD//' /boot/loader/entries/arch-lts.conf
elif [[ $vendor == 2 ]]; then
sed -i 's/#Intel//' /boot/loader/entries/arch-lts.conf
fi
fi
if [[ $kernel == 3 || $kernel == 4 || $kernel == 5 ]]; then
# Entry Arch Zen
cp ./configs/arch-zen.conf /boot/loader/entries/
if [[ $vendor == 1 ]]; then
sed -i 's/#AMD//' /boot/loader/entries/arch-zen.conf
elif [[ $vendor == 2 ]]; then
sed -i 's/#Intel//' /boot/loader/entries/arch-zen.conf
fi
fi
if [[ $kernel == 1 || $kernel == 2 || $kernel == 3 || $kernel == 4 ]]; then
# Entry Arch Fallback
echo "title Arch Linux Fallback" > /boot/loader/entries/arch-fallback.conf
echo "linux /vmlinuz-linux-zen" >> /boot/loader/entries/arch-fallback.conf
# AMD
echo "initrd /amd-ucode.img" >> /boot/loader/entries/arch-fallback.conf
# Intel
# echo "initrd /intel-ucode.img" >> /boot/loader/entries/arch-fallback.conf
echo "initrd /initramfs-linux-zen-fallback.img" >> /boot/loader/entries/arch-fallback.conf
echo "options root=LABEL=arch rootflags=subvol=@" >> /boot/loader/entries/arch-fallback.conf
cp ./configs/arch-fallback.conf /boot/loader/entries/
if [[ $vendor == 1 ]]; then
sed -i 's/#AMD//' /boot/loader/entries/arch-fallback.conf
elif [[ $vendor == 2 ]]; then
sed -i 's/#Intel//' /boot/loader/entries/arch-fallback.conf
fi
fi
if [[ $kernel == 2 || $kernel == 4 || $kernel == 5 ]]; then
# Entry Arch LTS Fallback
echo "title Arch Linux LTS Fallback" > /boot/loader/entries/arch-lts-fallback.conf
echo "linux /vmlinuz-linux-lts" >> /boot/loader/entries/arch-lts-fallback.conf
# AMD
echo "initrd /amd-ucode.img" >> /boot/loader/entries/arch-lts-fallback.conf
# Intel
# echo "initrd /intel-ucode.img" >> /boot/loader/entries/arch-lts-fallback.conf
echo "initrd /initramfs-linux-lts-fallback.img" >> /boot/loader/entries/arch-lts-fallback.conf
echo "options root=LABEL=arch rootflags=subvol=@" >> /boot/loader/entries/arch-lts-fallback.conf
cp ./configs/arch-lts-fallback.conf /boot/loader/entries/
if [[ $vendor == 1 ]]; then
sed -i 's/#AMD//' /boot/loader/entries/arch-lts-fallback.conf
elif [[ $vendor == 2 ]]; then
sed -i 's/#Intel//' /boot/loader/entries/arch-lts-fallback.conf
fi
fi
# Netzwerk
# Ethernet
#echo "[Match]" >> /etc/systemd/network/20-ethernet.network
#echo "Name=en*" >> /etc/systemd/network/20-ethernet.network
#echo "Name=eth*" >> /etc/systemd/network/20-ethernet.network
#echo "" >> /etc/systemd/network/20-ethernet.network
#echo "[Network]" >> /etc/systemd/network/20-ethernet.network
#echo "DHCP=yes" >> /etc/systemd/network/20-ethernet.network
#echo "IPv6PrivacyExtensions=yes" >> /etc/systemd/network/20-ethernet.network
#echo "" >> /etc/systemd/network/20-ethernet.network
#echo "[DHCPv4]" >> /etc/systemd/network/20-ethernet.network
#echo "RouteMetric=100" >> /etc/systemd/network/20-ethernet.network
#echo "" >> /etc/systemd/network/20-ethernet.network
#echo "[IPv6AcceptRA]" >> /etc/systemd/network/20-ethernet.network
#echo "RouteMetric=100" >> /etc/systemd/network/20-ethernet.network
# Wlan
#echo "[Match]" >> /etc/systemd/network/20-wlan.network
#echo "Name=wl*" >> /etc/systemd/network/20-wlan.network
#echo "" >> /etc/systemd/network/20-wlan.network
#echo "[Network]" >> /etc/systemd/network/20-wlan.network
#echo "DHCP=yes" >> /etc/systemd/network/20-wlan.network
#echo "IPv6PrivacyExtensions=yes" >> /etc/systemd/network/20-wlan.network
#echo "" >> /etc/systemd/network/20-wlan.network
#echo "[DHCPv4]" >> /etc/systemd/network/20-wlan.network
#echo "RouteMetric=600" >> /etc/systemd/network/20-wlan.network
#echo "" >> /etc/systemd/network/20-wlan.network
#echo "[IPv6AcceptRA]" >> /etc/systemd/network/20-wlan.network
#echo "RouteMetric=600" >> /etc/systemd/network/20-wlan.network
# Wwan (Mobilefunk)
#echo "[Match]" >> /etc/systemd/network/20-wwan.network
#echo "Name=ww*" >> /etc/systemd/network/20-wwan.network
#echo "" >> /etc/systemd/network/20-wwan.network
#echo "[Network]" >> /etc/systemd/network/20-wwan.network
#echo "DHCP=yes" >> /etc/systemd/network/20-wwan.network
#echo "IPv6PrivacyExtensions=yes" >> /etc/systemd/network/20-wwan.network
#echo "" >> /etc/systemd/network/20-wwan.network
#echo "[DHCPv4]" >> /etc/systemd/network/20-wwan.network
#echo "RouteMetric=700" >> /etc/systemd/network/20-wwan.network
#echo "" >> /etc/systemd/network/20-wwan.network
#echo "[IPv6AcceptRA]" >> /etc/systemd/network/20-wwan.network
#echo "RouteMetric=700" >> /etc/systemd/network/20-wwan.network
echo "[device]" >>/etc/NetworkManager/conf.d/wifi_backend.conf
echo "wifi.backend=iwd" >>/etc/NetworkManager/conf.d/wifi_backend.conf
if [[ $kernel == 3 || $kernel == 4 || $kernel == 5 ]]; then
# Entry Arch Zen Fallback
cp ./configs/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
useradd -mG wheel eichehome
echo eichehome:testen | chpasswd