[ADD] conf for archlinux, <init>
[arrow.git] / archlinux_conf / home / .bin / shell / getip
blob986a182e8fa6a240d63f1602237b6c00895ce8db
1 #!/bin/sh
3 #dhclient a ip from dhcp server
4 #if give a parameter 'fix', I will fix eth0 ip to 172.21.5.133
6 isfixip=$1
7 FIXIP=172.21.5.133
8 IFACE=${ETH_LAN}
10 sudo killall -9 dhcpcd 1>/dev/null 2>&1
11 #echo $isfixip
12 #if [ "$isfixip" != "fix" ]; then
13 sudo killall -9 dhclient
14 sudo dhclient $IFACE
15 echo "--------------------"
16 if [ "$?" = "0" ]; then
17 echo "get ip from dhcp server success"
18 else
19 echo "occur err when get ip for $IFACE"
20 exit 1
22 if [ -x /etc/init.d/xinetd ]; then
23 /etc/init.d/xinetd restart
25 #fi
27 if [ "$isfixip" = "fix" ]; then
28 #fix ip to $FIXIP now
29 sudo ifconfig $IFACE $FIXIP
30 sudo ifconfig $IFACE down
31 sudo ifconfig $IFACE up
32 #did success our do
33 if [ "$?" = "0" ]; then
34 echo "arrow:you have fix ip($FIXIP) success -_-"
35 else
36 echo "arrow:check fix ip correct ?"
38 echo "--------------------"
39 #will restart inet2
40 sudo /etc/rc.d/rc.inet1 restart
41 #if [ -x /etc/init.d/xinetd ]; then
42 #/etc/init.d/xinetd restart
43 #fi
44 sudo /etc/rc.d/rc.inet2 restart
45 else
46 echo "DONE success dynamic ip"
47 sudo killall -9 dhcpcd 1>/dev/null 2>&1
50 sudo killall -9 dhclient
52 #ping -c 4 $GW