diff --git a/install.sh b/install.sh index 4a860c9..644956f 100644 --- a/install.sh +++ b/install.sh @@ -16,6 +16,12 @@ trap cleanup EXIT clear +# Check root +if [[ $(id -u) -ne 0 ]]; then + echo "This script needs to be run as root!" + exit 1 +fi + # Friendly introduction echo "0. WELCOME" echo "Welcome to the Arch Linux installation script!" @@ -54,6 +60,21 @@ IFS=' ' array=(${dev}) dev="${array[0]}" +# TODO Check disk size +# Disk auswählen (Variable `dev` muss gesetzt sein) +#disk="/dev/${dev}" + +# Festplattengröße in Gigabyte berechnen +#disk_size=$(lsblk -b -n -o SIZE "$disk" | awk '{print $1 / 1024 / 1024 / 1024}') + +# Prüfen, ob die Festplatte größer als 10 GB ist +#if (( $(echo "$disk_size >= 10" | bc -l) )); then +# echo "✅ Die Festplatte hat $disk_size GB und ist größer als 10 GB." +#else +# echo "❌ Fehler: Die Festplatte ist zu klein ($disk_size GB). Bitte eine größere auswählen." +# exit 1 +#fi + clear ########## @@ -63,14 +84,14 @@ echo # Setting encryption password. echo "Choose a strong password for encrypting the primary partition:" -pwcr="" -while [[ -z "${pwcr}" ]]; do - echo "Please enter a password: " - read -rs pwfr - read -rs -p "Retype a password: " pwsc - if [[ "${pwfr}" == "${pwsc}" ]]; +password_encrypt="" +while [[ -z "${password_encrypt}" ]]; do + #echo "Please enter a password: " + read -rs -p "Please enter a password: " password_first + read -rs -p "Retype a password: " password_second + if [[ "${password_first}" == "${password_second}" ]]; then - pwcr="${pwfr}" + password_encrypt="${password_first}" echo echo "Both passwords are the same. Continuing.." break @@ -88,9 +109,13 @@ clear echo "3. HOSTNAME" echo -# Setting hostname. -echo "Before installing the system, please enter a hostname:" -read -r host +# Setting hostname +#echo "Before installing the system, please enter a hostname:" +read -r -p "Before installing the system, please enter a hostname: " host +while [[ -z "${host}" ]]; do + echo "Hostname can not be empty!" + read -r -p "Please enter a hostname: " host +done clear @@ -99,16 +124,16 @@ clear echo "4. ROOT PASSWORD" echo -# Setting root password. +# Setting root password echo "Choose a password for the root account:" -pwr="" -while [[ -z "${pwr}" ]]; do - echo "Please enter a password: " - read -rs pwfr - read -rs -p "Retype a password: " pwsc +password_root="" +while [[ -z "${password_root}" ]]; do + #echo "Please enter a password: " + read -rs -p "Please enter a password: " password_first + read -rs -p "Retype a password: " password_second - if [[ "${pwfr}" == "${pwsc}" ]]; then - pwrt="${pwfr}" + if [[ "${password_first}" == "${password_second}" ]]; then + password_root="${password_first}" echo echo "Both passwords are the same. Continuing.." break @@ -125,21 +150,26 @@ echo "4. USER" echo # Setting username -echo "Please enter a username:" -read -r user +#echo "Please enter a username:" +read -r -p "Please enter a username: " user +while [[ -z "${user}" ]]; do + echo "Benutzername darf nicht leer sein!" + read -r -p "Please enter a username: " user +done + echo # Setting user password echo "Also please choose a password for your user:" -pwu="" -while [[ -z "${pwu}" ]]; do - echo "Please enter a password: " - read -rs pwfr - read -rs -p "Retype a password: " pwsc +password_user="" +while [[ -z "${password_user}" ]]; do + #echo "Please enter a password: " + read -rs -p "Please enter a password: " password_first + read -rs -p "Retype a password: " password_second - if [[ "${pwfr}" == "${pwsc}" ]]; + if [[ "${password_first}" == "${password_second}" ]]; then - pwur="${pwfr}" + password_user="${password_first}" echo echo "Both passwords are the same. Continuing.." break @@ -198,14 +228,14 @@ echo "Encrypting system partition. This might take a while." echo # https://wiki.archlinux.org/title/Dm-crypt/Device_encryption#Encryption_options_for_LUKS_mode -echo -en "${pwcr}\n${pwcr}" | cryptsetup -s 512 luksFormat /dev/$main +echo -en "${password_encrypt}\n${password_encrypt}" | cryptsetup -s 512 luksFormat "/dev/${main}" echo "Partition successfully encrypted." echo # Opening encrypted partition and mounting at /dev/mapper/main echo "Decrypting.. This also might take a while." echo -echo -en "${pwcr}\n${pwcr}" | cryptsetup luksOpen "/dev/${main}" main +echo -en "${password_encrypt}\n${password_encrypt}" | cryptsetup luksOpen "/dev/${main}" main echo "Partition successfully opened." clear @@ -232,6 +262,7 @@ mount "/dev/mapper/main" "/mnt" btrfs subvolume create "/mnt/root" btrfs subvolume create "/mnt/home" +sync umount "/mnt" echo @@ -375,7 +406,8 @@ echo # Editing mkinitcpio.conf echo "Editing /etc/mkinitcpio.conf.." -sed -i '55s/.*/HOOKS=(base udev autodetect microcode modconf kms block keyboard keymap encrypt filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf +sed -i 's/^HOOKS=.*/HOOKS=(base udev autodetect microcode modconf kms block keyboard keymap encrypt filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf +#sed -i '55s/.*/HOOKS=(base udev autodetect microcode modconf kms block keyboard keymap encrypt filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf echo "Done." echo @@ -400,7 +432,7 @@ echo # Set root password # https://wiki.archlinux.org/title/Installation_guide#Root_password echo "Setting root password.." -echo -en "${pwrt}\n${pwrt}" | arch-chroot "/mnt" passwd +echo -en "${password_root}\n${password_root}" | arch-chroot "/mnt" passwd echo "Done." echo @@ -450,7 +482,7 @@ echo # Set username, password and group echo "Adding user.." arch-chroot /mnt useradd -m "${user}" -echo -en "${pwur}\n${pwur}" | arch-chroot /mnt passwd "${user}" +echo -en "${password_user}\n${password_user}" | arch-chroot /mnt passwd "${user}" arch-chroot /mnt gpasswd -a "${user}" wheel sed -i '82s/.*/%wheel ALL=(ALL) ALL/' /mnt/etc/sudoers @@ -468,10 +500,37 @@ cat << EOF > /mnt/etc/plasmalogin.conf [Autologin] Session=plasma.desktop User=${user} +Session=plasma EOF echo "Done." echo +# Adding sddm config. +cat << EOF > /mnt/etc/sddm.conf.d/kde_settings.conf +[Autologin] +Relogin=false +Session=plasma +User=${user} + +[General] +HaltCommand=/usr/bin/systemctl poweroff +RebootCommand=/usr/bin/systemctl reboot + +[Theme] +Current=breeze + +[Users] +MaximumUid=60513 +MinimumUid=1000 +EOF + +# Unmounting and rebooting. +echo "Unmounting system.." +umount "/mnt/boot" +umount "/mnt" +echo "Done." +echo + clear echo "Installation finished!"