diff --git a/hosts/dns/dhcp-failover.sh b/hosts/dns/dhcp-failover.sh deleted file mode 100644 index bcb870e..0000000 --- a/hosts/dns/dhcp-failover.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -set -x -src_dns_server=192.168.1.2 -# DHCP scopes to manage - put the name of each scope you have -dhcp_scopes=("local-home") # Use this array for one or many scopes - -echo "Checking primary Technitium server status" -status_code=$(curl --write-out '%{http_code}' --silent --output /dev/null http://$src_dns_server:5380) - -if [[ "$status_code" -ne 200 ]]; then - echo "Primary DNS/DHCP server is not available. Enabling DHCP on the secondary server." - action="enable" -else - echo "Primary DNS/DHCP server is available. Disabling DHCP on the secondary server." - action="disable" -fi - -for scope in "${dhcp_scopes[@]}"; do - echo "Executing API call to $action DHCP scope: $scope" - response=$(curl -X POST "http://localhost:5380/api/dhcp/scopes/$action?token=$DNS1_API&name=$scope" \ - --silent --write-out "%{http_code}") - - echo "HTTP response code: $response" - if [[ "$response" == "200" ]]; then - echo "Successfully $action DHCP for scope: $scope" - else - echo "Failed to $action DHCP for scope: $scope. Check the response body for details." - fi -done \ No newline at end of file diff --git a/hosts/dns/dns-02.nix b/hosts/dns/dns-02.nix index f67fa59..6c238a0 100644 --- a/hosts/dns/dns-02.nix +++ b/hosts/dns/dns-02.nix @@ -6,10 +6,7 @@ }: { - age.secrets = { - dns02-admin-password.file = ../../secrets/dns02-admin-password.age; - dns02-dhcp-failover.file = ../../secrets/dns02-dhcp-failover.age; - }; + age.secrets.dns02-admin-password.file = ../../secrets/dns02-admin-password.age; my = { @@ -28,19 +25,5 @@ virtualisation.proxmox.enable = true; }; - # systemd.services.dhcp-failover = { - # description = "Set the current server as the primary DHCP server if the other one is down"; - # wantedBy = [ "multi-user.target" ]; - # path = [ pkgs.curl ]; - # serviceConfig = { - # EnvironmentFile = config.age.secrets.dns02-dhcp-failover.path; - # ExecStart = "${pkgs.writeShellScript "dhcp-failover.sh" (builtins.readFile ./dhcp-failover.sh)}"; - # Restart = "on-failure"; - # DynamicUser = true; - # StandardOutput = "journal"; - # StandardError = "journal"; - # }; - # }; - system.stateVersion = "24.11"; }