From: <abe...@us...> - 2016-06-07 17:48:35
|
Revision: 7709 http://sourceforge.net/p/astlinux/code/7709 Author: abelbeck Date: 2016-06-07 17:48:33 +0000 (Tue, 07 Jun 2016) Log Message: ----------- web interface, Network and Edit tab, add support for Avahi mDNS/DNS-SD Modified Paths: -------------- branches/1.0/package/webinterface/altweb/admin/edit.php branches/1.0/package/webinterface/altweb/admin/network.php branches/1.0/package/webinterface/altweb/common/functions.php Modified: branches/1.0/package/webinterface/altweb/admin/edit.php =================================================================== --- branches/1.0/package/webinterface/altweb/admin/edit.php 2016-06-06 15:45:38 UTC (rev 7708) +++ branches/1.0/package/webinterface/altweb/admin/edit.php 2016-06-07 17:48:33 UTC (rev 7709) @@ -1,6 +1,6 @@ <?php -// Copyright (C) 2008-2015 Lonnie Abelbeck +// Copyright (C) 2008-2016 Lonnie Abelbeck // This is free software, licensed under the GNU General Public License // version 3 as published by the Free Software Foundation; you can // redistribute it and/or modify it under the terms of the GNU @@ -11,6 +11,7 @@ // 12-04-2008, Added Reload/Restart Menu // 02-18-2013, Added OpenVPN Client Config editing // 09-06-2013, Added Shortcut support +// 06-07-2016, Added Avahi mDNS/DNS-SD support // $myself = $_SERVER['PHP_SELF']; @@ -31,6 +32,7 @@ 'fossil' => 'Restart Fossil Server', 'ldap' => 'Reload LDAP Client', 'slapd' => 'Restart LDAP Server', + 'avahi' => 'Restart mDNS/DNS-SD', 'monit' => 'Restart Monit Monitor', 'darkstat' => 'Restart NetStat Server', 'snmpd' => 'Restart SNMP Server', @@ -256,6 +258,8 @@ $result = restartPROCESS($process, 46, $result, 'init'); } elseif ($process === 'fossil') { $result = restartPROCESS($process, 47, $result, 'init'); + } elseif ($process === 'avahi') { + $result = restartPROCESS($process, 48, $result, 'init'); } elseif ($process === 'cron') { $result = updateCRON('root', 30, $result); } @@ -298,6 +302,8 @@ $dir === '/mnt/kd/snmp' || $dir === '/mnt/kd/fop2' || $dir === '/mnt/kd/kamailio' || + $dir === '/mnt/kd/avahi' || + $dir === '/mnt/kd/avahi/services' || $dir === '/mnt/kd/monit' || $dir === '/mnt/kd/monit/monit.d' || $dir === '/mnt/kd/ups' || @@ -392,6 +398,8 @@ putHtml('<p style="color: green;">Monit Monitoring'.statusPROCESS('monit').'.</p>'); } elseif ($result == 47) { putHtml('<p style="color: green;">Fossil Server'.statusPROCESS('fossil').'.</p>'); + } elseif ($result == 48) { + putHtml('<p style="color: green;">mDNS/DNS-SD (Avahi)'.statusPROCESS('avahi').'.</p>'); } elseif ($result == 99) { putHtml('<p style="color: red;">Action Failed.</p>'); } elseif ($result == 999) { @@ -556,6 +564,24 @@ } putHtml('</optgroup>'); } + if (is_dir('/mnt/kd/avahi') && count($globfiles = glob('/mnt/kd/avahi/*')) > 0) { + putHtml('<optgroup label="———— Avahi mDNS/DNS-SD Configs ————">'); + foreach ($globfiles as $globfile) { + if (is_file($globfile) && is_writable($globfile)) { + $sel = ($globfile === $openfile) ? ' selected="selected"' : ''; + putHtml('<option value="'.$globfile.'"'.$sel.'>'.basename($globfile).' - Avahi Daemon Configuration</option>'); + } + } + if (is_dir('/mnt/kd/avahi/services') && count($globfiles = glob('/mnt/kd/avahi/services/*.service')) > 0) { + foreach ($globfiles as $globfile) { + if (is_file($globfile) && is_writable($globfile)) { + $sel = ($globfile === $openfile) ? ' selected="selected"' : ''; + putHtml('<option value="'.$globfile.'"'.$sel.'>services/'.basename($globfile).' - Avahi Service</option>'); + } + } + } + putHtml('</optgroup>'); + } if (is_dir('/mnt/kd/ups') && count($globfiles = glob('/mnt/kd/ups/*.conf')) > 0) { putHtml('<optgroup label="———— UPS Monitoring Configs ————">'); foreach ($globfiles as $globfile) { Modified: branches/1.0/package/webinterface/altweb/admin/network.php =================================================================== --- branches/1.0/package/webinterface/altweb/admin/network.php 2016-06-06 15:45:38 UTC (rev 7708) +++ branches/1.0/package/webinterface/altweb/admin/network.php 2016-06-07 17:48:33 UTC (rev 7709) @@ -1,6 +1,6 @@ <?php -// Copyright (C) 2008-2015 Lonnie Abelbeck +// Copyright (C) 2008-2016 Lonnie Abelbeck // This is free software, licensed under the GNU General Public License // version 3 as published by the Free Software Foundation; you can // redistribute it and/or modify it under the terms of the GNU @@ -37,6 +37,7 @@ // 12-16-2014, Added Monit Monitoring support // 08-21-2015, Added Fossil - Software Configuration Management // 11-01-2015, Added DHCPv6 support +// 06-07-2016, Added Avahi mDNS/DNS-SD support // // System location of rc.conf file $CONFFILE = '/etc/rc.conf'; @@ -488,6 +489,9 @@ $value = 'UPNP_LISTEN="'.trim($x_value).'"'; fwrite($fp, "### UPnP Listen Interfaces\n".$value."\n"); + $value = 'AVAHI_ENABLE="'.$_POST['avahi'].'"'; + fwrite($fp, "### mDNS/DNS-SD\n".$value."\n"); + $value = 'HTTPDIR="'.tuq($_POST['http_dir']).'"'; fwrite($fp, "### HTTP Server Directory\n".$value."\n"); @@ -954,6 +958,12 @@ $result = saveNETWORKsettings($NETCONFDIR, $NETCONFFILE); header('Location: /admin/zabbix.php'); exit; + } elseif (isset($_POST['submit_avahi'])) { + $result = saveNETWORKsettings($NETCONFDIR, $NETCONFFILE); + if (is_writable($file = '/mnt/kd/avahi/avahi-daemon.conf')) { + header('Location: /admin/edit.php?file='.$file); + exit; + } } elseif (isset($_POST['submit_edit_dnsmasq_conf'])) { $result = saveNETWORKsettings($NETCONFDIR, $NETCONFFILE); if (is_writable($file = '/mnt/kd/dnsmasq.conf')) { @@ -1077,6 +1087,8 @@ $result = restartPROCESS($process, 46, $result, 'init'); } elseif ($process === 'fossil') { $result = restartPROCESS($process, 47, $result, 'init'); + } elseif ($process === 'avahi') { + $result = restartPROCESS($process, 48, $result, 'init'); } } else { $result = 2; @@ -1167,6 +1179,8 @@ putHtml('<p style="color: green;">Monit Monitoring'.statusPROCESS('monit').'.</p>'); } elseif ($result == 47) { putHtml('<p style="color: green;">Fossil Server'.statusPROCESS('fossil').'.</p>'); + } elseif ($result == 48) { + putHtml('<p style="color: green;">mDNS/DNS-SD (Avahi)'.statusPROCESS('avahi').'.</p>'); } elseif ($result == 99) { putHtml('<p style="color: red;">Action Failed.</p>'); } elseif ($result == 100) { @@ -1248,6 +1262,8 @@ putHtml('<option value="ldap"'.$sel.'>Reload LDAP Client</option>'); $sel = ($reboot_restart === 'slapd') ? ' selected="selected"' : ''; putHtml('<option value="slapd"'.$sel.'>Restart LDAP Server</option>'); + $sel = ($reboot_restart === 'avahi') ? ' selected="selected"' : ''; + putHtml('<option value="avahi"'.$sel.'>Restart mDNS/DNS-SD</option>'); $sel = ($reboot_restart === 'monit') ? ' selected="selected"' : ''; putHtml('<option value="monit"'.$sel.'>Restart Monit Monitor</option>'); $sel = ($reboot_restart === 'darkstat') ? ' selected="selected"' : ''; @@ -1830,7 +1846,22 @@ $sel = isVARtype('UPNP_LISTEN', $db, $cur_db, 'DMZIF') ? ' checked="checked"' : ''; putHtml('<input type="checkbox" value="upnp_DMZIF" name="upnp_DMZIF"'.$sel.' /> DMZ'); putHtml('</td></tr>'); - + + if (is_file('/etc/init.d/avahi')) { + putHtml('<tr class="dtrow1"><td style="text-align: left;" colspan="6">'); + putHtml('mDNS/DNS-SD Service Discovery:'); + putHtml('<select name="avahi">'); + putHtml('<option value="no">disabled</option>'); + $sel = (getVARdef($db, 'AVAHI_ENABLE', $cur_db) === 'yes') ? ' selected="selected"' : ''; + putHtml('<option value="yes"'.$sel.'>enabled</option>'); + putHtml('</select>'); + if (is_writable('/mnt/kd/avahi/avahi-daemon.conf')) { + putHtml('–'); + putHtml('<input type="submit" value="Configure mDNS/DNS-SD" name="submit_avahi" class="button" />'); + } + putHtml('</td></tr>'); + } + putHtml('<tr class="dtrow1"><td style="text-align: left;" colspan="6">'); $value = getVARdef($db, 'HTTPDIR', $cur_db); putHtml('HTTP Server Directory:<input type="text" size="45" maxlength="64" value="'.$value.'" name="http_dir" />'); Modified: branches/1.0/package/webinterface/altweb/common/functions.php =================================================================== --- branches/1.0/package/webinterface/altweb/common/functions.php 2016-06-06 15:45:38 UTC (rev 7708) +++ branches/1.0/package/webinterface/altweb/common/functions.php 2016-06-07 17:48:33 UTC (rev 7709) @@ -116,6 +116,12 @@ } else { $str = $stopped; } + } elseif ($process === 'avahi') { + if (is_file($path.'avahi-daemon/pid')) { + $str = $running; + } else { + $str = $stopped; + } } elseif ($process === 'ups') { if (is_file($path.'upsmon.pid')) { $str = $running; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |