plan9fox/rc/bin/inst/ndbsetup

47 lines
889 B
Text
Raw Normal View History

2011-06-12 08:15:50 +00:00
#!/bin/rc
# desc: setup network configuration
# prereq: confignet copydist
etheraddr=`{cat $netdev/addr >[2]/dev/null}
2011-06-12 08:15:50 +00:00
switch($1){
case checkready checkdone
if(~ $#etheraddr 1 && ~ $netisfrom ether && ~ $ethermethod automatic manual && \
! grep -s $etheraddr /n/newfs/lib/ndb/local)
2011-06-12 08:15:50 +00:00
ndbsetup=ready
if not
ndbsetup=done
export ndbsetup
2011-06-12 08:15:50 +00:00
case go
echo
echo 'Setup network configuration'
echo
default=()
if(~ $#sysname 1)
default=(-d $sysname)
prompt $default 'sysname'
sysname=$rd
cp /n/newfs/lib/ndb/local /tmp/ndb.local
2011-06-12 08:15:50 +00:00
{
ssam 'x/^.*ether='^$etheraddr^'.*$/ d' /tmp/ndb.local
se = ('sys='^$sysname 'ether='^$etheraddr)
2011-06-12 08:15:50 +00:00
echo
switch($ethermethod){
case automatic
echo $se
2011-06-12 08:15:50 +00:00
case manual
echo $se 'ip='^$ipaddr 'ipmask='^$ipmask 'ipgw='^$gwaddr
if(! ~ $#DNSSERVER 0){
echo ' ' 'dns='^$DNSSERVER
}
2011-06-12 08:15:50 +00:00
}
echo
} >/n/newfs/lib/ndb/local
2011-06-12 08:15:50 +00:00
}