Commit 6033ee2c authored by Natanael Copa's avatar Natanael Copa
Browse files

setup-hostname: fix validation when non-interacitve

When we specify the hostname as an arg we run the tool non-interactively
and we only set it if the specified hostname is valid.
parent b3006f30
...@@ -50,14 +50,16 @@ if [ -z "$name" ] && [ $# -eq 1 ]; then ...@@ -50,14 +50,16 @@ if [ -z "$name" ] && [ $# -eq 1 ]; then
name="$1" name="$1"
fi fi
while true; do # if name is set, then we run non-interactively
if [ -n "$name" ]; then if [ -n "$name" ] && ! valid_hostname "$name"; then
HOST="$name" exit 1
else fi
HOST=`hostname`
echon "Enter system hostname (short form, e.g. 'foo') [$HOST]: " HOST="$name"
default_read HOST `hostname` while [ -z "$name" ]; do
fi HOST=`hostname`
echon "Enter system hostname (short form, e.g. 'foo') [$HOST]: "
default_read HOST "$HOST"
if valid_hostname "$HOST"; then if valid_hostname "$HOST"; then
break break
fi fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment