summaryrefslogtreecommitdiffstats
path: root/urunlevel/my_linux/Trinux/net-start
diff options
context:
space:
mode:
Diffstat (limited to 'urunlevel/my_linux/Trinux/net-start')
-rwxr-xr-xurunlevel/my_linux/Trinux/net-start141
1 files changed, 141 insertions, 0 deletions
diff --git a/urunlevel/my_linux/Trinux/net-start b/urunlevel/my_linux/Trinux/net-start
new file mode 100755
index 0000000..a090d85
--- /dev/null
+++ b/urunlevel/my_linux/Trinux/net-start
@@ -0,0 +1,141 @@
1#!/bin/sh
2# net-start
3#
4# can also be run via "start net" or "start network"
5#
6
7
8# find which dhcp client
9
10
11if [ -x /usr/sbin/dhcpcd ]
12then
13 DHCPCLIENT="/usr/sbin/dhcpcd"
14elif [ -x /sbin/udhcpc ]
15then
16 DHCPCLIENT="/sbin/udhcpc"
17else
18 echo "No DHCP client found!"
19fi
20
21/sbin/net-stop # bring down any interfaces and kill dhcp clients
22
23[ -d /etc/proc ] || mkdir /etc/proc
24
25probed=`dmesg | grep eth[0-9]: | cut -d: -f1`
26
27cd /etc/tux/config/
28found_faces=`ls eth*`
29
30echo "Found configs for: $found_faces"
31
32# first bring up interfaces
33
34for i in $found_faces
35do
36 echo -n "Configuring $i:"
37
38 if grep dhcp /etc/tux/config/$i > /dev/null 2> /dev/null
39 then
40 DHCP="true"
41 # things are really easy we just do dhcp
42 echo " using DHCP"
43 killall dhcpcd 2> /dev/null
44 sleep 1
45 if [ $DHCPCLIENT = "/usr/sbin/dhcpcd" ]
46 then
47 $DHCPCLIENT $i 2> /dev/null
48 else
49 $DHCPCLIENT -i $i 2> /dev/null
50 fi
51
52 else # static IP
53
54 if [ -f /etc/tux/config/$i ]
55 then
56 echo "settings found"
57 IP=`cut -d" " -f1 /etc/tux/config/$i`
58 MASK=`cut -d" " -f2 /etc/tux/config/$i`
59
60 if [ "$IP" ]
61 then
62 ifconfig $i $IP netmask $MASK up
63 fi
64
65 else
66 echo "no settings found, skipping..."
67 fi
68 fi
69
70
71 if [ "$i" = "eth0" ]
72 then
73 ifconfig $face | grep inet | cut -d":" -f2 | cut -d" " -f1 | grep -v 127.0.0.1 > /etc/proc/ipaddr
74 ln -sf /etc/proc/ipaddr /etc/proc/$i
75 nslookup `cat /etc/proc/ipaddr` | grep -v default | grep Name | cut -d":" -f2 | tr -d ' ' | tail -n 1 > /etc/proc/hostname
76 fi
77
78done
79
80if [ "$DHCP" ]
81then
82 echo "Skipping DNS and gateway config"
83else
84 echo -n "Adding default route: "
85
86 GW=`cat /etc/tux/config/gateway`
87
88 echo "$GW"
89 if [ "$GW" ]
90 then
91 route add default gw $GW
92 echo "done"
93 else
94 echo "failed"
95 fi
96
97 echo -n "Builing /etc/resolv.conf (DNS): "
98 # need to fix this for multiple DNS servers
99
100 DNS=`cat /etc/tux/config/dns 2>/dev/null`
101
102 if [ "$DNS" ]
103 then
104 echo "nameserver $DNS" > /etc/resolv.conf
105 else
106 echo "failed"
107 fi
108fi
109
110
111# update /etc/hosts and set HOSTNAME
112
113IPADDR=`cat /etc/proc/ipaddr`
114
115if [ -f /etc/tux/config/hostname ]
116then
117 HOSTNAME=`cat /etc/tux/config/hostname`
118else
119 HOSTNAME=`cat /etc/proc/hostname`
120 hlen=`length "$HOSTNAME"`
121
122 if [ "$hlen" -lt 1 ]
123 then
124 HOSTNAME='trinux'
125 fi
126fi
127
128echo "Setting hostname: $HOSTNAME"
129hostname $HOSTNAME
130
131echo "Building /etc/hosts"
132if [ -f /etc/tux/config/hosts ]
133then
134 cp /etc/tux/config/hosts /etc/hosts
135fi
136
137echo "127.0.0.1 localhost" >> /etc/hosts
138echo "$IPADDR $HOSTNAME" >> /etc/hosts
139
140sleep 3
141