2013-11-14 23:11:16 -07:00
|
|
|
#!/usr/bin/perl -w -I/www/cgi-bin
|
|
|
|
|
|
|
|
# this script generates the olsrd config file
|
|
|
|
# static part comes from /etc/config/olsrd.conf
|
|
|
|
# dynamic part depends on the node configuration
|
|
|
|
|
|
|
|
use perlfunc;
|
|
|
|
|
|
|
|
@names = @hosts = @services = ();
|
|
|
|
|
|
|
|
# canonical names for this node
|
|
|
|
# (they show up in reverse order, make the "official" name last)
|
|
|
|
push @names, $name if ($name = nvram_get("tactical"));
|
|
|
|
push @names, $name if ($name = nvram_get("node"));
|
|
|
|
|
|
|
|
# load the dhcp reservations when in dmz mode
|
|
|
|
if(-f "/etc/config/dmz-mode")
|
|
|
|
{
|
|
|
|
#($lanip, $lanmask, $lanbcast, $lannet) = get_ip4_network("eth0.0");
|
|
|
|
foreach(`cat /etc/ethers`)
|
|
|
|
{
|
|
|
|
next unless ($ip) = /[0-9a-f:]+\s+([\d\.]+)/i;
|
|
|
|
next unless $host = ip2hostname($ip);
|
|
|
|
push @hosts, qq("$ip" "$host");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-23 20:42:20 -06:00
|
|
|
# Add a name for the dtdlink interface.
|
|
|
|
if ($name = nvram_get("node"))
|
|
|
|
{
|
|
|
|
my ($dtdip,$dtdmask,$dtdbcast,$dtdnet);
|
|
|
|
($dtdip, $dtdmask, $dtdbcast, $dtdnet) = get_ip4_network("eth0.2");
|
|
|
|
push @hosts, qq("$dtdip" "dtdlink.$name.local.mesh");
|
|
|
|
}
|
|
|
|
|
2013-11-14 23:11:16 -07:00
|
|
|
# load the services
|
|
|
|
foreach(`cat /etc/config/services 2>/dev/null`)
|
|
|
|
{
|
|
|
|
next unless /^\w+:\/\/[\w\-\.]+:\d+(\/[^\|]*)?\|(tcp|udp)\|\w/;
|
|
|
|
chomp;
|
|
|
|
push @services, $_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# add the nameservice plugin
|
|
|
|
push @file, qq(\nLoadPlugin "olsrd_nameservice.so.0.3"\n);
|
|
|
|
push @file, qq({\n);
|
|
|
|
push @file, qq( PlParam "sighup-pid-file" "/var/run/dnsmasq.pid"\n);
|
|
|
|
push @file, qq( PlParam "interval" "30"\n);
|
|
|
|
push @file, qq( PlParam "timeout" "300"\n);
|
|
|
|
push @file, qq( PlParam "name-change-script" "touch /tmp/namechange"\n);
|
|
|
|
#push @file, qq( PlParam "lat" "1"\n);
|
|
|
|
#push @file, qq( PlParam "lon" "2"\n);
|
|
|
|
#push @file, qq( PlParam "laton-file" "/var/run/latlon.js"\n);
|
|
|
|
#push @file, qq( PlParam "laton-infile" "/tmp/latlon.txt"\n);
|
|
|
|
foreach(@names) { push @file, qq( PlParam "name" "$_"\n) }
|
|
|
|
foreach(@hosts) { push @file, qq( PlParam $_\n) }
|
|
|
|
foreach(@services) { push @file, qq( PlParam "service" "$_"\n) }
|
|
|
|
push @file, qq(}\n);
|
|
|
|
|
|
|
|
# write the file
|
2013-12-02 13:04:54 -07:00
|
|
|
print @file;
|