SUNETOPS-1935 - enforce new naming standard
This commit is contained in:
parent
21a5a4dce4
commit
e2152ab2c0
14
addhost
14
addhost
|
@ -5,19 +5,22 @@ cmd_do_bootstrap="no"
|
||||||
cmd_fqdn=""
|
cmd_fqdn=""
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
echo "Usage: $0 [-h] [-b] [-n fqdn] [--] [<host>]"
|
echo "Usage: $0 [-h] [-b] [-o] [-p] [-n fqdn] [--] [<host>]"
|
||||||
echo " -h show help"
|
echo " -h show help"
|
||||||
echo " -b bootstrap <host> (using ssh)"
|
echo " -b bootstrap <host> (using ssh)"
|
||||||
echo " -n specify FQDN (if not the same as <host>)"
|
echo " -n specify FQDN (if not the same as <host>)"
|
||||||
|
echo " -o override naming standard"
|
||||||
|
echo " -p specify ProxyJump host"
|
||||||
echo ""
|
echo ""
|
||||||
echo " <host> can be an IP number, or something that resolves to one"
|
echo " <host> can be an IP number, or something that resolves to one"
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts "bhnp:" this; do
|
while getopts "bhnop:" this; do
|
||||||
case "${this}" in
|
case "${this}" in
|
||||||
h) usage; exit 0;;
|
h) usage; exit 0;;
|
||||||
b) cmd_do_bootstrap="yes" ;;
|
b) cmd_do_bootstrap="yes" ;;
|
||||||
n) cmd_fqdn="${OPTARG}" ; shift ;;
|
n) cmd_fqdn="${OPTARG}" ; shift ;;
|
||||||
|
o) naming_override="yes" ;;
|
||||||
p) cmd_proxy="${OPTARG}" ; shift ;;
|
p) cmd_proxy="${OPTARG}" ; shift ;;
|
||||||
*) echo "Unknown option ${this}"; echo ""; usage; exit 1;;
|
*) echo "Unknown option ${this}"; echo ""; usage; exit 1;;
|
||||||
esac
|
esac
|
||||||
|
@ -37,6 +40,13 @@ if test -z "$cmd_hostname"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
if [[ -n $cmd_proxy ]]; then
|
||||||
proxyjump="-o ProxyJump=${cmd_proxy}"
|
proxyjump="-o ProxyJump=${cmd_proxy}"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue