Add log and update partDisks()

This commit is contained in:
Santiago Lo Coco 2021-12-25 22:11:22 -03:00
parent a3e506e2cc
commit 15fe4d838a
1 changed files with 69 additions and 24 deletions

View File

@ -11,10 +11,15 @@ formatOptions() {
done done
} }
logStep() {
echo ${1} > CocoASAIS.log
}
checkUefi() { checkUefi() {
ls /sys/firmware/efi/efivars > /dev/null 2>&1 ls /sys/firmware/efi/efivars > /dev/null 2>&1
if [ $? -ge 1 ]; then if [ $? -ge 1 ]; then
whiptail --msgbox "This scripts supports only UEFI boot mode." 0 0 whiptail --msgbox "This scripts supports only UEFI boot mode." 0 0
logStep "checkUefi"
exit 1 exit 1
fi fi
} }
@ -23,31 +28,49 @@ updateSystemClock() {
timedatectl set-ntp true timedatectl set-ntp true
} }
showDisks() { exitIfCancel() {
local IFS=$'\n' if [ $? -eq 1 ]; then
setDelimiters "" whiptail --msgbox "${1}" 0 0
formatOptions $(lsblk -d -p -n -l -o NAME,SIZE -e 7,11) echo "${2}" > CocoASAIS.log
exit 1
result=$(whiptail --title "Select a disk" --menu "" 0 0 0 "${options[@]}" 3>&1 1>&2 2>&3) fi
disk=$(echo $result | cut -d' ' -f1)
echo $disk
} }
partDisks() { partDisks() {
showDisks local IFS=$'\n'
setDelimiters ""
formatOptions $(lsblk -dpnlo NAME,SIZE)
result=$(whiptail --title "Select a disk." --menu "" 0 0 0 "${options[@]}" 3>&1 1>&2 2>&3)
exitIfCancel "You must select a disk." "partDisks"
disk=$(echo $result | cut -d' ' -f1)
# TODO: Add swapfile as an alternative to swap partition
whiptail --yesno "Do you want me to automatically partition and format the disk for you?" 0 0 whiptail --yesno "Do you want me to automatically partition and format the disk for you?" 0 0
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
whiptail --msgbox "You will partition the disk yourself with gdisk and then when finished you will continue with the installation." 0 0
gdisk $disk gdisk $disk
# TODO: ask user for the partitions and do formatPart and mountPart. # TODO: Ask for home partition
return formatOptions $(lsblk ${disk} -pnlo NAME,SIZE,MOUNTPOINTS | sed -n '2~1p')
result=$(whiptail --title "Select the boot partition." --menu "" 0 0 0 "${options[@]}" 3>&1 1>&2 2>&3)
exitIfCancel "You must select the boot partition." "partDisks"
bootPart=$(echo $result | cut -d' ' -f1)
result=$(whiptail --title "Select the root partition." --menu "" 0 0 0 "${options[@]}" 3>&1 1>&2 2>&3)
exitIfCancel "You must select the root partition." "partDisks"
rootPart=$(echo $result | cut -d' ' -f1)
whiptail --yesno "Do you have a swap partition?" 0 0
if [ $? -eq 1 ]; then
result=$(whiptail --title "Select the swap partition." --menu "" 0 0 0 "${options[@]}" 3>&1 1>&2 2>&3)
exitIfCancel "You must select the swap partition." "partDisks"
swapPart=$(echo $result | cut -d' ' -f1)
fi
else
autoPart
bootPart=${disk}1
swapPart=${disk}2
rootPart=${disk}3
fi fi
autoPart
bootPart=${disk}1
swapPart=${disk}2
rootPart=${disk}3
formatPart formatPart
mountPart mountPart
} }
@ -132,7 +155,6 @@ installPackage() {
} }
installMorePackages() { installMorePackages() {
# runInChroot "pacman -Sy --noconfirm grub efibootmgr networkmanager base-devel linux-headers xdg-user-dirs xdg-utils alsa-utils pipewire pipewire-alsa pipewire-pulse sudo nvidia-utils nvidia-settings"
pacstrap /mnt grub efibootmgr networkmanager base-devel linux-headers xdg-user-dirs xdg-utils alsa-utils pipewire pipewire-alsa pipewire-pulse sudo nvidia-utils nvidia-settings pacstrap /mnt grub efibootmgr networkmanager base-devel linux-headers xdg-user-dirs xdg-utils alsa-utils pipewire pipewire-alsa pipewire-pulse sudo nvidia-utils nvidia-settings
runInChroot "systemctl enable NetworkManager; systemctl enable fstrim.timer" runInChroot "systemctl enable NetworkManager; systemctl enable fstrim.timer"
} }
@ -195,13 +217,7 @@ getDotfiles() {
cd $lastFolder cd $lastFolder
} }
runScript() { steps=(
if [ -d "$HOME/Documents" ]; then
getDotfiles
exit 1
fi
whiptail --title "CocoASAIS" --msgbox "Welcome to CocoASAIS!" 0 0
checkUefi checkUefi
updateSystemClock updateSystemClock
partDisks partDisks
@ -216,6 +232,35 @@ runScript() {
grubSetUp grubSetUp
userSetUp userSetUp
finishInstallation finishInstallation
)
runScript() {
if [ -d "$HOME/Documents" ]; then
getDotfiles
exit 0
fi
i=0; found=false
if [ -f "CocoASAIS.log" ]; then
lastStep=$(cat CocoASAIS.log)
for item in "${steps[@]}"; do
if [ $item = "$lastStep" ]; then
found=true
break
fi
((i++))
done
if [ $found = false ]; then
i=0
fi
fi
whiptail --title "CocoASAIS" --msgbox "Welcome to CocoASAIS!" 0 0
while [ $i -le "${#steps[@]}" ]; do
${steps[$i]}
((i++))
done
} }
runScript runScript