Save and load username (w/o export)

This commit is contained in:
Santiago Lo Coco 2021-12-30 13:58:45 -03:00
parent dd74a98a35
commit 962b795308
1 changed files with 10 additions and 1 deletions

View File

@ -257,8 +257,16 @@ grubSetUp() {
runInChroot "grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB; grub-mkconfig -o /boot/grub/grub.cfg" > /dev/null 2>&1 runInChroot "grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB; grub-mkconfig -o /boot/grub/grub.cfg" > /dev/null 2>&1
} }
saveUsername() {
echo $username > CocoASAIS.vars
}
loadUsername() {
username=$(cat CocoASAIS.vars)
}
userSetUp() { userSetUp() {
export username=$(whiptail --inputbox "Enter the new username." 0 0 3>&1 1>&2 2>&3) username=$(whiptail --inputbox "Enter the new username." 0 0 3>&1 1>&2 2>&3) && saveUsername
exitIfCancel "You must enter an username." "userSetUp" exitIfCancel "You must enter an username." "userSetUp"
askForPassword "${username}" "userSetUp" askForPassword "${username}" "userSetUp"
runInChroot "useradd -m ${username};echo "${username}:${password}" | chpasswd; sed -i 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers; usermod -aG wheel ${username}" runInChroot "useradd -m ${username};echo "${username}:${password}" | chpasswd; sed -i 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers; usermod -aG wheel ${username}"
@ -276,6 +284,7 @@ EOF
installNotImportantPackages() { installNotImportantPackages() {
calcHeightAndRun "whiptail --msgbox \"Now, we will install a few more packages (in the background). Press OK and wait (it may take some time).\" HEIGHT 60 3>&1 1>&2 2>&3" calcHeightAndRun "whiptail --msgbox \"Now, we will install a few more packages (in the background). Press OK and wait (it may take some time).\" HEIGHT 60 3>&1 1>&2 2>&3"
loadUsername
checkForParu checkForParu
getThePackages "N" "installNotImportantPackages" getThePackages "N" "installNotImportantPackages"
runInChroot "sed -i 's/^%wheel ALL=(ALL) NOPASSWD: ALL/# %wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers" runInChroot "sed -i 's/^%wheel ALL=(ALL) NOPASSWD: ALL/# %wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers"