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