Magellan Linux

Annotation of /trunk/openslp/multicast_route_set.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1447 - (hide annotations) (download) (as text)
Wed Jul 27 16:38:50 2011 UTC (12 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 1269 byte(s)
-no -n
1 niro 1445 #!/bin/sh
2    
3 niro 1444 PING_OPTIONS_1='-c1 -w1'
4     PING_OPTIONS_2='-c1 -i1'
5     MULTICAST_ADDRESS='239.255.255.253'
6     TMP_FILE=/tmp/route.check
7     PING_ERROR_NO_ROUTE='unreachable'
8    
9     MSG_FAILED_TO_FIND='Failed to Detect Multicast Route'
10     MSG_SUCCESS_ON_FIND='Multicast Route Enabled'
11     MSG_ADDING_ROUTE='Attempting to Add Multicast Route ...'
12     MSG_FAILED_TO_ADD=' FAILED - Route NOT Added.'
13     MSG_SUCCES_ON_ADD=' SUCCESS - Route Added.'
14    
15     CMD_GET_INTERFACE="netstat -i | awk 'BEGIN{}(NR>2)&&(!/^lo*/){print \$1}'"
16     CMD_ADD_ROUTE="route add -net 224.0.0.0 netmask 240.0.0.0"
17    
18     ping $PING_OPTIONS_1 $MULTICAST_ADDRESS 2> $TMP_FILE 1> /dev/null
19     if [ $? = 2 ]; then
20     ping $PING_OPTIONS_2 $MULTICAST_ADDRESS 2> $TMP_FILE 1> /dev/null
21     fi
22    
23     grep $PING_ERROR_NO_ROUTE $TMP_FILE > /dev/null 2>&1
24     err_unreachable_found=$?
25    
26     #If errors, add route. Otherwise, do nothing
27     if [ -s $TMP_FILE ] && [ $err_unreachable_found = 0 ]; then
28    
29     if [ $1 != 0 ]; then
30 niro 1446 echo $MSG_FAILED_TO_FIND
31     echo $MSG_ADDING_ROUTE
32 niro 1444 fi
33    
34     $CMD_ADD_ROUTE `eval $CMD_GET_INTERFACE` > /dev/null 2>&1
35     retval=$?
36     if [ $1 != 0 ]; then
37    
38     if [ $retval = 0 ]; then
39 niro 1446 echo $MSG_SUCCES_ON_ADD
40 niro 1444 else
41 niro 1446 echo $MSG_FAILED_TO_ADD
42 niro 1444 fi
43     fi
44     else
45     if [ $1 != 0 ]; then
46 niro 1447 echo $MSG_SUCCESS_ON_FIND
47 niro 1444 fi
48     retval=0
49     fi
50    
51     rm -f $TMP_FILE # Clean up
52     exit $retval