aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2006-12-08 17:11:10 +0000
committerScott Ullrich <sullrich@pfsense.org>2006-12-08 17:11:10 +0000
commit5a1d86151907d0abeb7ede6224546a27a2c4e5df (patch)
tree64a8234252cfc1813d07b38838ea577114d8c7f4 /packages
parente8e9ce5aae7739a55d39311eb170aa78c3559b0b (diff)
downloadpfsense-packages-5a1d86151907d0abeb7ede6224546a27a2c4e5df.tar.gz
pfsense-packages-5a1d86151907d0abeb7ede6224546a27a2c4e5df.tar.bz2
pfsense-packages-5a1d86151907d0abeb7ede6224546a27a2c4e5df.zip
* Write out ip address database so ping_hosts.sh can obtain
* Finish up failover code
Diffstat (limited to 'packages')
-rw-r--r--packages/tinydns/tinydns.inc47
-rw-r--r--packages/tinydns/tinydns.xml5
-rw-r--r--packages/tinydns/tinydns_domains.xml1
3 files changed, 46 insertions, 7 deletions
diff --git a/packages/tinydns/tinydns.inc b/packages/tinydns/tinydns.inc
index ac626a0c..d270171d 100644
--- a/packages/tinydns/tinydns.inc
+++ b/packages/tinydns/tinydns.inc
@@ -33,6 +33,10 @@ function tinydns_custom_php_install_command() {
global $g, $config;
conf_mount_rw();
$fd = fopen("/usr/local/etc/rc.d/svscan.sh", "w");
+ if(!$fd) {
+ log_error("Could not open /usr/local/etc/rc.d/svscan.sh for writing.");
+ return;
+ }
$svscan = <<<EOD
#!/bin/sh
@@ -135,26 +139,58 @@ function tinydns_get_backup_record($record) {
if(!$domain['row'])
return $record;
foreach($domain['row'] as $row) {
- /* XXX: expand to two failover hosts, etc */
- return $row['failoverip'];
+ $status = tinydns_get_record_status($record);
+ if($status)
+ return $row['failoverip'];
}
}
}
}
+ return $record;
+}
+
+function tinydns_setup_ping_items() {
+ global $g, $config;
+ if(!$config['installedpackages']['tinydnsdomains'])
+ return;
+ conf_mount_rw();
+ /* XXX: make this work with other packages */
+ $fd = fopen("/var/db/pkgpinghosts", "w");
+ if(!$fd) {
+ log_error("Could not open /var/db/pkgpinghosts for writing.");
+ return;
+ }
+ /* write out each ip address so ping_hosts.sh can begin monitoring ip
+ * status and create a database of the status information that we can use.
+ */
+ foreach($config['installedpackages']['tinydnsdomains']['config'] as $domain) {
+ fwrite($fd, $domain['ipaddress'] . "\n");
+ if($domain['row']) {
+ foreach($domain['row'] as $row) {
+ fwrite($fd, $row['ipaddress'] . "\n");
+ }
+ }
+ }
+ fclose($fd);
+ conf_mount_ro();
}
function tinydns_create_zone_file() {
global $g, $config;
conf_mount_rw();
$fd = fopen("/service/tinydns/root/data", "w");
- if($config['installedpackages']['tinydnsdomains'])
+ if(!$fd) {
+ log_error("Could not open /service/tinydns/root/data for writing.");
+ return;
+ }
+ if($config['installedpackages']['tinydnsdomains']) {
foreach($config['installedpackages']['tinydnsdomains']['config'] as $domain) {
$record_data = "";
$hostname = $domain['hostname'];
$ipaddress = $domain['ipaddress'];
$ttl = $domain['ttl'];
- /* check record status, if it is down request
- * backup server if defined.
+ /* check record status, if it is down request
+ * backup server if defined.
*/
$status = tinydns_get_record_status($ipaddress);
if(!$status)
@@ -179,6 +215,7 @@ function tinydns_create_zone_file() {
if($record_data)
fwrite($fd, $record_data . "\n");
}
+ }
fclose($fd);
/* tell tinydns to reload zone file */
exec("cd /service/tinydns/root && /usr/local/bin/tinydns-data");
diff --git a/packages/tinydns/tinydns.xml b/packages/tinydns/tinydns.xml
index 00f4d857..7229d5c0 100644
--- a/packages/tinydns/tinydns.xml
+++ b/packages/tinydns/tinydns.xml
@@ -17,7 +17,7 @@
<tab>
<text>TinyDNS</text>
<url>/tinydns_filter.php</url>
- </tab>
+ </tab>
<aftersaveredirect>/pkg_edit.php?xml=tinydns.xml&amp;id=0</aftersaveredirect>
<additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
@@ -45,7 +45,8 @@
tinydns_custom_php_install_command();
tinydns_custom_php_changeip_command();
tinydns_create_zone_file();
- </custom_php_resync_config_command>
+ tinydns_setup_ping_items();
+ </custom_php_resync_config_command>
<include_file>/usr/local/pkg/tinydns.inc</include_file>
<fields>
<field>
diff --git a/packages/tinydns/tinydns_domains.xml b/packages/tinydns/tinydns_domains.xml
index 5661c5fb..0abdaac9 100644
--- a/packages/tinydns/tinydns_domains.xml
+++ b/packages/tinydns/tinydns_domains.xml
@@ -74,5 +74,6 @@
</fields>
<custom_php_resync_config_command>
tinydns_create_zone_file();
+ tinydns_setup_ping_items();
</custom_php_resync_config_command>
</packagegui>