files/setup-dns-provider.sh: update

This commit is contained in:
Haitao Pan 2023-12-27 20:31:53 +08:00
parent 481e78faa2
commit 2d830d35de
2 changed files with 13 additions and 12 deletions

View File

@ -38,3 +38,5 @@ ansible_ssh_private_key_file=~/.ssh/id_rsa
ansible_host_key_checking=False
ingress_ip=$SSH_HOST_IP
EOF
cat hosts/inventory

View File

@ -1,20 +1,19 @@
#!/bin/bash
# Function to check if a variable is empty
check_empty() {
if [ -z "${!1}" ]; then
echo "$1 is empty. Aborting."
exit 1
fi
# 检查参数是否为空
check_not_empty() {
if [[ -z $1 ]]; then
echo "Error: $2 is empty. Please provide a value."
exit 1
fi
}
# List of variables to check ; Loop through variables and check if each one is empty
variables=("DNS_AK" "DNS_SK" "DOMAIN")
for var in "${variables[@]}"; do
check_empty "$var"
done
# 检查参数是否为空
check_not_empty "$1" "DNS_AK" && DNS_AK=$1
check_not_empty "$2" "DNS_SK" && DNS_SK=$2
check_not_empty "$3" "DOMAIN" && DOMAIN=$3
# Deploy external-dns
cat > external-dns-values.yaml << EOF
clusterDomain: admin.local
sources: