From 51af650e999d6762a92f0263d6b27fe44cd2a83b Mon Sep 17 00:00:00 2001 From: maride Date: Thu, 31 Aug 2017 16:27:55 +0200 Subject: [PATCH] Move to 'source' and own return value variable --- checks/internet.check | 4 ++-- checks/uefi.check | 6 +++--- install.sh | 13 +++++-------- steps/10-wipe.step | 22 +++++++++++----------- steps/20-partition.step | 4 ++-- steps/60-user.step | 4 ++-- 6 files changed, 25 insertions(+), 28 deletions(-) diff --git a/checks/internet.check b/checks/internet.check index 6fef428..a0f07a4 100755 --- a/checks/internet.check +++ b/checks/internet.check @@ -4,9 +4,9 @@ ping -c 1 archlinux.org 2>/tmp/arch-maride-flavour_checks_internet_error.log 1>/ return=$? if [ "$return" -eq 0 ]; then - exit 0 + amf_return=0 else echo "~> Either internet is unavailable or archlinux.org is down..." echo "~> (ping returned $return. Maybe check the logs in /tmp." - exit 1 + amf_return=1 fi diff --git a/checks/uefi.check b/checks/uefi.check index 3ccc69a..f8f65b8 100755 --- a/checks/uefi.check +++ b/checks/uefi.check @@ -2,15 +2,15 @@ if [ "$bootloader" == "EFI" ]; then echo "~> Not an EFI host, not checking for EFI." - exit 0 + amf_return=0 fi ls /sys/firmware/efi/efivars 2>/tmp/arch-maride-flavour_checks_uefi_error.log 1>/tmp/arch-maride-flavour_checks_uefi_out.log return=$? if [ "$return" -eq 0 ]; then - exit 0 + amf_return=0 else echo "~> This doesn't seem to be an UEFI boot. Please boot UEFI." - exit 1 + amf_return=1 fi diff --git a/install.sh b/install.sh index 4d5c2a5..963d59c 100755 --- a/install.sh +++ b/install.sh @@ -37,8 +37,7 @@ for check in checks/*.check do echo "=> Running check '$check'..." $check - return=$? - if [ "$return" -ne 0 ]; then + if [ "$amf_return" -ne 0 ]; then echo "=> Check failed. Fix it, maybe." exit fi @@ -47,9 +46,8 @@ done for step in steps/*.step do echo "=> Running step '$step'..." - $step - return=$? - if [ "$return" -ne 0 ]; then + source $step + if [ "$amf_return" -ne 0 ]; then echo "=> Step failed. That is weird. Sorry. Check logs maybe." exit fi @@ -63,9 +61,8 @@ do if [ "$answer" == "y" ] || [ "$answer" == "Y" ]; then echo "=> Running flavour '$flavour'..." pushd $flavour - ./install.sh - return=$? - if [ "$return" -ne 0 ]; then + source install.sh + if [ "$amf_return" -ne 0 ]; then echo "=> Flavour failed. :(" fi popd diff --git a/steps/10-wipe.step b/steps/10-wipe.step index 7bcb37e..a4780ff 100755 --- a/steps/10-wipe.step +++ b/steps/10-wipe.step @@ -5,16 +5,16 @@ echo -n "~> Wipe block device? (Y/n) " read answer if [ "$answer" == "n" ] || [ "$answer" == "N" ]; then - exit 0 -fi - -echo -n "~> You sure? (y/N) " -read answer - -if [ "$answer" == "y" ] || [ "$answer" == "Y" ]; then - echo "~> OK. Be patient now, that could take some time..." - dd if=/dev/zero of=$blockdevice status=progress - exit 0 + amf_return=0 else - exit 1 + echo -n "~> You sure? (y/N) " + read answer + + if [ "$answer" == "y" ] || [ "$answer" == "Y" ]; then + echo "~> OK. Be patient now, that could take some time..." + dd if=/dev/zero of=$blockdevice status=progress + amf_return=0 + else + amf_return=1 + fi fi diff --git a/steps/20-partition.step b/steps/20-partition.step index 67df9e1..5f435e8 100755 --- a/steps/20-partition.step +++ b/steps/20-partition.step @@ -8,8 +8,8 @@ echo -e "g\nn\n1\n2048\n+300M\nn\n2\n\n\np\nw" | fdisk $blockdevice if [ "$?" -eq 0 ]; then echo "~> Seems to have worked. Yay!" - exit 0 + amf_return=0 else echo "~> Failed. :(" - exit 1 + amf_return=1 fi diff --git a/steps/60-user.step b/steps/60-user.step index 5ecb85c..65810ec 100755 --- a/steps/60-user.step +++ b/steps/60-user.step @@ -7,12 +7,12 @@ echo -n "~> Do you want to create an user account? (Y/n) " read answer if [ "$answer" == "n" ] || [ "$answer" == "N" ]; then - exit 0 + amf_return=0 else echo -n " Name of your new user? " read name export username=$name arch-chroot /mnt useradd -m $name arch-chroot /mnt passwd $name - exit 0 + amf_return=0 fi