tizen beta release
[platform/core/base/default-files-tizen.git] / etc / rc.d / init.d / network
1 #!/bin/sh
2 #
3 # network       This starts and stops network.
4
5
6 PATH=/sbin:/bin:/usr/bin:/usr/sbin
7
8 # Source function library.
9 . /etc/init.d/functions
10
11 # Get config.
12 [ -f "/etc/sysconfig/network" ] && . /etc/sysconfig/network
13
14 CWD=`pwd`
15 cd /etc/sysconfig/network-scripts
16
17 interfaces=`ls ifcfg-*`
18
19 # See how we were called.
20 case "$1" in
21     start)
22         for i in $interfaces; do 
23                 . ./$i 
24                 ifconfig ${DEVICE} ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK} up 
25                 if [ "$?" = "0" ]; then
26                         echo "  bring up $DEVICE successfully"
27                 else 
28                         echo "  fail to bring up $DEVICE."
29                 fi 
30         done 
31         
32         route add default gw ${GATEWAY} 
33
34         ;;
35     stop)
36         for i in $interfaces; do 
37                 . ./$i 
38                 ifconfig ${DEVICE} down 
39         done
40         ;;
41     restart)
42         cd $CWD 
43         $0 stop 
44         $0 start 
45         ;;
46     *)
47         echo $"Usage: $0 {start|stop|restart}"
48         RETVAL=1
49 esac
50
51 exit $RETVAL