Add generic loadVar() and saveVar()
This commit is contained in:
parent
76dabb2407
commit
f562bae1ba
40
install.sh
40
install.sh
|
@ -185,12 +185,14 @@ mountPart() {
|
||||||
fi
|
fi
|
||||||
mount "$bootPart" "/mnt/$bootPath" 2>&1 | debug
|
mount "$bootPart" "/mnt/$bootPath" 2>&1 | debug
|
||||||
else
|
else
|
||||||
mkdir -p /mnt/boot/efi
|
bootPath="boot/efi"
|
||||||
mount "$bootPart" /mnt/boot/efi 2>&1 | debug
|
mkdir -p /mnt/$bootPath
|
||||||
|
mount "$bootPart" /mnt/$bootPath 2>&1 | debug
|
||||||
fi
|
fi
|
||||||
printWaitBox
|
printWaitBox
|
||||||
[ -n "$swapPart" ] && swapon "$swapPart" 2>&1 | debug
|
[ -n "$swapPart" ] && swapon "$swapPart" 2>&1 | debug
|
||||||
[ -n "$swapfile" ] && createSwapfile
|
[ -n "$swapfile" ] && createSwapfile
|
||||||
|
saveVar "bootPath" "/$bootPath"
|
||||||
}
|
}
|
||||||
|
|
||||||
debug() {
|
debug() {
|
||||||
|
@ -394,21 +396,32 @@ updateMirrors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
grubSetUp() {
|
grubSetUp() {
|
||||||
# TODO: Prompt user for efi-directory
|
|
||||||
printWaitBox
|
printWaitBox
|
||||||
runInChroot "grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB; grub-mkconfig -o /boot/grub/grub.cfg" 2>&1 | debug
|
[ -z $bootPath ] && loadVar "bootPath"
|
||||||
|
runInChroot "grub-install --target=x86_64-efi --efi-directory=${bootPath} --bootloader-id=GRUB; grub-mkconfig -o /boot/grub/grub.cfg" 2>&1 | debug
|
||||||
}
|
}
|
||||||
|
|
||||||
saveUsername() {
|
saveVar() {
|
||||||
echo $username > CocoASAIS.vars
|
[ ! -f "CocoASAIS.vars" ] && touch CocoASAIS.vars
|
||||||
|
if [ -z "$(grep "$1" CocoASAIS.vars)" ]; then
|
||||||
|
echo "$1=$2" >> CocoASAIS.vars
|
||||||
|
else
|
||||||
|
sed -i "s|$1=.*|$1=$2|" CocoASAIS.vars
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
loadUsername() {
|
loadVar() {
|
||||||
username=$(cat CocoASAIS.vars)
|
var=$(grep "$1=" CocoASAIS.vars | cut -d= -f2)
|
||||||
|
if [ -z $var ]; then
|
||||||
|
echo "Couldn't load '$1'. Try to run the script again." 1>&2
|
||||||
|
rm -f CocoASAIS.log CocoASAIS.vars
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
export $1=$var
|
||||||
}
|
}
|
||||||
|
|
||||||
userSetUp() {
|
userSetUp() {
|
||||||
username=$(whiptail --inputbox "Enter the new username." 0 0 3>&1 1>&2 2>&3) && saveUsername
|
username=$(whiptail --inputbox "Enter the new username." 0 0 3>&1 1>&2 2>&3) && saveVar "username" "$username"
|
||||||
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}"
|
||||||
|
@ -426,7 +439,7 @@ EOF
|
||||||
|
|
||||||
installOtherPackages() {
|
installOtherPackages() {
|
||||||
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"
|
||||||
[ -z $username ] && loadUsername
|
[ -z $username ] && loadVar "username"
|
||||||
getThePackages "S" "installOtherPackages"
|
getThePackages "S" "installOtherPackages"
|
||||||
checkForParu
|
checkForParu
|
||||||
getThePackages "N" "installOtherPackages"
|
getThePackages "N" "installOtherPackages"
|
||||||
|
@ -437,7 +450,7 @@ installOtherPackages() {
|
||||||
finishInstallation() {
|
finishInstallation() {
|
||||||
cp CocoASAIS /mnt/usr/bin/CocoASAIS
|
cp CocoASAIS /mnt/usr/bin/CocoASAIS
|
||||||
echo "sh /usr/bin/CocoASAIS && logout" >> /mnt/home/slococo/.bashrc
|
echo "sh /usr/bin/CocoASAIS && logout" >> /mnt/home/slococo/.bashrc
|
||||||
rm /mnt/cocoScript
|
rm -f /mnt/cocoScript
|
||||||
umount -R /mnt
|
umount -R /mnt
|
||||||
whiptail --yesno "Finally, the PC needs to restart, would you like to restart now?" 0 0
|
whiptail --yesno "Finally, the PC needs to restart, would you like to restart now?" 0 0
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
|
@ -486,6 +499,10 @@ checkForSystemdUnit() {
|
||||||
trap - INT
|
trap - INT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# createVarsFile() {
|
||||||
|
# echo ""
|
||||||
|
# }
|
||||||
|
|
||||||
steps=(
|
steps=(
|
||||||
checkUefi
|
checkUefi
|
||||||
updateSystemClock
|
updateSystemClock
|
||||||
|
@ -548,6 +565,7 @@ runScript() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
whiptail --title "CocoASAIS" --msgbox "${welcomeMsg}" 0 0
|
whiptail --title "CocoASAIS" --msgbox "${welcomeMsg}" 0 0
|
||||||
|
createVarsFile
|
||||||
|
|
||||||
while [ $i -le "${#steps[@]}" ]; do
|
while [ $i -le "${#steps[@]}" ]; do
|
||||||
${steps[$i]}
|
${steps[$i]}
|
||||||
|
|
Loading…
Reference in New Issue