jean-cloud-services/services/ns1.jean-cloud.org/deploy.sh

62 lines
1.4 KiB
Bash
Raw Normal View History

2023-09-07 17:50:05 +00:00
#!/bin/bash
. driglibash-base
2023-09-13 08:46:02 +00:00
. "$(where)/helper_functions.sh"
2023-09-07 17:50:05 +00:00
set -euo pipefail
# Working variables
debian_bind_confdir="/etc/bind"
2023-09-13 08:46:02 +00:00
autoconf_separator=";;; Autogeneration. Do not write under this line! ;;;"
2023-09-07 17:50:05 +00:00
2023-09-13 08:46:02 +00:00
# File that contain "service target" lines
# With service a symbolic dns name and target an existing server hostname
2023-09-07 17:50:05 +00:00
servicefile="/docker/services.txt"
2023-09-13 08:46:02 +00:00
# The bind file containing server declarations
server_zone_file="template.db.jean-cloud.org"
2023-09-07 17:50:05 +00:00
2023-09-13 08:46:02 +00:00
# Where you want your DNS keys stored
keydir="$DATA_DIR/keys"
2023-09-07 17:50:05 +00:00
2023-09-13 08:46:02 +00:00
# IP of primary servers
2023-09-16 18:17:34 +00:00
# MUST end with ; if non-empty
2023-09-13 08:46:02 +00:00
primary_ips=""
2023-09-07 17:50:05 +00:00
2023-09-13 08:46:02 +00:00
# IP of secondary servers (for zone transfer)
2023-09-16 18:17:34 +00:00
secondary_ips="37.65.119.74;"
2023-09-07 17:50:05 +00:00
2023-09-13 08:46:02 +00:00
# NS name
2023-10-31 15:42:06 +00:00
default_dns_name="ns.jean-cloud.org."
2023-09-07 17:50:05 +00:00
2023-09-15 08:57:47 +00:00
CAA_RR='CAA 0 issue "letsencrypt.org;validationmethods=dns-01"'
2023-09-07 17:50:05 +00:00
2023-09-16 18:17:34 +00:00
runthis () {
2023-09-13 08:46:02 +00:00
if [ "$#" -ne 1 ] ; then
2023-09-16 18:17:34 +00:00
die "Usage: runthis <primary|secondary>"
2023-09-13 08:46:02 +00:00
fi
2023-09-07 17:50:05 +00:00
2023-09-13 08:46:02 +00:00
prepare
2023-09-29 07:51:22 +00:00
primary_ips="$primary_ips$(fakeresolve_ip_list tetede)"
2023-09-16 18:17:34 +00:00
secondary_ips="$secondary_ips$(fakeresolve_ip_list shlago)"
2023-09-07 17:50:05 +00:00
2023-09-15 08:57:47 +00:00
line_in_file "primary_ips=\"$primary_ips\"" "$DOCKER_DIR/.env"
line_in_file "secondary_ips=\"$secondary_ips\"" "$DOCKER_DIR/.env"
2023-09-13 08:46:02 +00:00
if [ "$1" = "primary" ] ; then
create_primary_files
2023-09-07 17:50:05 +00:00
else
2023-09-13 08:46:02 +00:00
create_secondary_files
2023-09-07 17:50:05 +00:00
fi
2023-09-13 08:46:02 +00:00
restart
2023-09-07 17:50:05 +00:00
}
2023-09-13 08:46:02 +00:00
main () {
2023-09-16 18:17:34 +00:00
runthis primary
2023-09-13 08:46:02 +00:00
}
2023-09-07 17:50:05 +00:00
2023-09-13 08:46:02 +00:00
# Do not execute main if script is sourced
! (return 0 2>/dev/null) && main "$@" || true # return 0 whatever happends