blob: a090d854f0f9c0db8e3c040b875295b9c6f17540 (
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
#!/bin/sh
# net-start
#
# can also be run via "start net" or "start network"
#
# find which dhcp client
if [ -x /usr/sbin/dhcpcd ]
then
DHCPCLIENT="/usr/sbin/dhcpcd"
elif [ -x /sbin/udhcpc ]
then
DHCPCLIENT="/sbin/udhcpc"
else
echo "No DHCP client found!"
fi
/sbin/net-stop # bring down any interfaces and kill dhcp clients
[ -d /etc/proc ] || mkdir /etc/proc
probed=`dmesg | grep eth[0-9]: | cut -d: -f1`
cd /etc/tux/config/
found_faces=`ls eth*`
echo "Found configs for: $found_faces"
# first bring up interfaces
for i in $found_faces
do
echo -n "Configuring $i:"
if grep dhcp /etc/tux/config/$i > /dev/null 2> /dev/null
then
DHCP="true"
# things are really easy we just do dhcp
echo " using DHCP"
killall dhcpcd 2> /dev/null
sleep 1
if [ $DHCPCLIENT = "/usr/sbin/dhcpcd" ]
then
$DHCPCLIENT $i 2> /dev/null
else
$DHCPCLIENT -i $i 2> /dev/null
fi
else # static IP
if [ -f /etc/tux/config/$i ]
then
echo "settings found"
IP=`cut -d" " -f1 /etc/tux/config/$i`
MASK=`cut -d" " -f2 /etc/tux/config/$i`
if [ "$IP" ]
then
ifconfig $i $IP netmask $MASK up
fi
else
echo "no settings found, skipping..."
fi
fi
if [ "$i" = "eth0" ]
then
ifconfig $face | grep inet | cut -d":" -f2 | cut -d" " -f1 | grep -v 127.0.0.1 > /etc/proc/ipaddr
ln -sf /etc/proc/ipaddr /etc/proc/$i
nslookup `cat /etc/proc/ipaddr` | grep -v default | grep Name | cut -d":" -f2 | tr -d ' ' | tail -n 1 > /etc/proc/hostname
fi
done
if [ "$DHCP" ]
then
echo "Skipping DNS and gateway config"
else
echo -n "Adding default route: "
GW=`cat /etc/tux/config/gateway`
echo "$GW"
if [ "$GW" ]
then
route add default gw $GW
echo "done"
else
echo "failed"
fi
echo -n "Builing /etc/resolv.conf (DNS): "
# need to fix this for multiple DNS servers
DNS=`cat /etc/tux/config/dns 2>/dev/null`
if [ "$DNS" ]
then
echo "nameserver $DNS" > /etc/resolv.conf
else
echo "failed"
fi
fi
# update /etc/hosts and set HOSTNAME
IPADDR=`cat /etc/proc/ipaddr`
if [ -f /etc/tux/config/hostname ]
then
HOSTNAME=`cat /etc/tux/config/hostname`
else
HOSTNAME=`cat /etc/proc/hostname`
hlen=`length "$HOSTNAME"`
if [ "$hlen" -lt 1 ]
then
HOSTNAME='trinux'
fi
fi
echo "Setting hostname: $HOSTNAME"
hostname $HOSTNAME
echo "Building /etc/hosts"
if [ -f /etc/tux/config/hosts ]
then
cp /etc/tux/config/hosts /etc/hosts
fi
echo "127.0.0.1 localhost" >> /etc/hosts
echo "$IPADDR $HOSTNAME" >> /etc/hosts
sleep 3
|