From 7b0c46474dc0716767b89901a33a85efbb2dc8cd Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Wed, 26 Feb 2014 14:01:28 +0100 Subject: [PATCH] Allow gateway to be specified, or calculate it with ipcalc --- vinst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vinst b/vinst index 9a8eb90..66b70aa 100755 --- a/vinst +++ b/vinst @@ -35,6 +35,14 @@ while [ -n "$1" ]; do esac IPADDRESS="$1" ;; + (-g|--gateway) + shift + if [ -z "$1" ]; then + echo >&2 'E: --gateway/-g needs IP address' + exit 1 + fi + GATEWAY="$1" + ;; (-r|--ram) shift if [ -z "$1" ]; then @@ -70,7 +78,7 @@ hostname=${HOSTNAME%%.*} \ domain=${HOSTNAME#*.}" if [ -n "$IPADDRESS" ]; then - if [ -z "$GATEWAY" ]; then + if [ -z "$GATEWAY" ] && [ -x $(command -v ipcalc) ]; then # default to the first IP in the network GATEWAY=$(ipcalc $IPADDRESS | grep HostMin | awk '{print $2}') fi -- 2.39.2