From 19f6fb2d775d180c906195b3b9ba43fa57a8ab8c Mon Sep 17 00:00:00 2001 From: Muhammad Rivan Date: Sat, 12 Jun 2021 14:01:28 +0700 Subject: [PATCH] Improve stability --- install.sh | 8 +++++--- lib-core.sh | 2 +- lib-install.sh | 30 +++++++++++++++++++----------- tweaks.sh | 4 +++- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/install.sh b/install.sh index 7aed090..6b87bfc 100755 --- a/install.sh +++ b/install.sh @@ -51,6 +51,8 @@ usage() { #-----------------------------PARSE ARGUMENTS---------------------------------# +echo + while [[ $# -gt 0 ]]; do # Don't show any dialog here. Let this loop checks for errors or shows help # We can only show dialogs when there's no error and no -r parameter @@ -117,8 +119,6 @@ if [[ "${uninstall}" == 'true' ]]; then remove_themes prompt -s "Done! All '${name}' themes has been removed." else - echo - if [[ "${interactive}" == 'true' ]]; then show_panel_opacity_dialog; show_sidebar_size_dialog; show_nautilus_style_dialog echo; prompt -w "DIALOG: '--size' and '--panel' parameters are ignored if exist."; echo @@ -152,6 +152,8 @@ else notif_msg="${final_msg}" fi - echo; prompt -w "${final_msg}"; echo + echo; prompt -w "${final_msg}" [[ -x /usr/bin/notify-send ]] && notify-send "'${name}' theme has been installed. Enjoy!" "${notif_msg}" -i "dialog-information-symbolic" fi + +echo diff --git a/lib-core.sh b/lib-core.sh index 92eb676..a0aaba8 100755 --- a/lib-core.sh +++ b/lib-core.sh @@ -640,7 +640,7 @@ sudo() { } udo() { - local result="1" + local result="0" # Just in case. We put the prompt here to make it less annoying if ! ${SUDO_BIN} -u "${MY_USERNAME}" -n true &> /dev/null; then diff --git a/lib-install.sh b/lib-install.sh index caf9539..1d9fbd3 100755 --- a/lib-install.sh +++ b/lib-install.sh @@ -55,15 +55,23 @@ installation_sorry() { } prepare_deps() { - local head="$(curl -Is -o - 'time.cloudflare.com' || wget -Sq -o - --max-redirect=0 'time.cloudflare.com')" - local remote_time="$(echo "${head}" | awk -F ': ' '/Date/{print $2}')" - local remote_time_int="$(date --date "${remote_time}" +"%Y%m%d")" - local local_time_int="$(date -u +"%Y%m%d")" + local head="" + local remote_time="" + local local_time="" - if (( remote_time_int > local_time_int )); then - prompt -w "\n DEPS: Your system clock is wrong" - prompt -i "DEPS: Updating your system clock...\n" - sudo date -s "${remote_time}"; sudo hwclock --systohc + prompt -i "DEPS: Checking your internet connection..." + + if ! head="$(curl -Is -o - 'time.cloudflare.com' || wget -Sq -o - --max-redirect=0 'time.cloudflare.com')"; then + prompt -e "DEPS ERROR: You have an internet connection issue\n"; exit 1 + fi + + remote_time="$(echo "${head}" | awk -F ': ' '/Date/{print $2}' | date -f - "+%s")" + local_time="$(date -u "+%s")" + + if (( remote_time-(5*60) > local_time )); then + prompt -w "DEPS: Your system clock is wrong" + prompt -i "DEPS: Updating your system clock..." + sudo date -s "@${remote_time}"; sudo hwclock --systohc fi } @@ -142,7 +150,7 @@ prepare_xbps() { install_theme_deps() { if ! has_command glib-compile-resources || ! has_command sassc || ! has_command xmllint || (! is_my_distro "clear-linux" && [[ ! -r "/usr/share/gtk-engines/murrine.xml" ]]); then - prompt -w "'glib2.0', 'sassc', 'xmllint', and 'libmurrine' are required for theme installation." + prompt -w "DEPS: 'glib2.0', 'sassc', 'xmllint', and 'libmurrine' are required for theme installation." prepare_deps if has_command zypper; then @@ -174,7 +182,7 @@ install_theme_deps() { install_beggy_deps() { if ! has_command convert; then - prompt -w "'imagemagick' are required for background editing." + prompt -w "DEPS: 'imagemagick' is required for background editing." prepare_deps if has_command zypper; then @@ -202,7 +210,7 @@ install_beggy_deps() { install_dialog_deps() { if ! has_command dialog; then - prompt -w "'dialog' is required for this option." + prompt -w "DEPS: 'dialog' is required for this option." prepare_deps if has_command zypper; then diff --git a/tweaks.sh b/tweaks.sh index b2d1449..678e6a3 100755 --- a/tweaks.sh +++ b/tweaks.sh @@ -43,6 +43,8 @@ usage() { #-----------------------------PARSE ARGUMENTS---------------------------------# +echo + while [[ $# -gt 0 ]]; do # Don't show any dialog here. Let this loop checks for errors or shows help # We can only show dialogs when there's no error and no -r parameter @@ -137,7 +139,7 @@ finalize_argument_parsing #---------------------------START INSTALL THEMES-------------------------------# if [[ "${uninstall}" == 'true' ]]; then - echo; prompt -w "REMOVAL: Non file-related parameters will be ignored." + prompt -w "REMOVAL: Non file-related parameters will be ignored." if [[ "${gdm}" == 'true' ]]; then echo; prompt -i "Removing '${name}' GDM theme..."