Update install.sh

This commit is contained in:
proledatarian 2022-02-14 13:48:27 +00:00
parent 422b0edb0d
commit 95c84238ed
1 changed files with 55 additions and 31 deletions

View File

@ -1,8 +1,22 @@
#!/bin/bash #!/bin/bash
### Variables:
# $dsks = whole lsblk output (e.g. "sda 1,0T, sdb ..")
# $disk = only selected disk (e.g. "sdc 500G")
# $dev = selected disk without size (e.g. "sdd")
# $main = main partition (e.g. "sde2")
# $szmn = size of the main partition (e.g. "50")
# szrt = size of root LVM volume
# $boot = boot partition (e.g. "sdf1")
# $host = hostname
# $user = username
# $pwur = user password
# $pwrt = root password
# $pwcr = encryption password
# Friendly introduction. # Friendly introduction.
echo "Welcome to the Arch Linux installation script!" echo "Welcome to the Arch Linux installation script!"
echo "This script will ERASE ALL DATA on the partition you choose in the next step." echo "This script will ERASE ALL DATA on the partition you will choose next!"
echo echo
read -p "Do you want to continue? Type [Y]es or [N]o. " -n 1 -r read -p "Do you want to continue? Type [Y]es or [N]o. " -n 1 -r
echo # (optional) move to a new line echo # (optional) move to a new line
@ -29,6 +43,42 @@ declare -a dsks
select dev in ${dsks[*]} select dev in ${dsks[*]}
do do
echo "Choose a strong password for encrypting the primary partition:"
while [ -z "$pwcr" ]; do
echo "Please enter a password: "
read -s pwfr
read -s -p "Retype a password: " pwsc
if [ $pwfr == $pwsc ];
then
pwcr=$pwfr
echo
echo "Both passwords are the same. Continuing.."
else
echo
echo "You have entered different passwords. Try again.."
fi
# Ask for everything that is necessary later.
#echo "Before installing the system, please enter a hostname:"
#echo
#read host
#echo
#echo "Please enter a password for the root account:"
#read pwr
#echo
#echo "And please enter a username:"
#read user
#echo
#
#echo "Also please enter a password for your user:"
#read pwu
#echo
#
#echo "System is getting installed.."
#echo
# Separate values by spaces. # Separate values by spaces.
IFS=' ' IFS=' '
@ -66,33 +116,28 @@ lsblk | grep "$dev"
sleep 1 sleep 1
echo echo
# This needs to be deleted.
echo $dev > /tmp/dev
# Exit. # Exit.
break break
done done
# This needs to be deleted. # Get new variable.
# Get variable from filesystem. main=$(dev)2
main=$(</tmp/dev)2
# Encrypting partition. # Encrypting partition.
echo "Encrypting system partition. This might take a while." echo "Encrypting system partition. This might take a while."
echo echo
cryptsetup -c aes-xts-plain -y -s 512 luksFormat /dev/$main && echo -en "&pwcr\n$pwcr" | cryptsetup -c aes-xts-plain -s 512 luksFormat /dev/$main &&
echo "Partition successfully encrypted." echo "Partition successfully encrypted."
echo echo
# Opening encrypted partition and mounting at /dev/mapper/lvm. # Opening encrypted partition and mounting at /dev/mapper/lvm.
echo "Decrypting.. This also might take a while." echo "Decrypting.. This also might take a while."
echo echo
cryptsetup luksOpen /dev/$main lvm && echo -en "&pwcr\n$pwcr" | cryptsetup luksOpen /dev/$main lvm &&
echo "Partition successfully opened." echo "Partition successfully opened."
echo echo
dev="${main%?}"
lsblk | grep "$dev" lsblk | grep "$dev"
echo echo
@ -106,27 +151,6 @@ read szrt
echo "Creating a $szrt GB root volume.." echo "Creating a $szrt GB root volume.."
echo echo
# Ask for everything that is necessary later.
#echo "Before installing the system, please enter a hostname:"
#echo
#read host
#echo
#echo "Please enter a password for the root account:"
#read pwr
#echo
#echo "And please enter a username:"
#read user
#echo
#
#echo "Also please enter a password for your user:"
#read pwu
#echo
#
#echo "System is getting installed.."
#echo
# Creating physical volume. # Creating physical volume.
echo "Creating physical volume." echo "Creating physical volume."
pvcreate /dev/mapper/lvm && pvcreate /dev/mapper/lvm &&