From 5411dcdee309a6d77029e3978e8ec3d56105701d Mon Sep 17 00:00:00 2001 From: Bernhard Landauer Date: Thu, 22 Jun 2017 00:03:04 +0200 Subject: [PATCH] move privilege check to the start - else when running as non-root you get a bunch of errors already during language config. Also anyway doesn't make sense to do anything as user... ;) --- bin/manjaro-architect.in | 3 ++- lib/util.sh | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bin/manjaro-architect.in b/bin/manjaro-architect.in index 0f77fe3..30a4223 100644 --- a/bin/manjaro-architect.in +++ b/bin/manjaro-architect.in @@ -37,9 +37,10 @@ case $(tty) in /dev/tty[0-9]*) setterm -blank 0 -powersave off ;; esac +check_root id_system set_language mk_connection -check_requirements +check_connection greeting main_menu diff --git a/lib/util.sh b/lib/util.sh index 79c1b14..c90c4aa 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -131,6 +131,15 @@ submenu() { fi } +check_root() { + if [[ `whoami` != "root" ]]; then + DIALOG " $_ErrTitle " --infobox "\n$_RtFailBody\n " 0 0 + sleep 3 + clear + exit 1 + fi +} + # Adapted from AIS. Checks if system is made by Apple, whether the system is BIOS or UEFI, # and for LVM and/or LUKS. id_system() { @@ -354,23 +363,17 @@ mk_connection() { # Check user is root, and that there is an active internet connection # Seperated the checks into seperate "if" statements for readability. -check_requirements() { - DIALOG " $_ChkTitle " --infobox "\n$_ChkBody\n " 0 0 - sleep 2 - - if [[ `whoami` != "root" ]]; then - DIALOG " $_Erritle " --infobox "\n$_RtFailBody\n " 0 0 - sleep 2 - exit 1 - fi +check_connection() { +# DIALOG " $_ChkTitle " --infobox "\n$_ChkBody\n " 0 0 +# sleep 2 if [[ ! $(ping -c 1 google.com) ]]; then DIALOG " $_ErrTitle " --infobox "\n$_ConFailBody\n " 0 0 - sleep 2 + sleep 3 + clear exit 1 fi - # This will only be executed where neither of the above checks are true. # The error log is also cleared, just in case something is there from a previous use of the installer. DIALOG " $_ReqMetTitle " --infobox "\n$_ReqMetBody\n\n$_UpdDb\n " 0 0 sleep 2