From 1d9d8511ae3271d866601d7c710ef35534e32aa3 Mon Sep 17 00:00:00 2001 From: Dan Johansen Date: Sun, 23 Dec 2018 13:50:21 +0100 Subject: [PATCH] added ncurses dialogs, thanks to dodgejcr! --- manjaro-arm-installer | 136 ++++++++++++++++++++++++++++++++---------- 1 file changed, 106 insertions(+), 30 deletions(-) diff --git a/manjaro-arm-installer b/manjaro-arm-installer index 3398740..10b35e7 100644 --- a/manjaro-arm-installer +++ b/manjaro-arm-installer @@ -1,22 +1,9 @@ #! /bin/bash # Set globals -#LIBDIR=/usr/share/manjaro-arm-tools/lib -SDCARD=/dev/mmcblk0 TMPDIR=/var/tmp/manjaro-arm-installer PROFILES=/var/tmp/manjaro-arm-installer/profiles ARCH='aarch64' -DEVICE='rpi3' -EDITION='minimal' -USER='manjaro' -PASSWORD='manjaro' -ROOTPASSWORD='root' - - - - -#imports -#source $LIBDIR/functions.sh # Functions @@ -303,20 +290,114 @@ fi } # Asking for user input! -read -p 'What device is this for? [Options: rpi3, oc2 and pinebook] ' DEVICE -read -p 'What edition do you want? [Options: minimal, lxqt and kde] ' EDITION -read -p 'What is the path to the SD card? (example: /dev/sdb)? ' SDCARD -read -p 'What username do you want? ' USER -read -sp "What password should $USER have? " PASSWORD -read -sp " -What password should the root user have? " ROOTPASSWORD -echo " -" #to fix next line from being in the password line +#read -p 'What device is this for? [Options: rpi3, oc2 and pinebook] ' DEVICE +#read -p 'What edition do you want? [Options: minimal, lxqt and kde] ' EDITION +#read -p 'What is the path to the SD card? (example: /dev/sdb)? ' SDCARD +#read -p 'What username do you want? ' USER +#read -sp "What password should $USER have? " PASSWORD +#read -sp " +#What password should the root user have? " ROOTPASSWORD +#echo " +#" #to fix next line from being in the password line +#echo "Device = $DEVICE" +#echo "Edition = $EDITION" +#echo "Path to SD Card = $SDCARD" +#echo "Username = $USER" + + +# Using ncurses to ask for user input for variables +DEVICE=$(dialog --clear --title "Manjaro-ARM Installer" \ + --menu "Choose a device:" 20 51 4 \ + "rpi3" "Raspberry Pi 3" \ + "oc2" "Odroid C2" \ + "pinebook" "PineBook" 3>&1 1>&2 2>&3 3>&-) + + +#The if statement makes sure that the user has put in something in the previous prompt. If not (left blank or pressed cancel) the script will end +if [ ! -z "$DEVICE" ] +then +EDITION=$(dialog --clear --title "Manjaro-ARM Installer" \ + --menu "Choose an edition:" 20 50 4 \ + "minimal" "Minimal Edition (Just CLI)" \ + "lxqt" "Full LXQT Desktop and apps (lightweight)" \ + "kde" "Full KDE Desktop (Heavy)" 3>&1 1>&2 2>&3 3>&-) + +else + clear + exit 1 +fi + + +if [ ! -z "$EDITION" ] +then +USER=$(dialog --clear --title "Manjaro-ARM Installer" \ + --inputbox "Enter username:" 8 50 \ + 3>&1 1>&2 2>&3 3>&-) +else + clear + exit 1 +fi + + + + +if [ ! -z "$USER" ] +then +PASSWORD=$(dialog --clear --title "Manjaro-ARM Installer" \ + --passwordbox "Enter Password:" 8 50 \ + 3>&1 1>&2 2>&3 3>&- \ + ) +else + clear + exit 1 +fi + + + +if [ ! -z "$PASSWORD" ] +then +ROOTPASSWORD=$(dialog --clear --title "Manjaro-ARM Installer" \ + --passwordbox "Enter Root Password:" 8 50 \ + 3>&1 1>&2 2>&3 3>&- \ + ) +else + clear + exit 1 +fi + + + + +if [ ! -z "$ROOTPASSWORD" ] +then + +# simple command to put the results of lsblk (just the names of the devices) into an array and make that array populate the options +let i=0 +W=() +while read -r line; do + let i=$i+1 + W+=($line "") +done < <( lsblk -adn -o NAME ) +SDCARD=$(dialog --title "Manjaro-ARM Installer" \ + --menu "Chose your SDCard" 20 50 4 \ + "${W[@]}" 3>&2 2>&1 1>&3) + +# add /dev/ to the selected option above +SDCARD=/dev/$SDCARD +else + clear + exit 1 +fi + + +# List all the responses upon completion (remove this for production) +clear echo "Device = $DEVICE" echo "Edition = $EDITION" -echo "Path to SD Card = $SDCARD" -echo "Username = $USER" - +echo "User name = $USER" +echo "Password = ********** ($PASSWORD)" #password is here for testing purposes +echo "Root Password = ********** ($ROOTPASSWORD)" #password is here for testing purposes +echo "SDCard = $SDCARD" if [[ "$DEVICE" = "oc1" ]] || [[ "$DEVICE" = "rpi2" ]] || [[ "$DEVICE" = "xu4" ]]; then ARCH='armv7h' @@ -324,11 +405,6 @@ else ARCH='aarch64' fi -#if [[ ! -f $SDCARD ]]; then - # echo "Path $SDCARD does not exist! Aborting..." - # exit 1 -#fi - # get the profiles getarmprofiles