From 63504207145ea501c44268eef64f12dcb4c53f00 Mon Sep 17 00:00:00 2001 From: farhan Date: Fri, 12 Nov 2021 19:01:24 +0000 Subject: [PATCH 01/12] added startup.sh for user preferences and changed other files with variables --- 0-preinstall.sh | 32 +++++++------- 1-setup.sh | 4 +- archtitus.sh | 2 + startup.sh | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+), 17 deletions(-) create mode 100644 startup.sh diff --git a/0-preinstall.sh b/0-preinstall.sh index d789a3a..da49b11 100755 --- a/0-preinstall.sh +++ b/0-preinstall.sh @@ -36,17 +36,17 @@ mkdir /mnt echo -e "\nInstalling prereqs...\n$HR" pacman -S --noconfirm gptfdisk btrfs-progs -echo "-------------------------------------------------" -echo "-------select your disk to format----------------" -echo "-------------------------------------------------" -lsblk -echo "Please enter disk to work on: (example /dev/sda)" -read DISK -echo "THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK" -read -p "are you sure you want to continue (Y/N):" formatdisk -case $formatdisk in +# echo "-------------------------------------------------" +# echo "-------select your disk to format----------------" +# echo "-------------------------------------------------" +# lsblk +# echo "Please enter disk to work on: (example /dev/sda)" +# read DISK +# echo "THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK" +# read -p "are you sure you want to continue (Y/N):" formatdisk +# case $formatdisk in -y|Y|yes|Yes|YES) +# y|Y|yes|Yes|YES) echo "--------------------------------------" echo -e "\nFormatting disk...\n$HR" echo "--------------------------------------" @@ -67,16 +67,19 @@ fi echo -e "\nCreating Filesystems...\n$HR" if [[ ${DISK} =~ "nvme" ]]; then mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" -mkfs.btrfs -L "ROOT" "${DISK}p3" -f -mount -t btrfs "${DISK}p3" /mnt +mkfs.$FS -L "ROOT" "${DISK}p3" -f +mount -t $FS "${DISK}p3" /mnt else mkfs.vfat -F32 -n "EFIBOOT" "${DISK}2" -mkfs.btrfs -L "ROOT" "${DISK}3" -f -mount -t btrfs "${DISK}3" /mnt +mkfs.$FS -L "ROOT" "${DISK}3" -f +mount -t $FS "${DISK}3" /mnt fi +if [[ $FS =~ btrfs]]; then ls /mnt | xargs btrfs subvolume delete btrfs subvolume create /mnt/@ umount /mnt +mount -t btrfs -o subvol=@ -L ROOT /mnt +fi ;; *) echo "Rebooting in 3 Seconds ..." && sleep 1 @@ -87,7 +90,6 @@ reboot now esac # mount target -mount -t btrfs -o subvol=@ -L ROOT /mnt mkdir /mnt/boot mkdir /mnt/boot/efi mount -t vfat -L EFIBOOT /mnt/boot/ diff --git a/1-setup.sh b/1-setup.sh index ada72c7..323e502 100755 --- a/1-setup.sh +++ b/1-setup.sh @@ -34,12 +34,12 @@ echo " Setup Language to US and set locale " echo "-------------------------------------------------" sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen locale-gen -timedatectl --no-ask-password set-timezone America/Chicago +timedatectl --no-ask-password set-timezone $timezone timedatectl --no-ask-password set-ntp 1 localectl --no-ask-password set-locale LANG="en_US.UTF-8" LC_TIME="en_US.UTF-8" # Set keymaps -localectl --no-ask-password set-keymap us +localectl --no-ask-password set-keymap $keymap # Add sudo no password rights sed -i 's/^# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers diff --git a/archtitus.sh b/archtitus.sh index c981a50..f8b33c6 100755 --- a/archtitus.sh +++ b/archtitus.sh @@ -4,6 +4,8 @@ export SCRIPTHOME="$(basename -- $PWD)" echo "Scripts are in dir named $SCRIPTHOME" + bash startup.sh + source setup.conf bash 0-preinstall.sh arch-chroot /mnt /root/$SCRIPTHOME/1-setup.sh source /mnt/root/$SCRIPTHOME/install.conf diff --git a/startup.sh b/startup.sh new file mode 100644 index 0000000..f32f034 --- /dev/null +++ b/startup.sh @@ -0,0 +1,114 @@ +#!/usr/bin/env bash +# This script will ask users about their prefrences like disk, file system, +logo () { +# This will be shown on every set as user is progressing +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ +██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ +███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ +██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ +██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ +╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------ + Please select presetup settings for your system +------------------------------------------------------------------------ +" +} +filesystem () { +# This function will handle file systems. At this movement we are handling only +# btrfs and ext4. Others will be added in future. +echo -ne " + Please Select your file system for both boot and root + 1) btrfs + 2) ext4 + 0) exit +" +read FS +case $FS in +1) echo "FS=btrfs" >> setup.conf;; +2) echo "FS=ext4" >> setup.conf;; +# 3) echo "FS=LUKS" >> setup.conf;; +0) exit ;; +*) echo "Wrong option please select again"; filesystem;; +esac +} +timezone () { +# Added this from arch wiki https://wiki.archlinux.org/title/System_time +time_zone="$(curl --fail https://ipapi.co/timezone)" +echo -ne "System detected your timezone to be '$time_zone'" +echo -ne "Is this correct? yes/no:" +read answer +case $answer in + y|Y|yes|Yes|YES) + echo "timezone=$time_zone" >> setup.conf;; + n|N|no|NO|No) + read -p "Please enter your desired timezone e.g. Europe/London :" new_timezone + echo "timezone=$new_timezone" >> setup.conf;; + *) echo "Wrong option. Try again";timezone;; +esac +} +keymap () { +# These are default key maps as presented in official arch repo archinstall +echo -ne " +Please select key board layout from this list + -by + -ca + -cf + -cz + -de + -dk + -es + -et + -fa + -fi + -fr + -gr + -hu + -il + -it + -lt + -lv + -mk + -nl + -no + -pl + -ro + -ru + -sg + -ua + -uk + -us + +" +read -p "Your key boards layout:" keymap +echo "keymap=$keymap" >> setup.conf +} +diskpart (){ +lsblk +echo -ne " +------------------------------------------------------------------------ + THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK + Please make sure you know what you are doing because + after formating your disk there is no way to get data back +------------------------------------------------------------------------ + +Please enter disk to work on: (example /dev/sda): +" +read option +echo "DISK=$option" >> setup.conf +} +# More features in future +language (){} +logo +rm -rf setup.conf &>/dev/null +diskpart +clear +logo +filesystem +clear +logo +timezone +clear +logo +keymap \ No newline at end of file From d08ac2b61ab93bcad783198bfe030a5e0479765c Mon Sep 17 00:00:00 2001 From: farhan Date: Fri, 12 Nov 2021 19:08:36 +0000 Subject: [PATCH 02/12] clearing some typos --- startup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startup.sh b/startup.sh index f32f034..681cb67 100644 --- a/startup.sh +++ b/startup.sh @@ -99,7 +99,7 @@ read option echo "DISK=$option" >> setup.conf } # More features in future -language (){} +# language (){} logo rm -rf setup.conf &>/dev/null diskpart From 56afc4e54446ae17a01552188c8590093c18b973 Mon Sep 17 00:00:00 2001 From: farhan Date: Fri, 12 Nov 2021 19:48:55 +0000 Subject: [PATCH 03/12] added sourcing setup.conf in files --- 0-preinstall.sh | 22 +++++++++++++++------- 1-setup.sh | 5 +++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/0-preinstall.sh b/0-preinstall.sh index da49b11..f03f7b3 100755 --- a/0-preinstall.sh +++ b/0-preinstall.sh @@ -8,6 +8,7 @@ # ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ #------------------------------------------------------------------------- SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +source setup.conf echo "-------------------------------------------------" echo "Setting up mirrors for optimal download " echo "-------------------------------------------------" @@ -32,7 +33,6 @@ echo -e "----------------------------------------------------------------------- reflector -a 48 -c $iso -f 5 -l 20 --sort rate --save /etc/pacman.d/mirrorlist mkdir /mnt - echo -e "\nInstalling prereqs...\n$HR" pacman -S --noconfirm gptfdisk btrfs-progs @@ -65,16 +65,24 @@ fi # make filesystems echo -e "\nCreating Filesystems...\n$HR" -if [[ ${DISK} =~ "nvme" ]]; then +if [[ ${DISK} =~ "nvme" && ${FS} == "btrfs" ]]; then mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" -mkfs.$FS -L "ROOT" "${DISK}p3" -f -mount -t $FS "${DISK}p3" /mnt +mkfs.btrfs -L "ROOT" "${DISK}p3" -f +mount -t btrfs "${DISK}p3" /mnt +elif [[ ${DISK} =~ "sd" && ${FS} == "btrfs"]]; then +mkfs.vfat -F32 -n "EFIBOOT" "${DISK}2" +mkfs.btrfs -L "ROOT" "${DISK}3" -f +mount -t btrfs "${DISK}3" /mnt +elif [[ ${DISK} =~ "nvme" && ${FS} == "ext4" ]]; then +mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" +mkfs.ext4 -L "ROOT" "${DISK}p3" +mount -t ext4 "${DISK}p3" /mnt else mkfs.vfat -F32 -n "EFIBOOT" "${DISK}2" -mkfs.$FS -L "ROOT" "${DISK}3" -f -mount -t $FS "${DISK}3" /mnt +mkfs.ext4 -L "ROOT" "${DISK}3" +mount -t ext4 "${DISK}3" /mnt fi -if [[ $FS =~ btrfs]]; then +if [[ ${FS} =~ "btrfs" ]]; then ls /mnt | xargs btrfs subvolume delete btrfs subvolume create /mnt/@ umount /mnt diff --git a/1-setup.sh b/1-setup.sh index 323e502..9722cb1 100755 --- a/1-setup.sh +++ b/1-setup.sh @@ -7,6 +7,7 @@ # ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ # ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ #------------------------------------------------------------------------- +source setup.conf echo "--------------------------------------" echo "-- Network Setup --" echo "--------------------------------------" @@ -34,12 +35,12 @@ echo " Setup Language to US and set locale " echo "-------------------------------------------------" sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen locale-gen -timedatectl --no-ask-password set-timezone $timezone +timedatectl --no-ask-password set-timezone ${timezone} timedatectl --no-ask-password set-ntp 1 localectl --no-ask-password set-locale LANG="en_US.UTF-8" LC_TIME="en_US.UTF-8" # Set keymaps -localectl --no-ask-password set-keymap $keymap +localectl --no-ask-password set-keymap ${keymap} # Add sudo no password rights sed -i 's/^# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers From 1c23c706e1704635401a213b6efe703c161d8e4a Mon Sep 17 00:00:00 2001 From: farhan Date: Fri, 12 Nov 2021 20:05:04 +0000 Subject: [PATCH 04/12] removing errors and fine tuning --- 0-preinstall.sh | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/0-preinstall.sh b/0-preinstall.sh index f03f7b3..c77e9bf 100755 --- a/0-preinstall.sh +++ b/0-preinstall.sh @@ -65,22 +65,24 @@ fi # make filesystems echo -e "\nCreating Filesystems...\n$HR" -if [[ ${DISK} =~ "nvme" && ${FS} == "btrfs" ]]; then -mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" -mkfs.btrfs -L "ROOT" "${DISK}p3" -f -mount -t btrfs "${DISK}p3" /mnt -elif [[ ${DISK} =~ "sd" && ${FS} == "btrfs"]]; then -mkfs.vfat -F32 -n "EFIBOOT" "${DISK}2" -mkfs.btrfs -L "ROOT" "${DISK}3" -f -mount -t btrfs "${DISK}3" /mnt -elif [[ ${DISK} =~ "nvme" && ${FS} == "ext4" ]]; then -mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" -mkfs.ext4 -L "ROOT" "${DISK}p3" -mount -t ext4 "${DISK}p3" /mnt -else -mkfs.vfat -F32 -n "EFIBOOT" "${DISK}2" -mkfs.ext4 -L "ROOT" "${DISK}3" -mount -t ext4 "${DISK}3" /mnt +if [[ ${DISK} =~ "nvme"]]; then + if [[ ${FS} == "btrfs" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" + mkfs.btrfs -L "ROOT" "${DISK}p3" -f + mount -t btrfs "${DISK}p3" /mnt + else + mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" + mkfs.ext4 -L "ROOT" "${DISK}p3" + mount -t ext4 "${DISK}p3" /mnt +else [[ ${DISK} =~ "sd"]]; then + if [[ ${FS} == "btrfs" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" "${DISK}2" + mkfs.btrfs -L "ROOT" "${DISK}3" -f + mount -t btrfs "${DISK}3" /mnt + else + mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" + mkfs.ext4 -L "ROOT" "${DISK}p3" + mount -t ext4 "${DISK}p3" /mnt fi if [[ ${FS} =~ "btrfs" ]]; then ls /mnt | xargs btrfs subvolume delete From 8c896a0a1333134887135353889c541bd511d63b Mon Sep 17 00:00:00 2001 From: farhan Date: Fri, 12 Nov 2021 20:32:46 +0000 Subject: [PATCH 05/12] removing errors and fine tuning --- 0-preinstall.sh | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/0-preinstall.sh b/0-preinstall.sh index c77e9bf..a161a75 100755 --- a/0-preinstall.sh +++ b/0-preinstall.sh @@ -65,7 +65,8 @@ fi # make filesystems echo -e "\nCreating Filesystems...\n$HR" -if [[ ${DISK} =~ "nvme"]]; then +if [[ ${DISK} =~ "nvme" ]]; then + if [[ ${FS} == "btrfs" ]]; then mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" mkfs.btrfs -L "ROOT" "${DISK}p3" -f @@ -74,15 +75,17 @@ if [[ ${DISK} =~ "nvme"]]; then mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" mkfs.ext4 -L "ROOT" "${DISK}p3" mount -t ext4 "${DISK}p3" /mnt -else [[ ${DISK} =~ "sd"]]; then + fi +elif [[ ${DISK =~ "sd" }]]; then if [[ ${FS} == "btrfs" ]]; then mkfs.vfat -F32 -n "EFIBOOT" "${DISK}2" mkfs.btrfs -L "ROOT" "${DISK}3" -f mount -t btrfs "${DISK}3" /mnt else - mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" - mkfs.ext4 -L "ROOT" "${DISK}p3" - mount -t ext4 "${DISK}p3" /mnt + mkfs.vfat -F32 -n "EFIBOOT" "${DISK}2" + mkfs.ext4 -L "ROOT" "${DISK}3" + mount -t ext4 "${DISK}3" /mnt + fi fi if [[ ${FS} =~ "btrfs" ]]; then ls /mnt | xargs btrfs subvolume delete @@ -90,14 +93,14 @@ btrfs subvolume create /mnt/@ umount /mnt mount -t btrfs -o subvol=@ -L ROOT /mnt fi -;; -*) -echo "Rebooting in 3 Seconds ..." && sleep 1 -echo "Rebooting in 2 Seconds ..." && sleep 1 -echo "Rebooting in 1 Second ..." && sleep 1 -reboot now -;; -esac +# ;; +# *) +# echo "Rebooting in 3 Seconds ..." && sleep 1 +# echo "Rebooting in 2 Seconds ..." && sleep 1 +# echo "Rebooting in 1 Second ..." && sleep 1 +# reboot now +# ;; +# esac # mount target mkdir /mnt/boot From e63c8d8b15a0e9a53c03364835415cd6de383411 Mon Sep 17 00:00:00 2001 From: farhan Date: Fri, 12 Nov 2021 20:42:54 +0000 Subject: [PATCH 06/12] final --- 0-preinstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/0-preinstall.sh b/0-preinstall.sh index a161a75..b82ded5 100755 --- a/0-preinstall.sh +++ b/0-preinstall.sh @@ -76,7 +76,7 @@ if [[ ${DISK} =~ "nvme" ]]; then mkfs.ext4 -L "ROOT" "${DISK}p3" mount -t ext4 "${DISK}p3" /mnt fi -elif [[ ${DISK =~ "sd" }]]; then +else # only two file systems are supported yet if [[ ${FS} == "btrfs" ]]; then mkfs.vfat -F32 -n "EFIBOOT" "${DISK}2" mkfs.btrfs -L "ROOT" "${DISK}3" -f From 40d4008405971d0b4f85673ded163b000616b1e7 Mon Sep 17 00:00:00 2001 From: farhan Date: Fri, 12 Nov 2021 20:44:29 +0000 Subject: [PATCH 07/12] final --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8e189eb..a20aba1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ install.conf installlog.txt -archnikus.code-workspace \ No newline at end of file +archnikus.code-workspace +setup.conf \ No newline at end of file From aed61721151caed8e9b5d8c43301abcf537bb9a0 Mon Sep 17 00:00:00 2001 From: farhan Date: Fri, 12 Nov 2021 22:23:32 +0000 Subject: [PATCH 08/12] One brand theme through out --- 0-preinstall.sh | 113 ++++++++++++++++++++++++------------------------ 1-setup.sh | 92 +++++++++++++++++++++++++-------------- 2-user.sh | 29 ++++++++----- 3-post-setup.sh | 57 ++++++++++++++---------- archtitus.sh | 31 ++++++++++--- startup.sh | 2 +- 6 files changed, 193 insertions(+), 131 deletions(-) diff --git a/0-preinstall.sh b/0-preinstall.sh index b82ded5..ef69e2a 100755 --- a/0-preinstall.sh +++ b/0-preinstall.sh @@ -8,10 +8,21 @@ # ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ #------------------------------------------------------------------------- SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ + ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ + ███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ + ██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ + ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ + ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------- + Automated Arch Linux Installer +------------------------------------------------------------------------- + +Setting up mirrors for optimal download +" source setup.conf -echo "-------------------------------------------------" -echo "Setting up mirrors for optimal download " -echo "-------------------------------------------------" iso=$(curl -4 ifconfig.co/country-iso) timedatectl set-ntp true pacman -S --noconfirm pacman-contrib terminus-font @@ -19,38 +30,24 @@ setfont ter-v22b sed -i 's/^#Para/Para/' /etc/pacman.conf pacman -S --noconfirm reflector rsync grub cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup -echo -e "-------------------------------------------------------------------------" -echo -e " █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗" -echo -e " ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝" -echo -e " ███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗" -echo -e " ██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║" -echo -e " ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║" -echo -e " ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝" -echo -e "-------------------------------------------------------------------------" -echo -e "-Setting up $iso mirrors for faster downloads" -echo -e "-------------------------------------------------------------------------" - +echo -ne " +------------------------------------------------------------------------- + Setting up $iso mirrors for faster downloads +------------------------------------------------------------------------- +" reflector -a 48 -c $iso -f 5 -l 20 --sort rate --save /etc/pacman.d/mirrorlist -mkdir /mnt - -echo -e "\nInstalling prereqs...\n$HR" +mkdir /mnt &>/dev/null # Hiding error message if any +echo -ne " +------------------------------------------------------------------------- + Installing Prerequisites +------------------------------------------------------------------------- +" pacman -S --noconfirm gptfdisk btrfs-progs - -# echo "-------------------------------------------------" -# echo "-------select your disk to format----------------" -# echo "-------------------------------------------------" -# lsblk -# echo "Please enter disk to work on: (example /dev/sda)" -# read DISK -# echo "THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK" -# read -p "are you sure you want to continue (Y/N):" formatdisk -# case $formatdisk in - -# y|Y|yes|Yes|YES) -echo "--------------------------------------" -echo -e "\nFormatting disk...\n$HR" -echo "--------------------------------------" - +echo -ne " +------------------------------------------------------------------------- + Formating Disk +------------------------------------------------------------------------- +" # disk prep sgdisk -Z ${DISK} # zap all on disk sgdisk -a 2048 -o ${DISK} # new gpt disk 2048 alignment @@ -59,12 +56,15 @@ sgdisk -a 2048 -o ${DISK} # new gpt disk 2048 alignment sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:'BIOSBOOT' ${DISK} # partition 1 (BIOS Boot Partition) sgdisk -n 2::+100M --typecode=2:ef00 --change-name=2:'EFIBOOT' ${DISK} # partition 2 (UEFI Boot Partition) sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:'ROOT' ${DISK} # partition 3 (Root), default start, remaining -if [[ ! -d "/sys/firmware/efi" ]]; then +if [[ ! -d "/sys/firmware/efi" ]]; then # Checking for bios system sgdisk -A 1:set:2 ${DISK} fi - # make filesystems -echo -e "\nCreating Filesystems...\n$HR" +echo -ne " +------------------------------------------------------------------------- + Creating Filesystems +------------------------------------------------------------------------- +" if [[ ${DISK} =~ "nvme" ]]; then if [[ ${FS} == "btrfs" ]]; then @@ -93,14 +93,6 @@ btrfs subvolume create /mnt/@ umount /mnt mount -t btrfs -o subvol=@ -L ROOT /mnt fi -# ;; -# *) -# echo "Rebooting in 3 Seconds ..." && sleep 1 -# echo "Rebooting in 2 Seconds ..." && sleep 1 -# echo "Rebooting in 1 Second ..." && sleep 1 -# reboot now -# ;; -# esac # mount target mkdir /mnt/boot @@ -114,24 +106,29 @@ if ! grep -qs '/mnt' /proc/mounts; then echo "Rebooting in 1 Second ..." && sleep 1 reboot now fi - -echo "--------------------------------------" -echo "-- Arch Install on Main Drive --" -echo "--------------------------------------" +echo -ne " +------------------------------------------------------------------------- + Arch Install on Main Drive +------------------------------------------------------------------------- +" pacstrap /mnt base base-devel linux linux-firmware vim nano sudo archlinux-keyring wget libnewt --noconfirm --needed genfstab -U /mnt >> /mnt/etc/fstab echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf cp -R ${SCRIPT_DIR} /mnt/root/ArchTitus cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist -echo "--------------------------------------" -echo "--GRUB BIOS Bootloader Install&Check--" -echo "--------------------------------------" +echo -ne " +------------------------------------------------------------------------- + GRUB BIOS Bootloader Install & Check +------------------------------------------------------------------------- +" if [[ ! -d "/sys/firmware/efi" ]]; then grub-install --boot-directory=/mnt/boot ${DISK} fi -echo "--------------------------------------" -echo "-- Check for low memory systems <8G --" -echo "--------------------------------------" +echo -ne " +------------------------------------------------------------------------- + Checking for low memory systems <8G +------------------------------------------------------------------------- +" TOTALMEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*') if [[ $TOTALMEM -lt 8000000 ]]; then #Put swap into the actual system, not into RAM disk, otherwise there is no point in it, it'll cache RAM into RAM. So, /mnt/ everything. @@ -145,6 +142,8 @@ if [[ $TOTALMEM -lt 8000000 ]]; then #The line below is written to /mnt/ but doesn't contain /mnt/, since it's just / for the sysytem itself. echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab #Add swap to fstab, so it KEEPS working after installation. fi -echo "--------------------------------------" -echo "-- SYSTEM READY FOR 1-setup --" -echo "--------------------------------------" +echo -ne " +------------------------------------------------------------------------- + SYSTEM READY FOR 1-setup.sh +------------------------------------------------------------------------- +" \ No newline at end of file diff --git a/1-setup.sh b/1-setup.sh index 9722cb1..ed99a8b 100755 --- a/1-setup.sh +++ b/1-setup.sh @@ -1,38 +1,51 @@ #!/usr/bin/env bash -#------------------------------------------------------------------------- -# █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ -# ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ -# ███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ -# ██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ -# ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ -# ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ -#------------------------------------------------------------------------- +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ + ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ + ███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ + ██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ + ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ + ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------- + Automated Arch Linux Installer +------------------------------------------------------------------------- +" source setup.conf -echo "--------------------------------------" -echo "-- Network Setup --" -echo "--------------------------------------" +echo -ne " +------------------------------------------------------------------------- + Network Setup +------------------------------------------------------------------------- +" pacman -S networkmanager dhclient --noconfirm --needed systemctl enable --now NetworkManager -echo "-------------------------------------------------" -echo "Setting up mirrors for optimal download " -echo "-------------------------------------------------" +echo -ne " +------------------------------------------------------------------------- + Setting up mirrors for optimal download +------------------------------------------------------------------------- +" pacman -S --noconfirm pacman-contrib curl pacman -S --noconfirm reflector rsync cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak nc=$(grep -c ^processor /proc/cpuinfo) -echo "You have " $nc" cores." -echo "-------------------------------------------------" -echo "Changing the makeflags for "$nc" cores." +echo -ne " +------------------------------------------------------------------------- + You have " $nc" cores. And + changing the makeflags for "$nc" cores. Aswell as + changing the compression settings. +------------------------------------------------------------------------- +" TOTALMEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*') if [[ $TOTALMEM -gt 8000000 ]]; then sed -i "s/#MAKEFLAGS=\"-j2\"/MAKEFLAGS=\"-j$nc\"/g" /etc/makepkg.conf -echo "Changing the compression settings for "$nc" cores." sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $nc -z -)/g" /etc/makepkg.conf fi -echo "-------------------------------------------------" -echo " Setup Language to US and set locale " -echo "-------------------------------------------------" +echo -ne " +------------------------------------------------------------------------- + Setup Language to US and set locale +------------------------------------------------------------------------- +" sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen locale-gen timedatectl --no-ask-password set-timezone ${timezone} @@ -51,14 +64,18 @@ sed -i 's/^#Para/Para/' /etc/pacman.conf #Enable multilib sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf pacman -Sy --noconfirm - -echo -e "\nInstalling Base System\n" - +echo -ne " +------------------------------------------------------------------------- + Installing Base System +------------------------------------------------------------------------- +" sudo pacman -S --noconfirm --needed - < /pkg-files/pacman-pkgs.txt - -# +echo -ne " +------------------------------------------------------------------------- + Installing Microcode +------------------------------------------------------------------------- +" # determine processor type and install microcode -# proc_type=$(lscpu | awk '/Vendor ID:/ {print $3}') case "$proc_type" in GenuineIntel) @@ -71,8 +88,12 @@ case "$proc_type" in pacman -S --noconfirm amd-ucode proc_ucode=amd-ucode.img ;; -esac - +esac +echo -ne " +------------------------------------------------------------------------- + Installing Graphics Drivers +------------------------------------------------------------------------- +" # Graphics Drivers find and install if lspci | grep -E "NVIDIA|GeForce"; then pacman -S nvidia --noconfirm --needed @@ -82,8 +103,11 @@ elif lspci | grep -E "Radeon"; then elif lspci | grep -E "Integrated Graphics Controller"; then pacman -S libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils --needed --noconfirm fi - -echo -e "\nDone!\n" +echo -ne " +------------------------------------------------------------------------- + Adding User +------------------------------------------------------------------------- +" if ! source install.conf; then read -p "Please enter username:" username echo "username=$username" >> ${HOME}/$SCRIPTHOME/install.conf @@ -99,4 +123,8 @@ then else echo "You are already a user proceed with aur installs" fi - +echo -ne " +------------------------------------------------------------------------- + SYSTEM READY FOR 2-user.sh +------------------------------------------------------------------------- +" \ No newline at end of file diff --git a/2-user.sh b/2-user.sh index 7a32541..f583586 100755 --- a/2-user.sh +++ b/2-user.sh @@ -1,17 +1,20 @@ #!/usr/bin/env bash -#------------------------------------------------------------------------- -# █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ -# ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ -# ███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ -# ██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ -# ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ -# ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ -#------------------------------------------------------------------------- +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ + ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ + ███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ + ██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ + ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ + ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------- + Automated Arch Linux Installer +------------------------------------------------------------------------- -echo -e "\nINSTALLING AUR SOFTWARE\n" +Installing AUR Softwares +" # You can solve users running this script as root with this and then doing the same for the next for statement. However I will leave this up to you. -echo "CLONING: YAY" cd ~ git clone "https://aur.archlinux.org/yay.git" cd ${HOME}/yay @@ -31,5 +34,9 @@ konsave -i $HOME/$SCRIPTHOME/kde.knsv sleep 1 konsave -a kde -echo -e "\nDone!\n" +echo -ne " +------------------------------------------------------------------------- + SYSTEM READY FOR 3-post-setup.sh +------------------------------------------------------------------------- +" exit diff --git a/3-post-setup.sh b/3-post-setup.sh index c230620..f90f9c9 100755 --- a/3-post-setup.sh +++ b/3-post-setup.sh @@ -1,36 +1,45 @@ #!/usr/bin/env bash -#------------------------------------------------------------------------- -# █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ -# ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ -# ███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ -# ██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ -# ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ -# ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ -#------------------------------------------------------------------------- +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ + ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ + ███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ + ██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ + ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ + ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------- + Automated Arch Linux Installer +------------------------------------------------------------------------- -echo -e "\nFINAL SETUP AND CONFIGURATION" -echo "--------------------------------------" -echo "-- GRUB EFI Bootloader Install&Check--" -echo "--------------------------------------" +Final Setup and Configurations +GRUB EFI Bootloader Install & Check +" if [[ -d "/sys/firmware/efi" ]]; then grub-install --efi-directory=/boot ${DISK} fi grub-mkconfig -o /boot/grub/grub.cfg -# ------------------------------------------------------------------------ - -echo -e "\nEnabling Login Display Manager" +echo -ne " +------------------------------------------------------------------------- + Enabling Login Display Manager +------------------------------------------------------------------------- +" systemctl enable sddm.service -echo -e "\nSetup SDDM Theme" +echo -ne " +------------------------------------------------------------------------- + Setting up SDDM Theme +------------------------------------------------------------------------- +" cat < /etc/sddm.conf [Theme] Current=Nordic EOF -# ------------------------------------------------------------------------ - -echo -e "\nEnabling essential services" - +echo -ne " +------------------------------------------------------------------------- + Enabling Essential Services +------------------------------------------------------------------------- +" systemctl enable cups.service ntpd -qg systemctl enable ntpd.service @@ -38,10 +47,10 @@ systemctl disable dhcpcd.service systemctl stop dhcpcd.service systemctl enable NetworkManager.service systemctl enable bluetooth -echo " -############################################################################### -# Cleaning -############################################################################### +echo -ne " +------------------------------------------------------------------------- + Cleaning +------------------------------------------------------------------------- " # Remove no password sudo rights sed -i 's/^%wheel ALL=(ALL) NOPASSWD: ALL/# %wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers diff --git a/archtitus.sh b/archtitus.sh index f8b33c6..c6e09e4 100755 --- a/archtitus.sh +++ b/archtitus.sh @@ -2,8 +2,19 @@ # Find the name of the folder the scripts are in export SCRIPTHOME="$(basename -- $PWD)" -echo "Scripts are in dir named $SCRIPTHOME" - +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ + ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ + ███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ + ██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ + ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ + ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------- + Automated Arch Linux Installer +------------------------------------------------------------------------- + Scripts are in directory named $SCRIPTHOME +" bash startup.sh source setup.conf bash 0-preinstall.sh @@ -12,8 +23,16 @@ echo "Scripts are in dir named $SCRIPTHOME" arch-chroot /mnt /usr/bin/runuser -u $username -- /home/$username/$SCRIPTHOME/2-user.sh arch-chroot /mnt /root/$SCRIPTHOME/3-post-setup.sh -echo " -############################################################################### -# Done - Please Eject Install Media and Reboot -############################################################################### +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ + ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ + ███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ + ██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ + ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ + ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------- + Automated Arch Linux Installer +------------------------------------------------------------------------- + Done - Please Eject Install Media and Reboot " \ No newline at end of file diff --git a/startup.sh b/startup.sh index 681cb67..5cfbcb3 100644 --- a/startup.sh +++ b/startup.sh @@ -11,7 +11,7 @@ echo -ne " ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ------------------------------------------------------------------------ - Please select presetup settings for your system + Please select presetup settings for your system ------------------------------------------------------------------------ " } From 9d04a5950062ca4c5769be7ffc324e728615ac77 Mon Sep 17 00:00:00 2001 From: farhan Date: Sat, 13 Nov 2021 18:29:20 +0000 Subject: [PATCH 09/12] added luks with btrfs and asking user for username and password at satrtup --- 0-preinstall.sh | 79 +++++++++++++++++++++++++++++++++++++------------ 1-setup.sh | 14 ++++----- startup.sh | 25 ++++++++++++++-- 3 files changed, 87 insertions(+), 31 deletions(-) diff --git a/0-preinstall.sh b/0-preinstall.sh index ef69e2a..5e07962 100755 --- a/0-preinstall.sh +++ b/0-preinstall.sh @@ -65,28 +65,69 @@ echo -ne " Creating Filesystems ------------------------------------------------------------------------- " -if [[ ${DISK} =~ "nvme" ]]; then - - if [[ ${FS} == "btrfs" ]]; then - mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" - mkfs.btrfs -L "ROOT" "${DISK}p3" -f - mount -t btrfs "${DISK}p3" /mnt - else - mkfs.vfat -F32 -n "EFIBOOT" "${DISK}p2" - mkfs.ext4 -L "ROOT" "${DISK}p3" - mount -t ext4 "${DISK}p3" /mnt +if [[ "${DISK}" == "nvme" ]]; then + if [[ "${FS}" == "btrfs" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" ${DISK}p2 + mkfs.btrfs -L ROOT ${DISK}p3 -f + mount -t btrfs ${DISK}p3 /mnt + elif [[ "${FS}" == "ext4" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" ${DISK}p2 + mkfs.ext4 -L ROOT ${DISK}p3 + mount -t ext4 ${DISK}p3 /mnt + elif [[ "${FS}" == "luks" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" ${DISK}p2 +# enter luks password to cryptsetup and format root partition + echo -n "${luks_password}" | cryptsetup -y -v luksFormat ${DISK}p3 - +# open luks container and ROOT will be place holder + cryptsetup open ${DISK}p3 ROOT +# now format that container + mkfs.btrfs -L ROOT /dev/mapper/ROOT +# create subvolumes for btrfs + mount -t btrfs /dev/mapper/ROOT /mnt + btrfs subvolume create /mnt/@ + btrfs subvolume create /mnt/@home + btrfs subvolume create /mnt/@.snapshots + btrfs subvolume create /mnt/@var + btrfs subvolume create /mnt/@tmp + umount /mnt +# mount @ subvolume + mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@ /dev/mapper/ROOT /mnt +# make directories home, .snapshots, var, tmp + mkdir -p /mnt/{home,var,tmp,.snapshots} +# mount subvolumes + mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@home /dev/mapper/ROOT /mnt/home + mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@.snapshots /dev/mapper/ROOT /mnt/.snapshots + mount -t btrfs /dev/mapper/ROOT /mnt/var fi -else # only two file systems are supported yet - if [[ ${FS} == "btrfs" ]]; then - mkfs.vfat -F32 -n "EFIBOOT" "${DISK}2" - mkfs.btrfs -L "ROOT" "${DISK}3" -f - mount -t btrfs "${DISK}3" /mnt - else - mkfs.vfat -F32 -n "EFIBOOT" "${DISK}2" - mkfs.ext4 -L "ROOT" "${DISK}3" - mount -t ext4 "${DISK}3" /mnt +else + if [[ "${FS}" == "btrfs" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" ${DISK}2 + mkfs.btrfs -f -L ROOT ${DISK}3 + elif [[ "${FS}" == "ext4" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" ${DISK}2 + mkfs.ext4 -L ROOT ${DISK}3 + elif [[ "${FS}" == "luks" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" ${DISK}2 + echo -n "${luks_password}" | cryptsetup -y -v luksFormat ${DISK}3 - + cryptsetup luksOpen ${DISK}3 ROOT + mkfs.ext4 -L ROOT /dev/mapper/ROOT + mount -t btrfs /dev/mapper/ROOT /mnt + btrfs subvolume create /mnt/@ + btrfs subvolume create /mnt/@home + btrfs subvolume create /mnt/@.snapshots + btrfs subvolume create /mnt/@var + btrfs subvolume create /mnt/@tmp + umount /mnt +# mount all the subvolumes + mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@ /dev/mapper/ROOT /mnt +# make directories home, .snapshots, var, tmp + mkdir -p /mnt/{home,var,tmp,.snapshots} + mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@home /dev/mapper/ROOT /mnt/home + mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@.snapshots /dev/mapper/ROOT /mnt/.snapshots + mount -t btrfs /dev/mapper/ROOT /mnt/var fi fi +# checking if user selected btrfs if [[ ${FS} =~ "btrfs" ]]; then ls /mnt | xargs btrfs subvolume delete btrfs subvolume create /mnt/@ diff --git a/1-setup.sh b/1-setup.sh index ed99a8b..0c9d614 100755 --- a/1-setup.sh +++ b/1-setup.sh @@ -108,18 +108,14 @@ echo -ne " Adding User ------------------------------------------------------------------------- " -if ! source install.conf; then - read -p "Please enter username:" username -echo "username=$username" >> ${HOME}/$SCRIPTHOME/install.conf -fi -if [ $(whoami) = "root" ]; -then +if [ $(whoami) = "root" ]; then useradd -m -G wheel,libvirt -s /bin/bash $username - passwd $username +# use chpasswd to enter $username:$password + echo "$username:$password" | chpasswd cp -R /root/$SCRIPTHOME /home/$username/ chown -R $username: /home/$username/$SCRIPTHOME - read -p "Please name your machine:" nameofmachine - echo $nameofmachine > /etc/hostname +# enter $hostname to /etc/hostname + echo $hostname > /etc/hostname else echo "You are already a user proceed with aur installs" fi diff --git a/startup.sh b/startup.sh index 5cfbcb3..0c3d249 100644 --- a/startup.sh +++ b/startup.sh @@ -22,13 +22,18 @@ echo -ne " Please Select your file system for both boot and root 1) btrfs 2) ext4 + 3) luks with btrfs 0) exit " read FS case $FS in 1) echo "FS=btrfs" >> setup.conf;; 2) echo "FS=ext4" >> setup.conf;; -# 3) echo "FS=LUKS" >> setup.conf;; +3) +echo -ne "Please enter your luks password: " +read luks_password +echo "luks_password=$luks_password" >> setup.conf +echo "FS=luks" >> setup.conf;; 0) exit ;; *) echo "Wrong option please select again"; filesystem;; esac @@ -43,7 +48,8 @@ case $answer in y|Y|yes|Yes|YES) echo "timezone=$time_zone" >> setup.conf;; n|N|no|NO|No) - read -p "Please enter your desired timezone e.g. Europe/London :" new_timezone + echo "Please enter your desired timezone e.g. Europe/London :" + read new_timezone echo "timezone=$new_timezone" >> setup.conf;; *) echo "Wrong option. Try again";timezone;; esac @@ -84,7 +90,7 @@ Please select key board layout from this list read -p "Your key boards layout:" keymap echo "keymap=$keymap" >> setup.conf } -diskpart (){ +diskpart () { lsblk echo -ne " ------------------------------------------------------------------------ @@ -98,10 +104,23 @@ Please enter disk to work on: (example /dev/sda): read option echo "DISK=$option" >> setup.conf } +userinfo () { +echo -ne "Please enter username: " +read username +echo "username=$username" >> setup.conf +echo -ne "Please enter your password: " +read password +echo "password=$password" >> setup.conf +echo -ne "Please enter your hostname: " +read hostname +echo "hostname=$hostname" >> setup.conf +} # More features in future # language (){} logo rm -rf setup.conf &>/dev/null +userinfo +clear diskpart clear logo From 29d6e1f36505310b433d37fc0d011304b37a1bab Mon Sep 17 00:00:00 2001 From: farhan Date: Sat, 13 Nov 2021 19:46:10 +0000 Subject: [PATCH 10/12] tried in VB found some errors and made changes for luks implementation --- 0-preinstall.sh | 6 +++--- 1-setup.sh | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/0-preinstall.sh b/0-preinstall.sh index 5e07962..64eb1b2 100755 --- a/0-preinstall.sh +++ b/0-preinstall.sh @@ -79,7 +79,7 @@ if [[ "${DISK}" == "nvme" ]]; then # enter luks password to cryptsetup and format root partition echo -n "${luks_password}" | cryptsetup -y -v luksFormat ${DISK}p3 - # open luks container and ROOT will be place holder - cryptsetup open ${DISK}p3 ROOT + echo -n "${luks_password}" | cryptsetup open ${DISK}p3 ROOT - # now format that container mkfs.btrfs -L ROOT /dev/mapper/ROOT # create subvolumes for btrfs @@ -109,8 +109,8 @@ else elif [[ "${FS}" == "luks" ]]; then mkfs.vfat -F32 -n "EFIBOOT" ${DISK}2 echo -n "${luks_password}" | cryptsetup -y -v luksFormat ${DISK}3 - - cryptsetup luksOpen ${DISK}3 ROOT - mkfs.ext4 -L ROOT /dev/mapper/ROOT + echo -n "${luks_password}" | cryptsetup open ${DISK}3 ROOT - + mkfs.btrfs -L ROOT /dev/mapper/ROOT mount -t btrfs /dev/mapper/ROOT /mnt btrfs subvolume create /mnt/@ btrfs subvolume create /mnt/@home diff --git a/1-setup.sh b/1-setup.sh index 0c9d614..1633cda 100755 --- a/1-setup.sh +++ b/1-setup.sh @@ -119,6 +119,13 @@ if [ $(whoami) = "root" ]; then else echo "You are already a user proceed with aur installs" fi +if [[ ${FS} == "luks" ]]; then +# Making sure to edit mkinitcpio conf if luks is selected +# add encrypt in mkinitcpio.conf before filesystems in hooks + sed -i 's/filesystems/encrypt filesystems/g' /etc/mkinitcpio.conf +# making mkinitcpio with linux kernel + mkinitcpio -p linux +fi echo -ne " ------------------------------------------------------------------------- SYSTEM READY FOR 2-user.sh From a5da808a3821b55f50641acaf2cb2eb2c8253d08 Mon Sep 17 00:00:00 2001 From: farhan Date: Sat, 13 Nov 2021 20:09:03 +0000 Subject: [PATCH 11/12] minor update --- 0-preinstall.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/0-preinstall.sh b/0-preinstall.sh index 64eb1b2..d8e80e4 100755 --- a/0-preinstall.sh +++ b/0-preinstall.sh @@ -97,7 +97,8 @@ if [[ "${DISK}" == "nvme" ]]; then # mount subvolumes mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@home /dev/mapper/ROOT /mnt/home mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@.snapshots /dev/mapper/ROOT /mnt/.snapshots - mount -t btrfs /dev/mapper/ROOT /mnt/var + mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@tmp /dev/mapper/ROOT /mnt/tmp + mount -o subvol=@var /dev/mapper/ROOT /mnt/var fi else if [[ "${FS}" == "btrfs" ]]; then @@ -124,7 +125,8 @@ else mkdir -p /mnt/{home,var,tmp,.snapshots} mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@home /dev/mapper/ROOT /mnt/home mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@.snapshots /dev/mapper/ROOT /mnt/.snapshots - mount -t btrfs /dev/mapper/ROOT /mnt/var + mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@tmp /dev/mapper/ROOT /mnt/tmp + mount -o subvol=@var /dev/mapper/ROOT /mnt/var fi fi # checking if user selected btrfs From 045a13de5ef96882d20152b5e0434239532b8a46 Mon Sep 17 00:00:00 2001 From: farhan Date: Mon, 15 Nov 2021 08:42:34 +0000 Subject: [PATCH 12/12] cleaning preinstall and startup --- 0-preinstall.sh | 39 +++++++++++++++++++++------------------ startup.sh | 2 +- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/0-preinstall.sh b/0-preinstall.sh index d8e80e4..ddc03c9 100755 --- a/0-preinstall.sh +++ b/0-preinstall.sh @@ -65,6 +65,20 @@ echo -ne " Creating Filesystems ------------------------------------------------------------------------- " +createsubvolumes () { + btrfs subvolume create /mnt/@ + btrfs subvolume create /mnt/@home + btrfs subvolume create /mnt/@var + btrfs subvolume create /mnt/@tmp + btrfs subvolume create /mnt/@.snapshots +} + +mountallsubvol () { + mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@home /dev/mapper/ROOT /mnt/home + mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@tmp /dev/mapper/ROOT /mnt/tmp + mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@.snapshots /dev/mapper/ROOT /mnt/.snapshots + mount -o subvol=@var /dev/mapper/ROOT /mnt/var +} if [[ "${DISK}" == "nvme" ]]; then if [[ "${FS}" == "btrfs" ]]; then mkfs.vfat -F32 -n "EFIBOOT" ${DISK}p2 @@ -84,49 +98,38 @@ if [[ "${DISK}" == "nvme" ]]; then mkfs.btrfs -L ROOT /dev/mapper/ROOT # create subvolumes for btrfs mount -t btrfs /dev/mapper/ROOT /mnt - btrfs subvolume create /mnt/@ - btrfs subvolume create /mnt/@home - btrfs subvolume create /mnt/@.snapshots - btrfs subvolume create /mnt/@var - btrfs subvolume create /mnt/@tmp + createsubvolumes umount /mnt # mount @ subvolume mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@ /dev/mapper/ROOT /mnt # make directories home, .snapshots, var, tmp mkdir -p /mnt/{home,var,tmp,.snapshots} # mount subvolumes - mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@home /dev/mapper/ROOT /mnt/home - mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@.snapshots /dev/mapper/ROOT /mnt/.snapshots - mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@tmp /dev/mapper/ROOT /mnt/tmp - mount -o subvol=@var /dev/mapper/ROOT /mnt/var + mountallsubvol fi else if [[ "${FS}" == "btrfs" ]]; then mkfs.vfat -F32 -n "EFIBOOT" ${DISK}2 mkfs.btrfs -f -L ROOT ${DISK}3 + mount -t btrfs ${DISK}3 /mnt elif [[ "${FS}" == "ext4" ]]; then mkfs.vfat -F32 -n "EFIBOOT" ${DISK}2 mkfs.ext4 -L ROOT ${DISK}3 + mount -t ext4 ${DISK}3 /mnt elif [[ "${FS}" == "luks" ]]; then mkfs.vfat -F32 -n "EFIBOOT" ${DISK}2 echo -n "${luks_password}" | cryptsetup -y -v luksFormat ${DISK}3 - echo -n "${luks_password}" | cryptsetup open ${DISK}3 ROOT - mkfs.btrfs -L ROOT /dev/mapper/ROOT mount -t btrfs /dev/mapper/ROOT /mnt - btrfs subvolume create /mnt/@ - btrfs subvolume create /mnt/@home - btrfs subvolume create /mnt/@.snapshots - btrfs subvolume create /mnt/@var - btrfs subvolume create /mnt/@tmp + createsubvolumes umount /mnt # mount all the subvolumes mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@ /dev/mapper/ROOT /mnt # make directories home, .snapshots, var, tmp mkdir -p /mnt/{home,var,tmp,.snapshots} - mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@home /dev/mapper/ROOT /mnt/home - mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@.snapshots /dev/mapper/ROOT /mnt/.snapshots - mount -o noatime,compress=zstd,space_cache,commit=120,subvol=@tmp /dev/mapper/ROOT /mnt/tmp - mount -o subvol=@var /dev/mapper/ROOT /mnt/var +# mount subvolumes + mountallsubvol fi fi # checking if user selected btrfs diff --git a/startup.sh b/startup.sh index 0c3d249..bc5f0c9 100644 --- a/startup.sh +++ b/startup.sh @@ -117,10 +117,10 @@ echo "hostname=$hostname" >> setup.conf } # More features in future # language (){} -logo rm -rf setup.conf &>/dev/null userinfo clear +logo diskpart clear logo