updated input check

This commit is contained in:
2025-11-02 11:35:55 +00:00
parent b2fd4140e6
commit 92c6bade15

View File

@@ -39,12 +39,18 @@ usage () {
}
#
# Function input check
# Parse and validate input
#
inputcheck () {
if [[ -z "$1" ]]; then usage ; printf "ERROR: DOMAIN CANNOT BE EMPTY!\n\n" ; exit 1; fi
if [[ "$1" =~ [[:space:]/] ]]; then printf "ERROR: DOMAIN INVALID (no spaces or slashes allowed)\n\n"; exit 1; fi
}
if [[ $# -ne 1 ]]; then usage ; printf "ERROR: Exactly one argument (the domain) is required.\n\n" ; exit 1 ; fi
hostname="$1" ; hostname=$(echo "$hostname" | tr '[:upper:]' '[:lower:]')
if [[ "$hostname" =~ [[:space:]/_] ]]; then printf "ERROR: Domain cannot contain spaces, slashes, or underscores.\n\n" ; exit 1 ; fi
if [[ ! "$hostname" =~ ^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$ ]]; then
printf "ERROR: Invalid domain format.\n"
printf "Example of valid input: wiki.example.com\n\n" ; exit 1
fi
#
# Let's go