pari: branch aadk r515 - in /branches/aadk: ./ config/ scripts/
asterisk-gui-commits at lists.digium.com
asterisk-gui-commits at lists.digium.com
Wed Mar 28 12:15:08 MST 2007
Author: pari
Date: Wed Mar 28 14:15:07 2007
New Revision: 515
URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=515
Log:
networking stuff - update from bkruse
Added:
branches/aadk/scripts/
branches/aadk/scripts/networking.sh
Modified:
branches/aadk/Makefile
branches/aadk/config/networking.html
Modified: branches/aadk/Makefile
URL: http://svn.digium.com/view/asterisk-gui/branches/aadk/Makefile?view=diff&rev=515&r1=514&r2=515
==============================================================================
--- branches/aadk/Makefile (original)
+++ branches/aadk/Makefile Wed Mar 28 14:15:07 2007
@@ -171,7 +171,23 @@
echo " -- in $(ASTETCDIR)/manager.conf" ; \
exit 1; \
fi
-
+ @echo -n "Checking for the network configuration script: "
+ @if [ -f $(ASTETCDIR)/networking.sh ]; then \
+ echo "OK"; \
+ else \
+ echo "NOT FOUND"; \
+ echo " -- Please Run 'make install' in the GUI Source Directory" ; \
+ exit 1; \
+ fi
+ @echo -n "Checking for the networking.conf: "
+ @if [ -f $(ASTETCDIR)/networking.conf ]; then \
+ echo "OK"; \
+ else \
+ echo "NOT FOUND"; \
+ echo " -- However, networking.conf is NOT required from initial install. " ; \
+ echo " -- Creating networking.conf ...." ; \
+ echo "; Generating via the GUI's source installer. " > $(ASTETCDIR)/networking.conf; \
+ fi
@echo " --- Everything looks good --- "
@echo " * GUI should be available at $(HTTPURL) "
@echo " * Before using the GUI, Please run the install script at $(HTTPSETUPURL) "
@@ -221,6 +237,10 @@
@for x in config/*.html; do \
echo "$$x --> $(CONFIGDIR)" ; \
$(INSTALL) -m 644 $$x $(CONFIGDIR)/ ; \
+ done
+ @for x in scripts/*; do \
+ echo "$$x --> $(ASTETCDIR)" ; \
+ $(INSTALL) -m 644 $$x $(ASTETCDIR)/ ; \
done
@if [ -x /usr/sbin/asterisk-gui-post-install ]; then \
/usr/sbin/asterisk-gui-post-install $(DESTDIR) . ; \
Modified: branches/aadk/config/networking.html
URL: http://svn.digium.com/view/asterisk-gui/branches/aadk/config/networking.html?view=diff&rev=515&r1=514&r2=515
==============================================================================
--- branches/aadk/config/networking.html (original)
+++ branches/aadk/config/networking.html Wed Mar 28 14:15:07 2007
@@ -1,22 +1,17 @@
<!--
- * Asterisk-GUI - an Asterisk configuration interface
+ * Manage network settings on the appliance
*
- * Manage Network Settings
- *
- * Copyright (C) 2006-2007, Digium, Inc.
+ * Copyright (C) 2006 - 2007, Digium, Inc.
*
* Mark Spencer <markster at digium.com>
+ * Pari Nannapaneni <pari at digium.com>
* Brandon Kruse <bkruse at digium.com>
*
- * See http://www.asterisk.org for more information about
- * the Asterisk project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
+ * All Rights Reserved.
*
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE file
- * at the top of the source tree.
+ * Distribution of this file is subject to the license
+ * agreement you accepted when obtained and/or activated
+ * the Digium product containing this file.
*
-->
<script src="scripts/prototype.js"></script>
@@ -25,7 +20,7 @@
<link href="stylesheets/rico.css" media="all" rel="Stylesheet" type="text/css" />
<link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
<script>
- var nwfields = ["DHCP_WAN", "IP_WAN", "SUBNET_WAN", "GATEWAY_WAN","DNS_WAN","DHCP_LAN", "IP_LAN", "SUBNET_LAN", "GATEWAY_LAN", "DNS_LAN", "ROUTER_IPRANGE", "SSH_STATUS", "status", "save", "cancel"];
+ var nwfields = ["HOSTNAME","DHCP_WAN","IP_WAN","SUBNET_WAN","GATEWAY_WAN","DNS_WAN","DHCP_LAN","IP_LAN","SUBNET_LAN","GATEWAY_LAN","DNS_LAN","SSH_STATUS","TFTP_LAN","ROUTER_LAN","LEASE_LAN","NTP_LAN","MAX_LEASE","START_RANGE_LAN","END_RANGE_LAN","DOMAIN_LAN","status","save","cancel"];
var widgets = {};
var networkingcallbacks = {};
@@ -42,16 +37,16 @@
networkingcallbacks.savechanges = function(){
- //parent.astmanEngine.run_tool("sh /etc/asterisk/apply_networking.sh ", callback = function() {
- // any Javascript you want to execute after apply_networking is executed.
- //} );
+
+ parent.astmanEngine.run_tool("sh /etc/asterisk/networking.sh options=WAN DHCP_WAN=" + _$('DHCP_WAN').value + " IP_WAN=" + _$('IP_WAN').value + " SUBNET_WAN=" + _$('SUBNET_WAN').value + " GATEWAY_WAN=" + _$('GATEWAY_WAN').value + " DNS_WAN=" + _$('DNS_WAN').value + " DHCP_LAN=" + _$('DHCP_LAN').value + " IP_LAN=" + _$('IP_LAN').value + " SUBNET_LAN=" + _$('SUBNET_LAN').value + " GATEWAY_LAN=" + _$('GATEWAY_LAN').value + " DNS_LAN=" + _$('DNS_LAN').value + " START_RANGE_LAN=" + _$('START_RANGE_LAN').value + " END_RANGE_LAN=" + _$('END_RANGE_LAN').value + " SSH_STATUS=" + _$('SSH_STATUS').value + " HOSTNAME=" + _$('HOSTNAME').value + " LEASE_LAN=" + _$('LEASE_LAN').value + " NTP_LAN=" + _$('NTP_LAN').value + " TFTP_LAN=" + _$('TFTP_LAN').value + " DOMAIN_LAN=" + _$('DOMAIN_LAN').value);
+ /* Lets hope this does not character buffer overflow :( */
}
function localajaxinit() {
setWindowTitle("Network Settings");
- for (var x =0; x < nwfields.length; x++ ) {
+ for (var x=0; x < nwfields.length; x++ ) {
widgets[nwfields[x]] = $(nwfields[x]);
widgets[nwfields[x]].disabled = true;
}
@@ -67,6 +62,10 @@
<table class="mainscreenTable" align="center">
<tr><td valign="top" align="center">
<table align="center">
+ <TR>
+ <TD><B>Hostname</B></TD>
+ <TD><input type="text" id='HOSTNAME' size=14></TD>
+ </TR>
<TR> <TD><B>WAN Settings</B></TD>
<TD></TD>
</TR>
@@ -88,6 +87,9 @@
<TR> <TD><B>LAN Settings</B></TD>
<TD></TD>
</TR>
+ <TR> <TD>Domain</TD>
+ <TD><input type="text" id='DOMAIN_LAN'></TD>
+ </TR>
<TR> <TD>DHCP</TD>
<TD><input type="checkbox" id='DHCP_LAN'></TD>
</TR>
@@ -103,8 +105,26 @@
<TR> <TD>DNS</TD>
<TD><input type="text" id='DNS_LAN' size=14></TD>
</TR>
- <TR> <TD>ROUTER IP Range</TD>
- <TD><input type="text" id='ROUTER_IPRANGE' size=14></TD>
+ <TR> <TD>IP Start Range</TD>
+ <TD><input type="text" id='START_RANGE_LAN' size=14></TD>
+ </TR>
+ <TR> <TD>IP End Range</TD>
+ <TD><input type="text" id='END_RANGE_LAN' size=14></TD>
+ </TR>
+ <TR> <TD>Lease Time (in Miliseconds)</TD>
+ <TD><input type="text" id='LEASE_LAN' size=14></TD>
+ </TR>
+ <TR> <TD>Max Number of Leases</TD>
+ <TD><input type="text" id='MAX_LEASE' size=14></TD>
+ </TR>
+ <TR> <TD>Optional Router IP</TD>
+ <TD><input type="text" id='ROUTER_LAN' size=14></TD>
+ </TR>
+ <TR> <TD>NTP Server</TD>
+ <TD><input type="text" id='NTP_LAN' size=14></TD>
+ </TR>
+ <TR> <TD>Tftp (Phone Provisioning)</TD>
+ <TD><input type="text" id='TFTP_LAN' size=14></TD>
</TR>
<TR> <TD><B>SSH</B></TD>
<TD><input type="checkbox" id='SSH_STATUS'></TD>
Added: branches/aadk/scripts/networking.sh
URL: http://svn.digium.com/view/asterisk-gui/branches/aadk/scripts/networking.sh?view=auto&rev=515
==============================================================================
--- branches/aadk/scripts/networking.sh (added)
+++ branches/aadk/scripts/networking.sh Wed Mar 28 14:15:07 2007
@@ -1,0 +1,112 @@
+#!/bin/bash
+################################################################
+# Copyright Digium && Brandon Kruse <bkruse at digium.com> (c)#####
+# ##############################################################
+# This is a bash script to apply network settings from the GUI.#
+################################################################
+WAN_INTERFACE="eth0"
+LAN_INTERFACE="eth1"
+DNS_CONFIG="/etc/config/resolv.conf"
+DHCP_CONFIG="/etc/udhcpd.conf"
+DHCP_BIN="`which udhcpd`"
+DHCP_SERVER="udhcpd"
+####################################################################
+
+for i in $* # This looks a little wierd, but its for setting our envirnment variables
+do
+export $i # If someone passed var=woot on the command line, we can access it easily using $var, automatically
+done
+
+####################################################################
+# #
+# Now for the real logic in the script. #
+# (Note: You CANNOT use functions with msh/busybox.) #
+####################################################################
+############### Set our hostname real quick
+if [ "$HOSTNAME" != "" ]
+then
+hostname $HOSTNAME&
+fi
+
+############### Set our time server
+if [ "$NTP_LAN" != "" ]
+then
+ntpdate $NTP_LAN&
+fi
+
+
+####################################################################
+# #
+# First we will do the WAN interface. #
+# #
+####################################################################
+
+if [ "$DHCP_WAN" = "on" ] #If dhcp_wan is set from the gui
+then
+ dhcpcd -k
+ dhcpcd $WAN_INTERFACE&
+else
+ ifconfig $WAN_INTERFACE down # Take down our interface real quick for changes..
+ ifconfig $WAN_INTERFACE $IP_WAN netmask $SUBNET_WAN # Add our basic values to ifconfig
+ echo "`cat $DNS_CONFIG | grep search`" > ${DNS_CONFIG}.tmp # Save the previous "search" field
+ mv ${DNS_CONFIG}.tmp $DNS_CONFIG # you cannot cat from the same file your writing to.
+ echo "nameserver $DNS_WAN" > $DNS_CONFIG # Add the ip/hostname of the nameserver
+ route add default gw $GATEWAY_WAN dev $WAN_INTERFACE # Add our default gateway for the wan interface
+ ifconfig $WAN_INTERFACE up # bring it up with our new settings
+fi
+
+####################################################################
+# #
+# Now we will do the LAN interface(s). #
+# #
+####################################################################
+
+if [ "$DHCP_LAN" = "off" ] # They do not want to use dhcp on the network
+then
+ # We could exit now? Since we arent going to be distributing any IP's, clients are on their own.
+ echo "dhcp for lan is off"
+else
+ ifconfig $LAN_INTERFACE down # Take down our interface real quick for changes..
+ ifconfig $LAN_INTERFACE $IP_LAN netmask $SUBNET_LAN # Add our basic values to ifconfig
+ route add default gw $GATEWAY_LAN dev $LAN_INTERFACE # Add our default gateway for the Lan interface
+ ifconfig $LAN_INTERFACE up # bring it up with our new settings
+
+ # Now we will edit /etc/udhcpd.conf
+ echo "start $START_RANGE_LAN" > $DHCP_CONFIG
+ echo "end $END_RANGE_LAN" >> $DHCP_CONFIG
+ echo "interface $LAN_INTERFACE" >> $DHCP_CONFIG
+ echo "max_leases $MAX_LEASE" >> $DHCP_CONFIG
+ if [ "$DNS_LAN" != "" ]
+ then
+ echo "opt dns $DNS_LAN" >> $DHCP_CONFIG
+ fi
+ if [ "$ROUTER_LAN" != "" ]
+ then
+ echo "opt router $ROUTER_LAN" >> $DHCP_CONFIG
+ fi
+ if [ "$DOMAIN_LAN" != "" ]
+ then
+ echo "opt domain $DOMAIN_LAN" >> $DHCP_CONFIG
+ fi
+ if [ "$LEASE_LAN" != "" ]
+ then
+ echo "opt lease $LEASE_LAN" >> $DHCP_CONFIG
+ else
+ echo "opt lease 8640000" >> $DHCP_CONFIG
+ fi
+ if [ "$TFTP_LAN" != "" ]
+ then
+ echo "opt tftp $TFTP_LAN" >> $DHCP_CONFIG
+ fi
+ if [ "$NTP_LAN" != "" ]
+ then
+ echo "opt ntpsrv $NTP_LAN" >> $DHCP_CONFIG
+ fi
+ ########Stop and restart our dhcp server.################
+ killall -9 $DHCP_SERVER; $DHCP_BIN&
+ ##########Done###########################################
+fi
+
+
+
+
More information about the asterisk-gui-commits
mailing list