diff options
author | xengineering <mail2xengineering@protonmail.com> | 2020-03-21 12:17:41 +0100 |
---|---|---|
committer | xengineering <mail2xengineering@protonmail.com> | 2020-03-21 12:17:41 +0100 |
commit | fb56b70fd757fb3c40b2b181a54b70b2deabe6f8 (patch) | |
tree | c3fb22083fccb7d3275c406f58272da8ea70c18f | |
parent | 412cab3b3e6095e8876f339fef934f2605a70e8d (diff) | |
download | archinstall-fb56b70fd757fb3c40b2b181a54b70b2deabe6f8.tar archinstall-fb56b70fd757fb3c40b2b181a54b70b2deabe6f8.tar.zst archinstall-fb56b70fd757fb3c40b2b181a54b70b2deabe6f8.zip |
Use print_x Functions for Output
-rw-r--r-- | archinstall.sh | 20 | ||||
-rw-r--r-- | stages/first_stage.sh | 38 | ||||
-rw-r--r-- | stages/second_stage.sh | 2 |
3 files changed, 31 insertions, 29 deletions
diff --git a/archinstall.sh b/archinstall.sh index 382568b..1b4d6af 100644 --- a/archinstall.sh +++ b/archinstall.sh @@ -52,7 +52,9 @@ cat << EOF EOF -# settings +############################################################################## + +# settings # # Modify each entry to your needs. Leave every unknown entry as it is. # But make sure to EDIT 'path_to_disk'! Run "lsblk" if you are unsure, which @@ -66,6 +68,8 @@ export language="de_DE.UTF-8" export keymap="de-latin1" export hostname="archlinux" # will be set to a user-chosen hostname +############################################################################## + # constants @@ -76,8 +80,6 @@ export FIRST_STAGE_LINK="https://raw.githubusercontent.com/xengineering/archinst export SECOND_STAGE_LINK="https://raw.githubusercontent.com/xengineering/archinstall/$BRANCH/stages/second_stage.sh" export PACKAGE_LIST="base linux linux-firmware grub networkmanager nano" # maybe this is requiered: efibootmgr export DEFAULT_PASSWORD="archinstall" -export OK="\033[m[ \033[32mOK\033[m ]" # ref. https://en.wikipedia.org/wiki/ANSI_escape_code -export FAILED="\033[m[ \033[31mFAILED\033[m ]" # ref. https://en.wikipedia.org/wiki/ANSI_escape_code # variables @@ -88,11 +90,13 @@ export boot_mode="unknown" # alternatives: "bios" or "uefi" # functions function print_ok () { + # ref. https://en.wikipedia.org/wiki/ANSI_escape_code printf "\033[m[ \033[32mOK\033[m ] $1\n" } export -f print_ok function print_failed () { + # ref. https://en.wikipedia.org/wiki/ANSI_escape_code printf "\033[m[ \033[31mFAILED\033[m ] $1\n" } export -f print_failed @@ -101,9 +105,9 @@ export -f print_failed # check internet connection if ping -w $INTERNET_TEST_PING_TIMEOUT -c 1 $INTERNET_TEST_SERVER; then - printf "$OK Internet connection is ready\n" + print_ok "Internet connection is ready" else - printf "$FAILED Could not reach INTERNET_TEST_SERVER '$INTERNET_TEST_SERVER'\n" + print_failed "Could not reach INTERNET_TEST_SERVER '$INTERNET_TEST_SERVER'" exit 1 fi @@ -111,14 +115,14 @@ fi # update the system clock timedatectl set-ntp true -printf "$OK Updated system clock\n" +print_ok "Updated system clock" # download and run first stage curl $FIRST_STAGE_LINK > /root/first_stage.sh bash /root/first_stage.sh -printf "$OK first_stage.sh finished\n" +print_ok "first_stage.sh finished" # download, run and delete second stage @@ -126,4 +130,4 @@ printf "$OK first_stage.sh finished\n" curl $SECOND_STAGE_LINK > /mnt/root/second_stage.sh echo "bash /root/second_stage.sh" | arch-chroot /mnt rm /mnt/root/second_stage.sh -printf "$OK second_stage.sh finished\n" +print_ok "second_stage.sh finished" diff --git a/stages/first_stage.sh b/stages/first_stage.sh index 57cc278..49e402f 100644 --- a/stages/first_stage.sh +++ b/stages/first_stage.sh @@ -26,30 +26,28 @@ set -e # debug output print_ok "Entering first_stage.sh" -print_failed "Testing printing functions ..." -exit 99 # check bootmode if [ -d "/sys/firmware/efi/efivars" ]; then export boot_mode="uefi" - printf "$OK Booted with UEFI\n" + print_ok "Booted with UEFI" else export boot_mode="bios" - printf "$OK Booted with legacy boot / BIOS\n" + print_ok "Booted with legacy boot / BIOS" fi # partition the disk if [ "$path_to_disk" == "/dev/null" ]; then - printf "$FAILED path_to_disk variable has still default value '/dev/null'\n" + print_failed "path_to_disk variable has still default value '/dev/null'" exit 1 fi if [ "$boot_mode" == "uefi" ]; then - printf "$OK Partitioning for UEFI mode ...\n" + print_ok "Partitioning for UEFI mode ..." wipefs -a $path_to_disk # make sure that fdisk does not ask for removing # signatures which breaks the script fdisk $path_to_disk << EOF @@ -69,10 +67,10 @@ n p w EOF - printf "$OK Partitioned disk for UEFI/GPT\n" + print_ok "Partitioned disk for UEFI/GPT" elif [ "$boot_mode" == "bios" ]; then - printf "$OK Partitioning for BIOS mode ...\n" + print_ok "Partitioning for BIOS mode ..." wipefs -a $path_to_disk # make sure that fdisk does not ask for removing # signatures which breaks the script fdisk $path_to_disk << EOF @@ -90,10 +88,10 @@ p p w EOF - printf "$OK Partitioned disk for BIOS/MBR\n" + print_ok "Partitioned disk for BIOS/MBR" else - printf "$FAILED Unknown boot_mode\n" + print_failed "Unknown boot_mode" fi @@ -101,7 +99,7 @@ fi if [ "$luks_encryption" == "no" ];then if [ "$boot_mode" == "bios" ];then - printf "$OK Formatting for no disk encryption and bios/mbr\n" + print_ok "Formatting for no disk encryption and bios/mbr" mkfs.ext4 ${path_to_disk}1 e2label ${path_to_disk}1 "boot" mkfs.ext4 ${path_to_disk}2 @@ -110,7 +108,7 @@ if [ "$luks_encryption" == "no" ];then mkdir /mnt/boot mount ${path_to_disk}1 /mnt/boot elif [ "$boot_mode" == "uefi" ];then - printf "$OK Formatting for no disk encryption and uefi/gpt\n" + print_ok "Formatting for no disk encryption and uefi/gpt" mkfs.fat -F32 ${path_to_disk}1 fatlabel ${path_to_disk}1 "efi" mkfs.ext4 ${path_to_disk}2 @@ -123,26 +121,26 @@ if [ "$luks_encryption" == "no" ];then mkdir /mnt/boot mount ${path_to_disk}2 /mnt/boot else - printf "$FAILED Unknown boot_mode\n" + print_failed "Unknown boot_mode" exit 1 fi elif [ "$luks_encryption" == "yes" ];then if [ "$boot_mode" == "bios" ];then - printf "$OK Formatting for disk encryption and bios/mbr\n" + print_ok "Formatting for disk encryption and bios/mbr" ### - printf "$FAILED Sorry, encryption is not ready to use ...\n" + print_failed "Sorry, encryption is not ready to use ..." exit 1 elif [ "$boot_mode" == "uefi" ];then - printf "$OK Formatting for disk encryption and uefi/gpt\n" + print_ok "Formatting for disk encryption and uefi/gpt" ### - printf "$FAILED Sorry, encryption is not ready to use ...\n" + print_failed "Sorry, encryption is not ready to use ..." exit 1 else - printf "$FAILED Unknown boot_mode\n" + print_failed "Unknown boot_mode" exit 1 fi else - printf "$FAILED luks_encryption not 'yes' or 'no'\n" + print_failed "luks_encryption not 'yes' or 'no'" exit 1 fi @@ -150,7 +148,7 @@ fi # install packages with pacstrap pacstrap /mnt $PACKAGE_LIST -printf "$OK Installed packages\n" +print_ok "Installed packages" # generate /etc/fstab diff --git a/stages/second_stage.sh b/stages/second_stage.sh index a649fc6..5800828 100644 --- a/stages/second_stage.sh +++ b/stages/second_stage.sh @@ -25,7 +25,7 @@ set -e # debug output -printf "$OK Entering second_stage.sh\n" +print_ok "Entering second_stage.sh" # set timezone |