Update install.sh
This commit is contained in:
		
							
								
								
									
										86
									
								
								install.sh
									
									
									
									
									
								
							
							
						
						
									
										86
									
								
								install.sh
									
									
									
									
									
								
							@@ -1,8 +1,22 @@
 | 
			
		||||
#!/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.
 | 
			
		||||
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
 | 
			
		||||
read -p "Do you want to continue? Type [Y]es or [N]o. " -n 1 -r
 | 
			
		||||
echo    # (optional) move to a new line
 | 
			
		||||
@@ -29,6 +43,42 @@ declare -a dsks
 | 
			
		||||
select dev in ${dsks[*]}
 | 
			
		||||
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.
 | 
			
		||||
IFS=' '
 | 
			
		||||
 | 
			
		||||
@@ -66,33 +116,28 @@ lsblk | grep "$dev"
 | 
			
		||||
sleep 1
 | 
			
		||||
echo
 | 
			
		||||
 | 
			
		||||
# This needs to be deleted.
 | 
			
		||||
echo $dev > /tmp/dev
 | 
			
		||||
 | 
			
		||||
# Exit.
 | 
			
		||||
break
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
# This needs to be deleted.
 | 
			
		||||
# Get variable from filesystem.
 | 
			
		||||
main=$(</tmp/dev)2
 | 
			
		||||
# Get new variable.
 | 
			
		||||
main=$(dev)2
 | 
			
		||||
 | 
			
		||||
# Encrypting partition.
 | 
			
		||||
echo "Encrypting system partition. This might take a while."
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
# Opening encrypted partition and mounting at /dev/mapper/lvm.
 | 
			
		||||
echo "Decrypting.. This also might take a while."
 | 
			
		||||
echo
 | 
			
		||||
cryptsetup luksOpen /dev/$main lvm &&
 | 
			
		||||
echo -en "&pwcr\n$pwcr" | cryptsetup luksOpen /dev/$main lvm &&
 | 
			
		||||
echo "Partition successfully opened."
 | 
			
		||||
echo
 | 
			
		||||
 | 
			
		||||
dev="${main%?}"
 | 
			
		||||
lsblk | grep "$dev"
 | 
			
		||||
echo
 | 
			
		||||
 | 
			
		||||
@@ -106,27 +151,6 @@ read szrt
 | 
			
		||||
echo "Creating a $szrt GB root volume.."
 | 
			
		||||
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.
 | 
			
		||||
echo "Creating physical volume."
 | 
			
		||||
pvcreate /dev/mapper/lvm &&
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user