From f05378b5091cf8e73baeac051e35462879f06831 Mon Sep 17 00:00:00 2001 From: whiskerz007 <2713522+whiskerz007@users.noreply.github.com> Date: Fri, 20 Mar 2020 15:00:25 +0100 Subject: [PATCH] Add menu to select storage and update README --- README.md | 14 +++++--------- install.sh | 31 +++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a6c7d77..f54c082 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,13 @@ -# New Proxmox VM with HassOS +# New Proxmox VM with Home Assistant -This script will create a new Proxmox VM with the latest version of HassOS. To create a new VM in the `local-lvm` storage, run the following in a SSH session or the console from Proxmox interface +This script will create a new Proxmox VM with the latest version of Home Assistant. To create a new VM, run the following in a SSH session or the console from Proxmox interface ``` -wget -qO - https://raw.githubusercontent.com/whiskerz007/proxmox_hassos_install/master/install.sh | bash -s local-lvm +bash -c "$(wget -qLO - https://github.com/whiskerz007/proxmox_hassos_install/raw/master/install.sh)" ``` After script completes, click on the new VM (_the script will tell you the ID_), click on the `Hardware` tab for the VM and change the `Memory` and `Processors` settings to what you desire. The `Hard Disk` can be expanded by clicking on it, then click on the `Resize disk` button above (_Note: additional steps must be taken for storage to take effect in the VM after the first boot_). The network MAC address can be changed by selecting `Network Device` and clicking `Edit` above. Once all changes have been made, click `Start` above. -## Specify Storage ID - -To specify the storage ID the new VM will be placed, replace `local-lvm` in the oneline command with desired storage ID. - ## Root Prompt To get to the root prompt @@ -19,8 +15,8 @@ To get to the root prompt - When the messages slow down press the `Enter` key a couple of times until you see the following ``` -Welcome to HassOS -hassio login: +Welcome to Home Assistant +homeassistant login: ``` - Login using `root`, no password is requested - When you see the `hassio > ` prompt, type `login` diff --git a/install.sh b/install.sh index bd75c79..56d8a11 100644 --- a/install.sh +++ b/install.sh @@ -35,12 +35,30 @@ TMP=`mktemp -d` pushd $TMP >/dev/null # Select storage location -STORAGE=${1:-local-lvm} -pvesm list $STORAGE >& /dev/null || - die "'$STORAGE' is not a valid storage ID." -pvesm status -content images -storage $STORAGE >&/dev/null || - die "'$STORAGE' does not allow 'Disk image' to be stored." -STORAGE_TYPE=`pvesm status -storage $STORAGE | awk 'NR>1 {print $2}'` +while read -r line; do + TAG=$(echo $line | awk '{print $1}') + TYPE=$(echo $line | awk '{printf "%-10s", $2}') + FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') + ITEM=" Type: $TYPE Free: $FREE " + OFFSET=2 + if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then + MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET)) + fi + STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" ) +done < <(pvesm status -content images | awk 'NR>1') +if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then + warn "'Disk image' needs to be selected for at least one storage location." + die "Unable to detect valid storage location." +elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then + STORAGE=${STORAGE_MENU[0]} +else + while [ -z "${STORAGE:+x}" ]; do + STORAGE=$(whiptail --title "Storage Pools" --radiolist \ + "Which storage pool you would like to use for the container?\n\n" \ + 16 $(($MSG_MAX_LENGTH + 23)) 6 \ + "${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit + done +fi info "Using '$STORAGE' for storage location." # Get the next guest VM/LXC ID @@ -76,6 +94,7 @@ msg "Extracting disk image..." gunzip -f $FILE # Create variables for container disk +STORAGE_TYPE=`pvesm status -storage $STORAGE | awk 'NR>1 {print $2}'` if [ "$STORAGE_TYPE" = "dir" ]; then DISK_EXT=".qcow2" DISK_REF="$VMID/"