aboutsummaryrefslogtreecommitdiffstats
path: root/config/tinydns/tinydns.inc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-03-29 13:56:40 +0000
committerErmal <eri@pfsense.org>2010-03-29 13:56:40 +0000
commitc0cf14415df4b1e70be1d903a04db006b1896be7 (patch)
treecfa6d5f05e502299c4edd9373d9cff70167c9577 /config/tinydns/tinydns.inc
parentc75dcc2241dcfddc0ff32b2c4e6cb4fcf3070811 (diff)
downloadpfsense-packages-c0cf14415df4b1e70be1d903a04db006b1896be7.tar.gz
pfsense-packages-c0cf14415df4b1e70be1d903a04db006b1896be7.tar.bz2
pfsense-packages-c0cf14415df4b1e70be1d903a04db006b1896be7.zip
Ticket #403. Move all services to /var/etc.
Diffstat (limited to 'config/tinydns/tinydns.inc')
-rw-r--r--config/tinydns/tinydns.inc100
1 files changed, 54 insertions, 46 deletions
diff --git a/config/tinydns/tinydns.inc b/config/tinydns/tinydns.inc
index 38521a39..18d522f4 100644
--- a/config/tinydns/tinydns.inc
+++ b/config/tinydns/tinydns.inc
@@ -99,11 +99,13 @@ load_rc_config \$name
required_dirs="\${svscan_servicedir}"
svscan_start () {
+ global $g;
+
echo "Starting svscan."
/usr/bin/env \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
/usr/sbin/daemon -f /bin/sh -c "\$command \$svscan_servicedir 2>&1 | /usr/local/bin/readproctitle service errors: ................................................................................................................................................................................................................................................................................................................................................................................................................ &" > /dev/null
- minicron {$refreshinterval} /var/run/ping_hosts.pid "/etc/ping_hosts.sh; cd /etc/tinydns/root && /usr/local/bin/tinydns-data"
+ minicron {$refreshinterval} {$g['varrun_path']}/ping_hosts.pid "/etc/ping_hosts.sh; cd {$g['varetc_path']}/etc/tinydns/root && /usr/local/bin/tinydns-data"
}
svscan_stop_post () {
@@ -129,6 +131,7 @@ EOD;
function tinydns_custom_php_deinstall_command() {
global $g, $config;
+
conf_mount_rw();
/* destroy all daemontools items */
exec("/usr/bin/killall supervise");
@@ -143,8 +146,8 @@ function tinydns_custom_php_deinstall_command() {
exec("rm /usr/local/www/*tinydns*");
exec("rm /usr/local/pkg/*tinydns*");
exec("rm /usr/local/pkg/pf/*tinydns*");
- exec("rm -rf /etc/tinydns {$g['varrun_path']}/service/tinydns");
- exec("rm -rf /etc/dnscache* {$g['varrun_path']}/service/dnscache*");
+ exec("rm -rf {$g['varetc_path']}/etc/tinydns {$g['varrun_path']}/service/tinydns");
+ exec("rm -rf {$g['varetc_path']}/etc/dnscache* {$g['varrun_path']}/service/dnscache*");
filter_configure();
conf_mount_ro();
}
@@ -177,27 +180,27 @@ function tinydns_custom_php_changeip_command() {
exec("/usr/sbin/pw useradd Gdnslog");
exec("/usr/sbin/pw useradd Gdnscache");
exec("/usr/sbin/pw useradd Gaxfrdns");
- exec("/bin/rm -r /etc/dnscache*");
+ exec("/bin/rm -r {$g['varetc_path']}/etc/dnscache*");
exec("/bin/rm -r {$g['varrun_path']}/service/dnscache*");
/* TinyDNS Server */
- exec("/usr/local/bin/tinydns-conf Gtinydns Gdnslog /etc/tinydns {$dnsserverip}");
- exec("/bin/ln -s /etc/tinydns {$g['varrun_path']}/service/");
+ exec("/usr/local/bin/tinydns-conf Gtinydns Gdnslog {$g['varetc_path']}/etc/tinydns {$dnsserverip}");
+ exec("/bin/ln -s {$g['varetc_path']}/etc/tinydns {$g['varrun_path']}/service/");
/* AXFRDNS - Zone transfers */
if(is_array($ztipaddress))
- exec("/usr/local/bin/axfrdns-conf Gaxfrdns Gdnslog /etc/axfrdns /etc/tinydns {$dnsserverip}");
- exec("/bin/ln -s /etc/axfrdns {$g['varrun_path']}/service/");
+ exec("/usr/local/bin/axfrdns-conf Gaxfrdns Gdnslog {$g['varetc_path']}/etc/axfrdns {$g['varetc_path']}/etc/tinydns {$dnsserverip}");
+ exec("/bin/ln -s {$g['varetc_path']}/etc/axfrdns {$g['varrun_path']}/service/");
- exec("echo {$dnsserverip} > /etc/tinydns/env/IP");
+ exec("echo {$dnsserverip} > {$g['varetc_path']}/etc/tinydns/env/IP");
exec("/usr/bin/killall -9 tinydns");
if($config['installedpackages']['tinydns']['config'][0]['enableforwarding']) {
$interfaces = explode(",", $config['installedpackages']['tinydns']['config'][0]['interface']);
- exec("/bin/cp /var/etc/resolv.conf /var/etc/resolv.conf.original");
- exec("/bin/cp /var/etc/resolv.conf /var/etc/resolv.conf.dnscache");
- exec("echo domain {$config['system']['domain']} > /var/etc/resolv.conf");
- exec("rm -rf /etc/dnscache* {$g['varrun_path']}/service/dnscache*");
+ exec("/bin/cp {$g['varetc_path']}/resolv.conf {$g['varetc_path']}/resolv.conf.original");
+ exec("/bin/cp {$g['varetc_path']}/resolv.conf {$g['varetc_path']}/resolv.conf.dnscache");
+ exec("echo domain {$config['system']['domain']} > {$g['varetc_path']}/resolv.conf");
+ exec("rm -rf {$g['varetc_path']}/etc/dnscache* {$g['varrun_path']}/service/dnscache*");
foreach ($interfaces as $dnsidx => $dnsif) {
$dnscacheif = convert_friendly_interface_to_real_interface_name($dnsif);
$dnscacheip = find_interface_ip($dnscacheif);
@@ -207,26 +210,26 @@ function tinydns_custom_php_changeip_command() {
$ipmask = $config['interfaces'][$dnsif]['subnet'];
$arr = tinydns_get_ip_subnet_arpa($dnscacheip, $ipmask);
$dnsuserip = $arr[0];
- exec("mkdir /etc/dnscache{$dnsidx}");
- exec("/usr/local/bin/dnscache-conf Gdnscache Gdnslog /etc/dnscache{$dnsidx} {$dnscacheip}");
- exec("/bin/ln -s /etc/dnscache{$dnsidx} {$g['varrun_path']}/service/");
- if (!is_dir("/etc/dnscache{$dnsidx}/env/IP"))
- exec("mkdir -p /etc/dnscache{$dnsidx}/env");
- exec("echo {$dnscacheip} > /etc/dnscache{$dnsidx}/env/IP");
+ exec("/bin/mkdir -p {$g['varetc_path']}/etc/dnscache{$dnsidx}");
+ exec("/usr/local/bin/dnscache-conf Gdnscache Gdnslog {$g['varetc_path']}/etc/dnscache{$dnsidx} {$dnscacheip}");
+ exec("/bin/ln -s {$g['varetc_path']}/etc/dnscache{$dnsidx} {$g['varrun_path']}/service/");
+ if (!is_dir("{$g['varetc_path']}/etc/dnscache{$dnsidx}/env/IP"))
+ exec("/bin/mkdir -p {$g['varetc_path']}/etc/dnscache{$dnsidx}/env");
+ exec("echo {$dnscacheip} > {$g['varetc_path']}/etc/dnscache{$dnsidx}/env/IP");
tinydns_dnscache_forwarding_servers($dnsidx);
- if (!is_dir("/etc/dnscache{$dnsidx}/root/ip"))
- exec("mkdir -p /etc/dnscache{$dnsidx}/root/ip");
- exec("touch /etc/dnscache{$dnsidx}/root/ip/{$dnsuserip}");
+ if (!is_dir("{$g['varetc_path']}/etc/dnscache{$dnsidx}/root/ip"))
+ exec("/bin/mkdir -p {$g['varetc_path']}/etc/dnscache{$dnsidx}/root/ip");
+ exec("/usr/bin/touch {$g['varetc_path']}/etc/dnscache{$dnsidx}/root/ip/{$dnsuserip}");
tinydns_create_soa_domain_list($dnsserverip, $dnsidx);
- exec("echo nameserver {$dnscacheip} >> /var/etc/resolv.conf");
+ exec("echo nameserver {$dnscacheip} >> {$g['varetc_path']}/resolv.conf");
}
exec("/usr/bin/killall -9 dnscache");
} else {
if(file_exists("/var/etc/resolv.conf.original"))
- exec("/bin/cp /var/etc/resolv.conf.original /var/etc/resolv.conf");
+ exec("/bin/cp {$g['varetc_path']}/resolv.conf.original {$g['varetc_path']}/resolv.conf");
$interfaces = explode(",", $$config['installedpackages']['tinydns']['config'][0]['interface']);
foreach ($interfaces as $dnsidx => $dnsif) {
- if(is_dir("/etc/dnscache{$dnsidx}"))
+ if(is_dir("{$g['varetc_path']}/etc/dnscache{$dnsidx}"))
dnscache_use_root_servers($dnsidx);
}
exec("/usr/bin/killall -9 dnscache");
@@ -252,13 +255,14 @@ function populate_zt_array() {
function tinydns_setup_axfrdns() {
global $g, $config;
+
/* Populate Zone Transfer array */
$ztipaddress = populate_zt_array();
if(!is_array($ztipaddress))
return;
- $fd = fopen("/etc/axfrdns/tcp","w");
+ $fd = fopen("{$g['varetc_path']}/etc/axfrdns/tcp","w");
if(!$fd) {
- log_error("Could not open /etc/axfrdns/tcp for writing");
+ log_error("Could not open {$g['varetc_path']}/etc/axfrdns/tcp for writing");
return;
}
foreach($ztipaddress as $zt) {
@@ -892,16 +896,16 @@ function tinydns_get_dns_record_type($tinydnsrecord) {
/* This function will be replaced by an auto detect DNS cache servers routine */
/* At the moment there is no tagging of DNSroute to a WAN port. It needs to be added */
function tinydns_dnscache_forwarding_servers($index) {
- global $config;
+ global $g, $config;
- exec("echo 1 > /etc/dnscache{$index}/env/FORWARDONLY");
- if(is_dir("/etc/dnscache{$index}/root/servers/"))
- exec("rm -R /etc/dnscache/root/servers/");
- exec("mkdir -p /etc/dnscache{$index}/root/servers/");
+ exec("echo 1 > {$g['varetc_path']}/etc/dnscache{$index}/env/FORWARDONLY");
+ if(is_dir("{$g['varetc_path']}/etc/dnscache{$index}/root/servers/"))
+ exec("rm -R {$g['varetc_path']}/etc/dnscache/root/servers/");
+ exec("/bin/mkdir -p {$g['varetc_path']}/etc/dnscache{$index}/root/servers/");
if (intval($config['version']) >= 6)
- exec("/bin/cat /var/etc/nameserver_* > /etc/dnscache{$index}/root/servers/@");
+ exec("/bin/cat {$g['varetc_path']}/nameserver_* > {$g['varetc_path']}/etc/dnscache{$index}/root/servers/@");
else {
- $fr = fopen("/var/etc/resolv.conf.dnscache", "r");
+ $fr = fopen("{$g['varetc_path']}/resolv.conf.dnscache", "r");
if (! $fr) {
printf("Error: cannot open resolv.conf.dnscache in tinydns_register_forwarding_servers().\n");
return 1;
@@ -924,9 +928,9 @@ function tinydns_dnscache_forwarding_servers($index) {
}
}
fclose($fr);
- $fr = fopen("/etc/dnscache{$index}/root/servers/@", "w");
+ $fr = fopen("{$g['varetc_path']}/etc/dnscache{$index}/root/servers/@", "w");
if (! $fr) {
- printf("Error: cannot write to /etc/dnscache{$index}/root/servers/@ in tinydns_dnscache_forwarding_servers().\n");
+ printf("Error: cannot write to {$g['varetc_path']}/etc/dnscache{$index}/root/servers/@ in tinydns_dnscache_forwarding_servers().\n");
return 1;
}
if($iprecords)
@@ -935,7 +939,7 @@ function tinydns_dnscache_forwarding_servers($index) {
}
}
-/* This routine adds filenames to /etc/dnscache/root/servers/ with the contents pointing to the tinyDNS server */
+/* This routine adds filenames to {$g['varetc_path']}/etc/dnscache/root/servers/ with the contents pointing to the tinyDNS server */
function tinydns_create_soa_domain_list($dnsserverip, $index = 0) {
global $g;
if(file_exists("{$g['varrun_path']}/service/tinydns/root/data"))
@@ -954,9 +958,9 @@ function tinydns_create_soa_domain_list($dnsserverip, $index = 0) {
if($fqdn) {
$rtypes = tinydns_get_dns_record_type($dnsrecord);
if($rtypes[0] == "SOA") {
- $fr = fopen("/etc/dnscache{$index}/root/servers/{$fqdn}", "w");
+ $fr = fopen("{$g['varetc_path']}/etc/dnscache{$index}/root/servers/{$fqdn}", "w");
if (! $fr) {
- printf("Error: cannot open /etc/dnscache{$index}/root/servers/{$fqdn} in tinydns_create_soa_domain_list().\n");
+ printf("Error: cannot open {$g['varetc_path']}/etc/dnscache{$index}/root/servers/{$fqdn} in tinydns_create_soa_domain_list().\n");
return 1;
}
if($fqdn)fwrite($fr, $dnsserverip);
@@ -969,7 +973,9 @@ function tinydns_create_soa_domain_list($dnsserverip, $index = 0) {
/* This function is not called */
/* At the moment there is no tagging of DNSroute to a WAN port. It needs to be added */
function tinydns_register_forwarding_servers() {
- $fr = fopen("/var/etc/resolv.conf", "r");
+ global $g;
+
+ $fr = fopen("{$g['varetc_path']}/resolv.conf", "r");
if (! $fr) {
printf("Error: cannot open resolv.conf in tinydns_register_forwarding_servers().\n");
return 1;
@@ -1034,6 +1040,8 @@ EOD;
}
function dnscache_use_root_servers($index = 0) {
+ global $g;
+
$rootservers =<<<EOD
198.41.0.4
192.228.79.201
@@ -1051,13 +1059,13 @@ function dnscache_use_root_servers($index = 0) {
EOD;
- exec("echo 0 > /etc/dnscache{$index}/env/FORWARDONLY");
- if(is_dir("/etc/dnscache{$index}/root/servers/"))
- exec("rm -R /etc/dnscache{$index}/root/servers/");
- exec("mkdir -p /etc/dnscache{$index}/root/servers/");
- $fr = fopen("/etc/dnscache{$index}/root/servers/@", "w");
+ exec("echo 0 > {$g['varetc_path']}/etc/dnscache{$index}/env/FORWARDONLY");
+ if(is_dir("{$g['varetc_path']}/etc/dnscache{$index}/root/servers/"))
+ exec("/bin/rm -R {$g['varetc_path']}/etc/dnscache{$index}/root/servers/");
+ exec("/bin/mkdir -p {$g['varetc_path']}/etc/dnscache{$index}/root/servers/");
+ $fr = fopen("{$g['varetc_path']}/etc/dnscache{$index}/root/servers/@", "w");
if (! $fr) {
- printf("Error: cannot write to /etc/dnscache{$index}/root/servers/@ in dnscache_use_root_servers().\n");
+ printf("Error: cannot write to {$g['varetc_path']}/etc/dnscache{$index}/root/servers/@ in dnscache_use_root_servers().\n");
return 1;
}
fwrite($fr, $rootservers);