added luks with btrfs and asking user for username and password at satrtup
This commit is contained in:
parent
aed6172115
commit
9d04a59500
|
|
@ -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/@
|
||||
|
|
|
|||
14
1-setup.sh
14
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
|
||||
|
|
|
|||
25
startup.sh
25
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue