Add IP validation

Prevent user from direct copy/paste
This commit is contained in:
Sheng Yang 2017-04-14 15:24:59 -07:00
parent 2163f1cfaa
commit 9a0a012743
2 changed files with 13 additions and 0 deletions

View File

@ -27,3 +27,13 @@ get_container_ip() {
fi
echo $ip
}
validate_ip() {
ip=$1
rx='([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])'
if [[ $ip =~ ^$rx\.$rx\.$rx\.$rx$ ]]; then
return 0
fi
echo Invalid ip address ${ip}
return 1
}

View File

@ -38,6 +38,9 @@ if [ "$etcd_ip" == "" ]; then
exit 1
fi
# will error out if fail since we have set -e
validate_ip ${etcd_ip}
network_option=
if [ "$network" != "" ]; then
network_option="--network ${network}"