From ab5ba9cf78eadc518a70c5e6b0506070c54d2f9e Mon Sep 17 00:00:00 2001 From: vinceliuice Date: Wed, 2 Jun 2021 13:15:05 +0800 Subject: [PATCH] update --- install.sh | 87 +++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/install.sh b/install.sh index c043bac..b8edaa9 100755 --- a/install.sh +++ b/install.sh @@ -390,39 +390,6 @@ remove() { fi } -# 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 -fi - while [[ $# -gt 0 ]]; do PROG_ARGS+=("${1}") case "${1}" in @@ -543,18 +510,52 @@ while [[ $# -gt 0 ]]; do esac done -if [[ "${remove:-}" != 'true' ]]; then - for theme in "${themes[@]-${THEME_VARIANTS[0]}}"; do - for icon in "${icons[@]-${ICON_VARIANTS[0]}}"; do - for screen in "${screens[@]-${SCREEN_VARIANTS[0]}}"; do - install "${theme}" "${icon}" "${screen}" +# 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 [[ "${remove:-}" != 'true' ]]; then + for theme in "${themes[@]-${THEME_VARIANTS[0]}}"; do + for icon in "${icons[@]-${ICON_VARIANTS[0]}}"; do + for screen in "${screens[@]-${SCREEN_VARIANTS[0]}}"; do + install "${theme}" "${icon}" "${screen}" + done done done - done -elif [[ "${remove:-}" == 'true' ]]; then - for theme in "${themes[@]-${THEME_VARIANTS[0]}}"; do - remove "${theme}" - done + elif [[ "${remove:-}" == 'true' ]]; then + for theme in "${themes[@]-${THEME_VARIANTS[0]}}"; do + remove "${theme}" + done + fi fi exit 1