From eba7bd8d46e5e3a628a57b564d6a332134a99f3c Mon Sep 17 00:00:00 2001 From: Roman Gorshunov Date: Mon, 21 May 2018 18:04:29 +0200 Subject: [PATCH] Assume "yes" for settings detection Completely lazy mode without any questions asked if launched with "-y" option. Change-Id: Ib4925a00989553a0bb829b9dedb8a0fc485d7ab3 --- .../dev_single_node/airship-in-a-bottle.sh | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/manifests/dev_single_node/airship-in-a-bottle.sh b/manifests/dev_single_node/airship-in-a-bottle.sh index 9f7582b7..9ab841c1 100755 --- a/manifests/dev_single_node/airship-in-a-bottle.sh +++ b/manifests/dev_single_node/airship-in-a-bottle.sh @@ -22,6 +22,19 @@ # # ############################################################################### +usage () +{ + echo "Usage: $(basename $0) {-y|-h}" 1>&2 + echo " -y don't ask questions, trust autodetection" 1>&2 + echo " -h this help" 1>&2 +} +# See how we were called. +case "$1" in + "" ) ;; + "-y" ) ASSUME_YES=1;; + "-h"|* ) usage; exit 1;; +esac + echo "" echo "Welcome to Airship in a Bottle" echo "" @@ -68,15 +81,18 @@ sleep 1 # IP and Hostname setup HOST_IFACE=$(ip route | grep "^default" | head -1 | awk '{ print $5 }') -read -p "Is your HOST IFACE $HOST_IFACE? (Y/n) " YN_HI -if [[ ! "$YN_HI" =~ ^([yY]|"")$ ]]; then - read -p "What is your HOST IFACE? " HOST_IFACE -fi - LOCAL_IP=$(ip addr | awk "/inet/ && /${HOST_IFACE}/{sub(/\/.*$/,\"\",\$2); print \$2}") -read -p "Is your LOCAL IP $LOCAL_IP? (Y/n) " YN_IP -if [[ ! "$YN_IP" =~ ^([yY]|"")$ ]]; then - read -p "What is your LOCAL IP? " LOCAL_IP + +if [[ $ASSUME_YES -ne 1 ]]; then + read -p "Is your HOST IFACE $HOST_IFACE? (Y/n) " YN_HI + if [[ ! "$YN_HI" =~ ^([yY]|"")$ ]]; then + read -p "What is your HOST IFACE? " HOST_IFACE + fi + + read -p "Is your LOCAL IP $LOCAL_IP? (Y/n) " YN_IP + if [[ ! "$YN_IP" =~ ^([yY]|"")$ ]]; then + read -p "What is your LOCAL IP? " LOCAL_IP + fi fi # Shells out to get the hostname for the single-node deployment to avoid some