105 |
105 |
/usr/bin/env \
|
106 |
106 |
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
|
107 |
107 |
/usr/sbin/daemon -f /bin/sh -c "\$command \$svscan_servicedir 2>&1 | /usr/local/bin/readproctitle service errors: ................................................................................................................................................................................................................................................................................................................................................................................................................ &" > /dev/null
|
108 |
|
minicron {$refreshinterval} {$g['varrun_path']}/ping_hosts.pid "/etc/ping_hosts.sh; cd {$g['varetc_path']}/etc/tinydns/root && /usr/local/bin/tinydns-data"
|
|
108 |
minicron {$refreshinterval} {$g['varrun_path']}/ping_hosts.pid "/etc/ping_hosts.sh; cd {$g['varetc_path']}/tinydns/root && /usr/local/bin/tinydns-data"
|
109 |
109 |
}
|
110 |
110 |
|
111 |
111 |
svscan_stop_post () {
|
... | ... | |
173 |
173 |
exec("rm /usr/local/www/*tinydns*");
|
174 |
174 |
exec("rm /usr/local/pkg/*tinydns*");
|
175 |
175 |
exec("rm /usr/local/pkg/pf/*tinydns*");
|
176 |
|
exec("rm -rf {$g['varetc_path']}/etc/tinydns {$g['varrun_path']}/service/tinydns {$g['varetc_path']}/axfrdns");
|
177 |
|
exec("rm -rf {$g['varetc_path']}/etc/dnscache* {$g['varrun_path']}/service/dnscache*");
|
|
176 |
exec("rm -rf {$g['varetc_path']}/tinydns {$g['varrun_path']}/service/tinydns {$g['varetc_path']}/axfrdns");
|
|
177 |
exec("rm -rf {$g['varetc_path']}/dnscache* {$g['varrun_path']}/service/dnscache*");
|
178 |
178 |
filter_configure();
|
179 |
179 |
conf_mount_ro();
|
180 |
180 |
}
|
... | ... | |
207 |
207 |
exec("/usr/sbin/pw useradd Gdnslog");
|
208 |
208 |
exec("/usr/sbin/pw useradd Gdnscache");
|
209 |
209 |
exec("/usr/sbin/pw useradd Gaxfrdns");
|
210 |
|
exec("/bin/rm -r {$g['varetc_path']}/etc/dnscache*");
|
|
210 |
exec("/bin/rm -r {$g['varetc_path']}/dnscache*");
|
211 |
211 |
exec("/bin/rm -r {$g['varrun_path']}/service/dnscache*");
|
212 |
212 |
|
213 |
213 |
/* TinyDNS Server */
|
214 |
|
exec("/usr/local/bin/tinydns-conf Gtinydns Gdnslog {$g['varetc_path']}/etc/tinydns {$dnsserverip}");
|
215 |
|
exec("/bin/ln -s {$g['varetc_path']}/etc/tinydns {$g['varrun_path']}/service/");
|
|
214 |
exec("/usr/local/bin/tinydns-conf Gtinydns Gdnslog {$g['varetc_path']}/tinydns {$dnsserverip}");
|
|
215 |
exec("/bin/ln -s {$g['varetc_path']}/tinydns {$g['varrun_path']}/service/");
|
216 |
216 |
|
217 |
217 |
/* AXFRDNS - Zone transfers */
|
218 |
218 |
if(is_array($ztipaddress))
|
219 |
|
exec("/usr/local/bin/axfrdns-conf Gaxfrdns Gdnslog {$g['varetc_path']}/etc/axfrdns {$g['varetc_path']}/etc/tinydns {$dnsserverip}");
|
220 |
|
exec("/bin/ln -s {$g['varetc_path']}/etc/axfrdns {$g['varrun_path']}/service/");
|
|
219 |
exec("/usr/local/bin/axfrdns-conf Gaxfrdns Gdnslog {$g['varetc_path']}/axfrdns {$g['varetc_path']}/tinydns {$dnsserverip}");
|
|
220 |
exec("/bin/ln -s {$g['varetc_path']}/axfrdns {$g['varrun_path']}/service/");
|
221 |
221 |
|
222 |
|
exec("echo {$dnsserverip} > {$g['varetc_path']}/etc/tinydns/env/IP");
|
|
222 |
exec("echo {$dnsserverip} > {$g['varetc_path']}/tinydns/env/IP");
|
223 |
223 |
exec("/usr/bin/killall -9 tinydns");
|
224 |
224 |
|
225 |
225 |
if($config['installedpackages']['tinydns']['config'][0]['enableforwarding']) {
|
... | ... | |
227 |
227 |
exec("/bin/cp {$g['varetc_path']}/resolv.conf {$g['varetc_path']}/resolv.conf.original");
|
228 |
228 |
exec("/bin/cp {$g['varetc_path']}/resolv.conf {$g['varetc_path']}/resolv.conf.dnscache");
|
229 |
229 |
exec("echo domain {$config['system']['domain']} > {$g['varetc_path']}/resolv.conf");
|
230 |
|
exec("rm -rf {$g['varetc_path']}/etc/dnscache* {$g['varrun_path']}/service/dnscache*");
|
|
230 |
exec("rm -rf {$g['varetc_path']}/dnscache* {$g['varrun_path']}/service/dnscache*");
|
231 |
231 |
foreach ($interfaces as $dnsidx => $dnsif) {
|
232 |
232 |
$dnscacheif = convert_friendly_interface_to_real_interface_name($dnsif);
|
233 |
233 |
$dnscacheip = find_interface_ip($dnscacheif);
|
... | ... | |
237 |
237 |
$ipmask = $config['interfaces'][$dnsif]['subnet'];
|
238 |
238 |
$arr = tinydns_get_ip_subnet_arpa($dnscacheip, $ipmask);
|
239 |
239 |
$dnsuserip = $arr[0];
|
240 |
|
exec("/bin/mkdir -p {$g['varetc_path']}/etc/dnscache{$dnsidx}");
|
241 |
|
exec("/usr/local/bin/dnscache-conf Gdnscache Gdnslog {$g['varetc_path']}/etc/dnscache{$dnsidx} {$dnscacheip}");
|
242 |
|
exec("/bin/ln -s {$g['varetc_path']}/etc/dnscache{$dnsidx} {$g['varrun_path']}/service/");
|
243 |
|
if (!is_dir("{$g['varetc_path']}/etc/dnscache{$dnsidx}/env/IP"))
|
244 |
|
exec("/bin/mkdir -p {$g['varetc_path']}/etc/dnscache{$dnsidx}/env");
|
245 |
|
exec("echo {$dnscacheip} > {$g['varetc_path']}/etc/dnscache{$dnsidx}/env/IP");
|
|
240 |
exec("/bin/mkdir -p {$g['varetc_path']}/dnscache{$dnsidx}");
|
|
241 |
exec("/usr/local/bin/dnscache-conf Gdnscache Gdnslog {$g['varetc_path']}/dnscache{$dnsidx} {$dnscacheip}");
|
|
242 |
exec("/bin/ln -s {$g['varetc_path']}/dnscache{$dnsidx} {$g['varrun_path']}/service/");
|
|
243 |
if (!is_dir("{$g['varetc_path']}/dnscache{$dnsidx}/env/IP"))
|
|
244 |
exec("/bin/mkdir -p {$g['varetc_path']}/dnscache{$dnsidx}/env");
|
|
245 |
exec("echo {$dnscacheip} > {$g['varetc_path']}/dnscache{$dnsidx}/env/IP");
|
246 |
246 |
tinydns_dnscache_forwarding_servers($dnsidx);
|
247 |
|
if (!is_dir("{$g['varetc_path']}/etc/dnscache{$dnsidx}/root/ip"))
|
248 |
|
exec("/bin/mkdir -p {$g['varetc_path']}/etc/dnscache{$dnsidx}/root/ip");
|
249 |
|
exec("/usr/bin/touch {$g['varetc_path']}/etc/dnscache{$dnsidx}/root/ip/{$dnsuserip}");
|
|
247 |
if (!is_dir("{$g['varetc_path']}/dnscache{$dnsidx}/root/ip"))
|
|
248 |
exec("/bin/mkdir -p {$g['varetc_path']}/dnscache{$dnsidx}/root/ip");
|
|
249 |
exec("/usr/bin/touch {$g['varetc_path']}/dnscache{$dnsidx}/root/ip/{$dnsuserip}");
|
250 |
250 |
tinydns_create_soa_domain_list($dnsserverip, $dnsidx);
|
251 |
251 |
exec("echo nameserver {$dnscacheip} >> {$g['varetc_path']}/resolv.conf");
|
252 |
252 |
}
|
... | ... | |
256 |
256 |
exec("/bin/cp {$g['varetc_path']}/resolv.conf.original {$g['varetc_path']}/resolv.conf");
|
257 |
257 |
$interfaces = explode(",", $$config['installedpackages']['tinydns']['config'][0]['interface']);
|
258 |
258 |
foreach ($interfaces as $dnsidx => $dnsif) {
|
259 |
|
if(is_dir("{$g['varetc_path']}/etc/dnscache{$dnsidx}"))
|
|
259 |
if(is_dir("{$g['varetc_path']}/dnscache{$dnsidx}"))
|
260 |
260 |
dnscache_use_root_servers($dnsidx);
|
261 |
261 |
}
|
262 |
262 |
exec("/usr/bin/killall -9 dnscache");
|
... | ... | |
287 |
287 |
$ztipaddress = populate_zt_array();
|
288 |
288 |
if(!is_array($ztipaddress))
|
289 |
289 |
return;
|
290 |
|
$fd = fopen("{$g['varetc_path']}/etc/axfrdns/tcp","w");
|
|
290 |
$fd = fopen("{$g['varetc_path']}/axfrdns/tcp","w");
|
291 |
291 |
if(!$fd) {
|
292 |
|
log_error("Could not open {$g['varetc_path']}/etc/axfrdns/tcp for writing");
|
|
292 |
log_error("Could not open {$g['varetc_path']}/axfrdns/tcp for writing");
|
293 |
293 |
return;
|
294 |
294 |
}
|
295 |
295 |
foreach($ztipaddress as $zt) {
|
... | ... | |
925 |
925 |
function tinydns_dnscache_forwarding_servers($index) {
|
926 |
926 |
global $g, $config;
|
927 |
927 |
|
928 |
|
exec("echo 1 > {$g['varetc_path']}/etc/dnscache{$index}/env/FORWARDONLY");
|
929 |
|
if(is_dir("{$g['varetc_path']}/etc/dnscache{$index}/root/servers/"))
|
930 |
|
exec("rm -R {$g['varetc_path']}/etc/dnscache/root/servers/");
|
931 |
|
exec("/bin/mkdir -p {$g['varetc_path']}/etc/dnscache{$index}/root/servers/");
|
|
928 |
exec("echo 1 > {$g['varetc_path']}/dnscache{$index}/env/FORWARDONLY");
|
|
929 |
if(is_dir("{$g['varetc_path']}/dnscache{$index}/root/servers/"))
|
|
930 |
exec("rm -R {$g['varetc_path']}/dnscache/root/servers/");
|
|
931 |
exec("/bin/mkdir -p {$g['varetc_path']}/dnscache{$index}/root/servers/");
|
932 |
932 |
if (intval($config['version']) >= 6)
|
933 |
|
exec("/bin/cat {$g['varetc_path']}/nameserver_* > {$g['varetc_path']}/etc/dnscache{$index}/root/servers/@");
|
|
933 |
exec("/bin/cat {$g['varetc_path']}/nameserver_* > {$g['varetc_path']}/dnscache{$index}/root/servers/@");
|
934 |
934 |
else {
|
935 |
935 |
$fr = fopen("{$g['varetc_path']}/resolv.conf.dnscache", "r");
|
936 |
936 |
if (! $fr) {
|
... | ... | |
955 |
955 |
}
|
956 |
956 |
}
|
957 |
957 |
fclose($fr);
|
958 |
|
$fr = fopen("{$g['varetc_path']}/etc/dnscache{$index}/root/servers/@", "w");
|
|
958 |
$fr = fopen("{$g['varetc_path']}/dnscache{$index}/root/servers/@", "w");
|
959 |
959 |
if (! $fr) {
|
960 |
|
printf("Error: cannot write to {$g['varetc_path']}/etc/dnscache{$index}/root/servers/@ in tinydns_dnscache_forwarding_servers().\n");
|
|
960 |
printf("Error: cannot write to {$g['varetc_path']}/dnscache{$index}/root/servers/@ in tinydns_dnscache_forwarding_servers().\n");
|
961 |
961 |
return 1;
|
962 |
962 |
}
|
963 |
963 |
if($iprecords)
|
... | ... | |
966 |
966 |
}
|
967 |
967 |
}
|
968 |
968 |
|
969 |
|
/* This routine adds filenames to {$g['varetc_path']}/etc/dnscache/root/servers/ with the contents pointing to the tinyDNS server */
|
|
969 |
/* This routine adds filenames to {$g['varetc_path']}/dnscache/root/servers/ with the contents pointing to the tinyDNS server */
|
970 |
970 |
function tinydns_create_soa_domain_list($dnsserverip, $index = 0) {
|
971 |
971 |
global $g;
|
972 |
972 |
if(file_exists("{$g['varrun_path']}/service/tinydns/root/data"))
|
... | ... | |
985 |
985 |
if($fqdn) {
|
986 |
986 |
$rtypes = tinydns_get_dns_record_type($dnsrecord);
|
987 |
987 |
if($rtypes[0] == "SOA") {
|
988 |
|
$fr = fopen("{$g['varetc_path']}/etc/dnscache{$index}/root/servers/{$fqdn}", "w");
|
|
988 |
$fr = fopen("{$g['varetc_path']}/dnscache{$index}/root/servers/{$fqdn}", "w");
|
989 |
989 |
if (! $fr) {
|
990 |
|
printf("Error: cannot open {$g['varetc_path']}/etc/dnscache{$index}/root/servers/{$fqdn} in tinydns_create_soa_domain_list().\n");
|
|
990 |
printf("Error: cannot open {$g['varetc_path']}/dnscache{$index}/root/servers/{$fqdn} in tinydns_create_soa_domain_list().\n");
|
991 |
991 |
return 1;
|
992 |
992 |
}
|
993 |
993 |
if($fqdn)fwrite($fr, $dnsserverip);
|
... | ... | |
1086 |
1086 |
|
1087 |
1087 |
EOD;
|
1088 |
1088 |
|
1089 |
|
exec("echo 0 > {$g['varetc_path']}/etc/dnscache{$index}/env/FORWARDONLY");
|
1090 |
|
if(is_dir("{$g['varetc_path']}/etc/dnscache{$index}/root/servers/"))
|
1091 |
|
exec("/bin/rm -R {$g['varetc_path']}/etc/dnscache{$index}/root/servers/");
|
1092 |
|
exec("/bin/mkdir -p {$g['varetc_path']}/etc/dnscache{$index}/root/servers/");
|
1093 |
|
$fr = fopen("{$g['varetc_path']}/etc/dnscache{$index}/root/servers/@", "w");
|
|
1089 |
exec("echo 0 > {$g['varetc_path']}/dnscache{$index}/env/FORWARDONLY");
|
|
1090 |
if(is_dir("{$g['varetc_path']}/dnscache{$index}/root/servers/"))
|
|
1091 |
exec("/bin/rm -R {$g['varetc_path']}/dnscache{$index}/root/servers/");
|
|
1092 |
exec("/bin/mkdir -p {$g['varetc_path']}/dnscache{$index}/root/servers/");
|
|
1093 |
$fr = fopen("{$g['varetc_path']}/dnscache{$index}/root/servers/@", "w");
|
1094 |
1094 |
if (! $fr) {
|
1095 |
|
printf("Error: cannot write to {$g['varetc_path']}/etc/dnscache{$index}/root/servers/@ in dnscache_use_root_servers().\n");
|
|
1095 |
printf("Error: cannot write to {$g['varetc_path']}/dnscache{$index}/root/servers/@ in dnscache_use_root_servers().\n");
|
1096 |
1096 |
return 1;
|
1097 |
1097 |
}
|
1098 |
1098 |
fwrite($fr, $rootservers);
|