From 156bdf66d4f433d8289f03e1a0ba3e6d0cd04e06 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Wed, 20 Sep 2017 19:50:55 +0100 Subject: Handle a failure when writing the zone file --- dns.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dns.php b/dns.php index 6e560d9..85844b3 100644 --- a/dns.php +++ b/dns.php @@ -119,7 +119,14 @@ function writezone($domain, $zonetext, $password = null) { } // Reload the zone if we got this far - sshrun("echo -en \"$zonetext\" > " . ZONEROOT . "$domain" . ZONESUFFIX); + $zonewrite = sshrun("echo -en \"$zonetext\" > " . ZONEROOT . "$domain" . ZONESUFFIX . " && echo $? || echo $?"); + + // If the return code was non-zero then fail + if ($zonewrite[sizeof($zonewrite) - 1] != "0") { + echo "

error: something went wrong when writing the zone file, please ask someone for help

"; + die(); + } + sshrun("rndc reload $domain"); } -- cgit v1.2.3