blob: 16d0505e1285390b674e838175a5e7b52e5b2964 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#!/bin/rc
fn confignet{
# get primary default interface if not specified
if(~ $#* 0){
e=/net/ether*
if(! ~ $e '/net/ether*')
*=(ether $e(1))
}
# setup wifi encryption if any
if(~ $1 ether && test -x /bin/aux/wpa){
essid=`{grep '^essid: ' $2/ifstats >[2]/dev/null | sed 's/^essid: //; q'}
if(! ~ $#essid 0){
if(! ~ $#wpapsk 0 || grep -s '^status: need authentication' $2/ifstats >[2]/dev/null){
x=(aux/wpa -s $"essid)
if(! ~ $#wpapsk 0){
echo 'key proto=wpapsk' `{!password=$"wpapsk whatis essid !password} > /mnt/factotum/ctl
wpapsk=()
}
if not {
x=($x -p)
}
$x $2
}
essid=()
}
rm -f /env/^(essid wpapsk)
}
if(~ $1 ether gbe && ~ $#* 2) @{
ip/ipconfig -6 $*
test -e /env/nora6 || ip/ipconfig $* ra6 recvra 1 &
ip/ipconfig -p $* &
wait
}
if not {
ip/ipconfig -p $*
}
if(~ $#fs 0)
fs=`{awk -F'=' '/^[ ]*fs=/{print $2}' /net/ndb}
if(~ $#auth 0)
auth=`{awk -F'=' '/^[ ]*auth=/{print $2}' /net/ndb}
if(~ $#fs 0)
ask fs ' address is? ' $auth(1)
if(~ $#auth 0)
ask auth ' address is? ' $fs(1)
# resolve dns names
if(test -x /bin/ndb/dnsgetip){
for(i in fs auth secstore){
x=`{for(x in $$i) ndb/dnsgetip -a $x}
~ $#x 0 || $i=$x
}
}
# publish info in /net/ndb for factotum
>> /net/ndb {
echo
echo 'ipbootinfo='
for(i in $fs) echo ' fs='^$i
for(i in $auth) echo ' auth='^$i
}
}
fn connecttcp{
while(! ~ $#fs 0 && ! srv -q tcp!$fs(1)^!564 boot)
fs=$fs(2-);
fs=$fs(1)
}
fn connecttls{
while(! ~ $#fs 0 && ! srvtls -q tcp!$fs(1)^!17020 boot)
fs=$fs(2-);
fs=$fs(1)
}
fn connectil{
while(! ~ $#fs 0 && ! srv -q il!$fs(1)^!17008 boot)
fs=$fs(2-);
fs=$fs(1)
}
mtcp=(confignet connecttcp)
mtls=(confignet connecttls)
mil=(confignet connectil)
mt=(mtcp mtls mil $mt)
|