]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/inst/ndbsetup
6824c919220a6bff6339c4c0309470a493ed268a
[plan9front.git] / rc / bin / inst / ndbsetup
1 #!/bin/rc
2
3 # desc: setup network configuration
4 # prereq: confignet copydist
5
6 etheraddr=`{cat /net/ether0/addr >[2]/dev/null}
7
8 switch($1){
9 case checkready checkdone
10         if(~ $#etheraddr 1 && ~ $netisfrom ether && ~ $ethermethod dhcp manual && \
11            ! grep -s $etheraddr /n/newfs/lib/ndb/local)
12                 ndbsetup=ready
13         if not
14                 ndbsetup=done
15         export ndbsetup
16
17 case go
18         echo
19         echo 'Setup network configuration'
20         echo
21
22         default=()
23         if(~ $#sysname 1)
24                 default=(-d $sysname)
25         prompt $default 'sysname'
26         sysname=$rd
27
28         cp /n/newfs/lib/ndb/local /tmp/ndb.local
29         {
30                 ssam 'x/^.*ether='^$etheraddr^'.*$/ d' /tmp/ndb.local
31                 
32                 se = ('sys='^$sysname 'ether='^$etheraddr)
33
34                 echo
35                 switch($ethermethod){
36                 case dhcp
37                         echo $se
38                 case manual
39                         echo $se 'ip='^$ipaddr 'ipmask='^$ipmask 'ipgw='^$gwaddr
40                         if(! ~ $#DNSSERVER 0){
41                                 echo '  '       'dns='^$DNSSERVER
42                         }
43                 }
44                 echo
45         } >/n/newfs/lib/ndb/local
46 }