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

66 lines
1.5 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)
2024-02-22 00:43:01 +00:00
# master.retzo.net
secondary_ips="159.69.124.127;2a01:4f8:c17:d8f2::1;"
2024-06-15 15:59:53 +00:00
# tetede
secondary_ips="${secondary_ips}51.195.40.128;"
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
2024-06-15 15:59:53 +00:00
primary_ips="$primary_ips$(fakeresolve_ip_list izzo)"
secondary_ips="$secondary_ips$(fakeresolve_ip_list ns)"
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 () {
2024-04-18 14:22:32 +00:00
aa-disable /etc/apparmor.d/usr.sbin.named
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