summaryrefslogtreecommitdiff
path: root/rc
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-05-10 19:38:01 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2018-05-10 19:38:01 +0200
commitfcb974af3a3b9747083b618fb6be7a4e70df3201 (patch)
tree9929998eeee52bb92659ec1ec2ae8677be02ceb8 /rc
parent0e5888a0cf993c89e4d52fd80b07990993e5abac (diff)
parenteb3951bcd48399d4d7239a9d396a113e95e38be9 (diff)
downloadplan9front-fcb974af3a3b9747083b618fb6be7a4e70df3201.tar.xz
merge
Diffstat (limited to 'rc')
-rwxr-xr-xrc/bin/cpurc27
-rwxr-xr-xrc/bin/ipv6on104
-rwxr-xr-xrc/bin/termrc19
3 files changed, 30 insertions, 120 deletions
diff --git a/rc/bin/cpurc b/rc/bin/cpurc
index a410d3dcb..404f494ff 100755
--- a/rc/bin/cpurc
+++ b/rc/bin/cpurc
@@ -5,7 +5,7 @@
NPROC=`{wc -l </dev/sysstat}
# bind all likely devices
-for(i in t S P '$')
+for(i in u t S P '$')
bind -a '#'^$i /dev >/dev/null >[2=1]
rm -f /env/i
@@ -56,12 +56,19 @@ if(test -e /cfg/$sysname/cpurc)
# automatic ip address setup
if(test -r /net/ipselftab){
if(! grep u /net/ipselftab | grep -sv 127.0.0.1){
- ether=`{ndb/query sys $sysname ether}
- if(~ $#ether 1){
- # try /lib/ndb first, then do dhcp
- ip/ipconfig -N >[2]/dev/null || ip/ipconfig -h $sysname
+ addrs=`{ndb/query -a sys $sysname ether}
+ if(! ~ $#addrs 0){
+ for(ether in /net/ether*){
+ addr=`{cat $ether/addr}
+ switch($addr){
+ case $addrs
+ # try /lib/ndb first, then do dhcp
+ ip/ipconfig -N ether $ether >[2]/dev/null \
+ || ip/ipconfig -h $sysname ether $ether
+ }
+ }
}
- rm -f /env/ether
+ rm -f /env/ether /env/addrs /env/addr
}
}
@@ -77,16 +84,16 @@ if(! ps|grep -s timesync){
sleep 2
}
-if(~ $#auth 0){
- auth=`{ndb/query sys $sysname auth}
- . <{ndb/ipquery sys $sysname auth | sed 's, +,\n,g'}
-}
if(test -d /cfg/$sysname/service)
serviced=/cfg/$sysname/service
if not if(test -d /cfg/default/service)
serviced=/cfg/default/service
if not
serviced=/rc/bin/service
+if(~ $#auth 0){
+ auth=`{ndb/query sys $sysname auth}
+ . <{ndb/ipquery sys $sysname auth | sed 's, +,\n,g'}
+}
switch($auth){
case `{ echo $sysname; ndb/query sys $sysname dom
if(test -r /net/ipselftab){
diff --git a/rc/bin/ipv6on b/rc/bin/ipv6on
deleted file mode 100755
index 703feed76..000000000
--- a/rc/bin/ipv6on
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/bin/rc
-# ipv6on [netdir ndbfile [gwv4]] - configure an interface for ipv6,
-# once ipv4 is configured.
-if (! ~ $#* 0 2 3) {
- echo usage: $0 '[netdir ndbfile [gw-v4-name]]' >[1=2]
- exit usage
-}
-rfork e
-if (~ $#* 0) {
- netdir=/net
- ndbf=/lib/ndb/local
- gw=`{ndb/ipquery sys $sysname ipgw | sed 's/ipgw=//'}
-}
-if not {
- netdir=$1
- ndbf=$2
- if (~ $#* 2)
- # gw=()
- gw=`{ndb/ipquery sys $sysname ipgw | sed 's/ipgw=//'}
- if not
- gw=$3
-}
-if (~ $netdir /net) {
- xsfx=()
- xdir=()
-}
-if not {
- xsfx=(-x `{echo $netdir | sed 's;^/net;;'})
- xdir=(-x $netdir)
-}
-fn nonnil { # variable
- if (~ $#$1 0) {
- echo no ip for $1
- exit no-ip
- }
- if (! ~ $#$1 1) {
- echo multiple ips for $1
- exit multiple-ips
- }
-}
-devdir=`{awk '/^device/{print $2}' $netdir/ipifc/*/status | grep -v /dev/null}
-nonnil devdir
-devtype=pkt
-if(~ $devdir *ether*)
- devtype=ether
-
-#
-# configure v6 for link-local addresses (fe80::) & multicast (ff02::)
-#
-if (! ip/ipconfig -6 $xdir $devtype $devdir)
- exit 'ipconfig -6 failed'
-ip/ipconfig $xdir $devtype $devdir ra6 recvra 1
-
-mev6=`{ndb/query -f $ndbf sys $sysname ipv6 | grep :}
-if (~ $#mev6 0)
- mev6=`{ndb/query -mf $ndbf sys $sysname ip | grep :}
-# mev4=`{ndb/query -f $ndbf sys $sysname ip | grep -v :}
-
-# for testing
-if(~ $devtype ether){
- mylnk=`{ip/linklocal `{cat $devdir/addr}}
- nonnil mylnk
-}
-
-if (~ $#gw 1) {
- if (~ $gw [0-9]*.[0-9]*.[0-9]*.[0-9]*)
- gwv4=$gw
- if (~ $#gwv4 0)
- gwv4=`{ndb/query -f $ndbf sys $gw ip | grep -v :}
- if (~ $gw *:*)
- gwv6=$gw
- if (~ $#gwv6 0)
- gwv6=`{ndb/query -f $ndbf sys $gw ipv6 | grep :}
- if (~ $#gwv6 0)
- gwv6=`{ndb/query -f $ndbf sys $gw ip | grep :}
- if (~ $#gwv6 0) {
- if (~ $#gwv4 1) {
- # echo ping gw $gwv4...
- # load arp cache with gw mac
- ip/ping -qn 3 $netdir/icmp!$gwv4 >/dev/null >[2=1] &
- sleep 1 # wait for ping
-
- gweth=`{grep '* '^$gwv4^' ' $netdir/arp | awk '{print $4}' }
- nonnil gweth
- gwlnk=`{ip/linklocal $gweth}
- nonnil gwlnk
- gwv6=$gwlnk
- }
- }
-}
-nonnil mev6
-#
-# configure my global v6 addresses
-#
-ip/ipconfig $xdir $devtype $devdir add $mev6 /64
-ip/ipconfig $xdir loopback /dev/null add $mev6 /128
-
-if (~ $#gwv6 1) {
- #
- # add default v6 route to v6 addr of v4 gw
- #
- echo add :: /0 $gwv6 >$netdir/iproute # need not be link-local
-}
-exit ''
diff --git a/rc/bin/termrc b/rc/bin/termrc
index dfc99968b..f160915e6 100755
--- a/rc/bin/termrc
+++ b/rc/bin/termrc
@@ -6,7 +6,7 @@ TIMESYNCARGS=(-rLa1000000)
NPROC=`{wc -l </dev/sysstat}
# bind all likely devices
-for(i in v t m i f S P L A '$')
+for(i in u v t m i f S P L A '$')
bind -a '#'^$i /dev >/dev/null >[2=1]
rm -f /env/i
@@ -57,12 +57,19 @@ if(test -e /cfg/$sysname/termrc)
# automatic ip address setup
if(test -r /net/ipselftab){
if(! grep u /net/ipselftab | grep -sv 127.0.0.1){
- ether=`{ndb/query sys $sysname ether}
- if(~ $#ether 1){
- # try /lib/ndb first, then do dhcp
- ip/ipconfig -N >[2]/dev/null || ip/ipconfig -h $sysname
+ addrs=`{ndb/query -a sys $sysname ether}
+ if(! ~ $#addrs 0){
+ for(ether in /net/ether*){
+ addr=`{cat $ether/addr}
+ switch($addr){
+ case $addrs
+ # try /lib/ndb first, then do dhcp
+ ip/ipconfig -N ether $ether >[2]/dev/null \
+ || ip/ipconfig -h $sysname ether $ether
+ }
+ }
}
- rm -f /env/ether
+ rm -f /env/ether /env/addrs /env/addr
}
}