]> git.pld-linux.org Git - projects/rc-scripts.git/blob - rc.d/init.d/network
- zmiana syntaxy dla routingu statycznego
[projects/rc-scripts.git] / rc.d / init.d / network
1 #!/bin/sh
2 #
3 # network       Bring up/down networking
4 #
5 # chkconfig: 2345 10 90
6 # description: Activates/Deactivates all network interfaces configured to \
7 #              start at boot time.
8 # probe: true
9
10 # Source function library.
11 . /etc/rc.d/init.d/functions
12 . /etc/rc.d/init.d/functions.network
13
14 [ ! -f /etc/sysconfig/network ] && exit 0
15
16 . /etc/sysconfig/network
17
18 # Check that networking is up.
19 [ "${NETWORKING}" == "no" -o "${NETWORKING}" == "" ] && exit 0
20
21 [ -x /sbin/ifconfig ] || exit 0
22
23 ######
24 # initialize networking:
25 # - check IPv4, IPv6, IPX can be handled by system
26 # - setup default IPv{4,6} interfaces policy like:
27 #   - forwarding,
28 #   - spoofig protection,
29 #   - icmp echo ignore broadcasts,
30 # - setup lo interface
31 network_init()
32 {
33 [ -f /etc/sysconfig/interfaces/ifcfg-lo ] && /sbin/ifup lo boot
34
35 }
36
37 ######
38 # deinitialize networking
39 # - down lo interface.
40 network_deinit()
41 {
42 [ -f /etc/sysconfig/interfaces/ifcfg-lo ] && /sbin/ifdown lo boot
43
44 }
45
46 interfaces="`cd /etc/sysconfig/interfaces && ls -1 ifcfg-* | grep -v ifcfg-lo | xargs 2> /dev/null`"
47 tunnels="`cd /etc/sysconfig/interfaces && ls -1 tnlcfg-* | xargs 2> /dev/null`"
48
49 # See how we were called.
50 case "$1" in
51   start)
52         network_init
53         for i in $tunnels do
54                 [ -f /etc/sysconfig/interfaces/$i ] && /sbin/tnlup $i boot
55         done
56         for i in $interfaces; do
57                 [ -f $i ] && /sbin/ifup $i boot
58         done
59         touch /var/lock/subsys/network
60         ;;
61   stop)
62         for i in $interfaces; do
63                 [ -f $i ] && /sbin/ifdown $i boot
64         done
65         for i in $tunnels do
66                 [ -f /etc/sysconfig/interfaces/$i ] && /sbin/tnldown $i boot
67         done
68         network_deinit
69         rm -f /var/lock/subsys/network
70         ;;
71   status)
72         echo "Configured devices:"
73         echo lo $interfaces
74
75         echo "Currently active devices:"
76         echo `/sbin/ifconfig | grep ^[a-z] | awk '{print $1}'`
77         ;;
78   restart)
79         $0 stop
80         $0 start
81         ;;
82   *)
83         echo "Usage: network {start|stop|restart|status}"
84         exit 1
85 esac
86
87 exit 0
This page took 0.050807 seconds and 4 git commands to generate.