Add calcHeightAndRun()
This commit is contained in:
parent
ac6d07679a
commit
dfa108fe19
15
install.sh
15
install.sh
|
@ -161,7 +161,7 @@ getThePackages() {
|
|||
}
|
||||
|
||||
installImportantPackages() {
|
||||
whiptail --msgbox "We will start by installing some important packages in the background. Please press OK and wait." 0 0
|
||||
calcHeightAndRun "whiptail --msgbox \"We will start by installing some important packages in the background. Please press OK and wait.\" 8 HEIGHT"
|
||||
getThePackages "Y" "installImportantPackages"
|
||||
runInChroot "systemctl enable NetworkManager; systemctl enable fstrim.timer" 2> /dev/null
|
||||
}
|
||||
|
@ -207,6 +207,17 @@ calcWidthAndRun() {
|
|||
echo $(eval $(echo "$@" | sed "s/WIDTH/$((${width}+8))/g"))
|
||||
}
|
||||
|
||||
calcHeightAndRun() {
|
||||
str=$(echo "$@" | grep -oP '(?<=").*?(?=")')
|
||||
newlines=$(printf "$str" | grep -c $'\n')
|
||||
chars=$(echo "$str" | wc -c)
|
||||
height=$(echo "$chars" "$newlines" | awk '{
|
||||
x = (($1 - $2 + ($2 * 60)) / 60)
|
||||
printf "%d", (x == int(x)) ? x : int(x) + 1
|
||||
}')
|
||||
echo $(eval $(echo "$@" | sed "s/HEIGHT/$((5+$height))/g"))
|
||||
}
|
||||
|
||||
askForPassword() {
|
||||
password=$(calcWidthAndRun "whiptail --passwordbox \"Now, enter the password for ${1}.\" 8 WIDTH 3>&1 1>&2 2>&3")
|
||||
exitIfCancel "You must enter a password." "${2}"
|
||||
|
@ -263,7 +274,7 @@ EOF
|
|||
}
|
||||
|
||||
installNotImportantPackages() {
|
||||
whiptail --msgbox "Now, we will install a few more packages (in the background). Press OK and note that it may take a long time, please wait." 0 0
|
||||
calcHeightAndRun "whiptail --msgbox \"Now, we will install a few more packages (in the background). Press OK and wait (it may take some time).\" 8 HEIGHT"
|
||||
checkForParu
|
||||
getThePackages "N" "installNotImportantPackages"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue