summaryrefslogtreecommitdiff
path: root/setup-hostname.in
diff options
context:
space:
mode:
Diffstat (limited to 'setup-hostname.in')
-rw-r--r--setup-hostname.in18
1 files changed, 10 insertions, 8 deletions
diff --git a/setup-hostname.in b/setup-hostname.in
index 16d9b6b..20164bd 100644
--- a/setup-hostname.in
+++ b/setup-hostname.in
@@ -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