Skip to content

Commit

Permalink
Fixed #126
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceliuice committed Jun 15, 2021
1 parent ab5ba9c commit 5a31c8d
Showing 1 changed file with 37 additions and 32 deletions.
69 changes: 37 additions & 32 deletions install.sh
Expand Up @@ -390,8 +390,42 @@ remove() {
fi
}

dialog_installer() {
if [[ ! -x /usr/bin/dialog ]]; then
if [[ $UID -ne $ROOT_UID ]]; then
#Check if password is cached (if cache timestamp not expired yet)
sudo -n true 2> /dev/null && echo

if [[ $? == 0 ]]; then
#No need to ask for password
exec sudo $0
else
#Ask for password
prompt -e "\n [ Error! ] -> Run me as root! "
read -p " [ Trusted ] Specify the root password : " -t ${MAX_DELAY} -s

sudo -S echo <<< $REPLY 2> /dev/null && echo

if [[ $? == 0 ]]; then
#Correct password, use with sudo's stdin
sudo $0 <<< $REPLY
else
#block for 3 seconds before allowing another attempt
sleep 3
prompt -e "\n [ Error! ] -> Incorrect password!\n"
exit 1
fi
fi
fi
install_dialog
fi
run_dialog
install "${theme}" "${icon}" "${screen}"
}

while [[ $# -gt 0 ]]; do
PROG_ARGS+=("${1}")
dialog='false'
case "${1}" in
-b|--boot)
THEME_DIR="/boot/grub/themes"
Expand Down Expand Up @@ -511,38 +545,7 @@ while [[ $# -gt 0 ]]; do
done

# Show terminal user interface for better use
if [[ $# -eq 0 ]]; then
if [[ ! -x /usr/bin/dialog ]]; then
if [[ $UID -ne $ROOT_UID ]]; then
#Check if password is cached (if cache timestamp not expired yet)
sudo -n true 2> /dev/null && echo

if [[ $? == 0 ]]; then
#No need to ask for password
exec sudo $0
else
#Ask for password
prompt -e "\n [ Error! ] -> Run me as root! "
read -p " [ Trusted ] Specify the root password : " -t ${MAX_DELAY} -s

sudo -S echo <<< $REPLY 2> /dev/null && echo

if [[ $? == 0 ]]; then
#Correct password, use with sudo's stdin
sudo $0 <<< $REPLY
else
#block for 3 seconds before allowing another attempt
sleep 3
prompt -e "\n [ Error! ] -> Incorrect password!\n"
exit 1
fi
fi
fi
install_dialog
fi
run_dialog
install "${theme}" "${icon}" "${screen}"
else
if [[ "${dialog:-}" == 'false' ]]; then
if [[ "${remove:-}" != 'true' ]]; then
for theme in "${themes[@]-${THEME_VARIANTS[0]}}"; do
for icon in "${icons[@]-${ICON_VARIANTS[0]}}"; do
Expand All @@ -556,6 +559,8 @@ else
remove "${theme}"
done
fi
else
dialog_installer
fi

exit 1

0 comments on commit 5a31c8d

Please sign in to comment.