You've already forked dokuwiki-ubuntu
updated input check
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user