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

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
name="$1"
fi
while true; do
if [ -n "$name" ]; then
HOST="$name"
else
HOST=`hostname`
echon "Enter system hostname (short form, e.g. 'foo') [$HOST]: "
default_read HOST `hostname`
fi
# if name is set, then we run non-interactively
if [ -n "$name" ] && ! valid_hostname "$name"; then
exit 1
fi
HOST="$name"
while [ -z "$name" ]; do
HOST=`hostname`
echon "Enter system hostname (short form, e.g. 'foo') [$HOST]: "
default_read HOST "$HOST"
if valid_hostname "$HOST"; then
break
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