diff --git a/addhost b/addhost index 883d172..4e728fb 100755 --- a/addhost +++ b/addhost @@ -5,19 +5,22 @@ cmd_do_bootstrap="no" cmd_fqdn="" function usage() { - echo "Usage: $0 [-h] [-b] [-n fqdn] [--] []" + echo "Usage: $0 [-h] [-b] [-o] [-p] [-n fqdn] [--] []" echo " -h show help" echo " -b bootstrap (using ssh)" echo " -n specify FQDN (if not the same as )" + echo " -o override naming standard" + echo " -p specify ProxyJump host" echo "" echo " can be an IP number, or something that resolves to one" } -while getopts "bhnp:" this; do +while getopts "bhnop:" this; do case "${this}" in h) usage; exit 0;; b) cmd_do_bootstrap="yes" ;; n) cmd_fqdn="${OPTARG}" ; shift ;; + o) naming_override="yes" ;; p) cmd_proxy="${OPTARG}" ; shift ;; *) echo "Unknown option ${this}"; echo ""; usage; exit 1;; esac @@ -37,6 +40,13 @@ if test -z "$cmd_hostname"; then exit 1 fi +if [[ ! $naming_override ]]; then + if [[ ! "$cmd_hostname" =~ ^([a-z]+)-(sthb|dco|tug)-?(prod|dev|stage|staging|test)?-([1-9][0-9]*).sunet.se$ ]]; then + echo "$cmd_hostname is not following the naming standard: function-location-environment-number.sunet.se" + exit 1 + fi +fi + if [[ -n $cmd_proxy ]]; then proxyjump="-o ProxyJump=${cmd_proxy}" fi