source: clfs-embedded/bootscripts/clfs/rc.d/init.d/network@ 423fe6b

Last change on this file since 423fe6b was 423fe6b, checked in by Maarten Lankhorst <mlankhorst@…>, 15 years ago

add a udhcpc.conf script to make udhcpc actually useful

  • Property mode set to 100755
File size: 1.6 KB
RevLine 
[a44b91b]1#!/bin/ash
2#
3# Network interface(s) init script
4#
5# config: /etc/network.conf
6# /etc/network.d/interface.[devname]
7
8. /etc/rc.d/init.d/functions
9. /etc/network.conf
10
11if [ "$NETWORKING" != "yes" ]; then
12 echo "Networking is disabled in /etc/network.conf"
13 exit 0
14fi
15
16case "$1" in
17start)
18 for i in /etc/network.d/interface.*
19 do
20 if [ -r "$i" ]; then
21 . $i
22 if [ "$DHCP" = "yes" ]; then
23 echo -n "Starting DHCP for interface $INTERFACE: "
[423fe6b]24 # udhcpc is braindead, bring up interface first
25 ifconfig "$INTERFACE" up
26
27 # Bridging code requires some time to wake up
28 [ "$INTERFACE" = "br0" ] && sleep 5
29
30 udhcpc -b -i "$INTERFACE" -s /etc/udhcpc.conf \
[a44b91b]31 -p "/var/run/udhcpc.$INTERFACE.pid" \
32 > /dev/null
33 else
34 echo -n "Setting up interface $INTERFACE: "
35 ifconfig "$INTERFACE" "$IPADDRESS" \
36 netmask "$NETMASK" \
37 broadcast "$BROADCAST" up
38 fi
39 check_status
40 fi
41 done
42
43 if [ "$USE_GATEWAY" = "yes" -a -n "$GATEWAY" ]; then
44 echo -n "Setting default route: "
45 route add default gw $GATEWAY
46 check_status
47 fi
48 ;;
49stop)
50 if [ "$USE_GATEWAY" = "yes" -a -n "$GATEWAY" ]; then
51 echo -n "Removing default route: "
52 route del -net 0.0.0.0
53 check_status
54 fi
55
56 for i in /etc/network.d/interface.*
57 do
58 if [ -r "$i" ]; then
59 . $i
60 echo -n "Shutting down interface $INTERFACE: "
61 ifconfig $INTERFACE down
62 check_status
63 if [ "$DHCP" = "yes" ]; then
[c05e923]64 kill `cat "/var/run/udhcpc.$INTERFACE.pid"` 2>/dev/null || true
[a44b91b]65 sleep 1
66 fi
67 fi
68 done
69 ;;
70restart)
71 $0 stop
72 $0 start
73 ;;
74status)
75 ifconfig
76 route
77 ;;
78*)
79 echo "Usage: $0 {start|stop|restart|status}"
80 exit 1
81esac
Note: See TracBrowser for help on using the repository browser.