]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/inst/ndbsetup
/lib/rob: Just write the code.
[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                 echo
33                 switch($ethermethod){
34                 case dhcp
35                         echo 'sys='^$sysname 'ether='^$etheraddr
36
37                 case manual
38                         echo 'sys='^$sysname 'ether='^$etheraddr \
39                                 'ip='^$ipaddr 'ipmask='^$ipmask 'ipgw='^$gwaddr
40                 }
41                 echo
42         } >/n/newfs/lib/ndb/local
43 }