Hello Leaf configurators

Sorry to answer my own post,  but I wanted to keep it in the thread.

with a few small shell scripts ( ugly probably ;) )  it is possible to 
extract the variables from the config files to the database ( for a first 
setup  not for persistant working that should be the wrong way 
around. 

Example network interfaces ( trouble is the parts that should be 
commented out) 

As an possible example

# Option 1.1 (default): eth0 / dynamic IP from pump/dhclient
$eth0_dyn_auto_notset auto eth0
$eth0_dyn_notset eth0 inet dhcp
#
# Option 1.2: eth0 / Fixed IP (assumed to be 1.2.3.4).
#               (broadcast/gateway optional)
$eth0_auto_fix_notset auto eth0
$eth0_fix_notset iface eth0 inet static
$eth0_fix_notset        address $eth0_ip
$eth0_fix_notset        masklen $eth0_masklen
$eth0_fix_notset        broadcast $eth0_bc
$eth0_fix_notset        gateway $eth0_gw
#
# Option 1.3: PPP/PPPOE (modem connected to eth0)
#auto ppp0
#iface ppp0 inet ppp
#       pre-up ip link set eth0 up
#       provider dsl-provider eth0
#
# Option 1.4: PPP modem
#auto ppp0
#iface ppp0 inet ppp
#       provider provider

# Step 2: configure  internal interface
# Default: eth1 / fixed IP = 192.168.1.254
$eth1_fix_auto_notset  auto eth1
$eth1_fix_notset iface eth1 inet static
$eth1_fix_notset address $eth1_ip
$eth1_fix_notset        masklen $eth1_masklen
$eth1_fix_notset        broadcast $eth1_bc
#

ignore the names .

now with the following script you can add those variables to the 
database 
-------------------------------
!/bin/bash
#extracts vars from the configuration templates
#and adds them to the database
#
# $1 is the template to search
#
database=/leaf/test/database
templatedir=/leaf/test/tmplate

sed --silent '/\$[a-zA-Z0-9_][a-zA-Z0-9_]*/p' $templatedir/$1| \
sed 's/\$/\
\$/g
s/\(\$[a-zA-Z0-9_][a-zA-Z0-9_]*\).*$/\1/' |\
sort |uniq | cut -c2- |while read varname
do
grep -q "$varname=" $database  || echo $varname="empty" 
>>$database
done
-----------------

Regards
Eric Wolzak
member of the bering crew



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

_______________________________________________
leaf-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/leaf-devel

Reply via email to