"Fossies" - the Fresh Open Source Software Archive

Member "freeha-1.0/service_scripts/vip.start" (23 Nov 2006, 1895 Bytes) of package /linux/privat/old/freeha-1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 #-------------------------------------------------------------------------#
    4 # Script to plumb up a "virtual IP" for cluster services to use           #
    5 # Provided as a tool to be called from 'starthasrv'                       #
    6 #                                                                         #
    7 # USAGE:   vip.start IP NICNAME                                           #
    8 #    EG:   vip.start 10.3.5.7 eri0                                        #
    9 #             (MUST be ip addr, not name)                                 #
   10 #  Script will automatically add a ":1", or whatever, to the physical NIC #
   11 #     Do not specify a virtual NICNAME like eth0:1                        #
   12 #                                                                         #
   13 #  Standard UNIX status: returns 0 on okay, non-0 on fail.                #
   14 #-------------------------------------------------------------------------#
   15 
   16 
   17 
   18 #This is tweaked for Solaris, because that's what I have to play with.
   19 # Please submit whatever tweaks are neccessary for your favorite OS.
   20 
   21 PATH=$PATH:/usr/sbin:/sbin
   22 
   23 if [ "$2" = "" ] ; then
   24     echo vip.start: ERROR: no NIC specified
   25     echo vip.start: Need IP and base interface name
   26     exit 1
   27 fi
   28 case "$1" in
   29     [0-9]*)
   30         break
   31         ;;
   32     *)
   33         echo vip.start: ERROR: no IP address specified
   34         echo vip.start: Need IP and base interface name
   35         exit 1
   36         ;;
   37 esac
   38 
   39 
   40 # Is it already up?
   41 #This uses the same algorithm as vip.stop
   42 exists=`ifconfig -a | awk '
   43 $1 ~ /:/        {split($1,nic,":"); 
   44                  lastif=sprintf("%s:%s",nic[1],nic[2]);}
   45 $2 == "'$1'"    { print lastif ; exit; }
   46 
   47 '`
   48 
   49 if [ "$exists" = "" ] ; then
   50     ping $1 1>/dev/null 2>&1
   51     if [ $? -eq 0 ] ; then
   52     echo "vip.start: ERROR: vip $1 already active elsewhere! Cannot continue!"
   53     exit 1
   54     fi
   55 else
   56     echo vip.start: NOTICE: vip already exists, as $exists
   57     exit 0
   58 fi
   59 
   60 ifconfig $2 addif $1 netmask + broadcast + up