⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ipaddr.in

📁 linux集群服务器软件代码包
💻 IN
📖 第 1 页 / 共 2 页
字号:
  esac  BASEIP=`echo $1 | sed s'%/.*%%'`  SENDARPPIDFILE="$SENDARPPIDDIR/send_arp-$BASEIP"  case $SYSTYPE in    Linux|SunOS)		CURRENTIF=`find_interface "$BASEIP"`       		case $CURRENTIF in         	  lo*)            		remove_conflicting_loopback "$BASEIP" "$CURRENTIF"            		;;            	  *)	;;    		esac ;;    *)		;;  esac  if IFINFO=`find_free_interface $1`; then  	: OK got interface [$IFINFO] for $1  else  	exit 1  fi  IF=`echo "$IFINFO" | cut -f1`  if    [ -x $HA_RCDIR/local_takeip ]  then    $HA_RCDIR/local_takeip $*  fi  add_interface "$BASEIP" "$IFINFO" "$IF"  rc=$?  case $rc in    0)    		;;    *)		exit $rc		;;  esac  # add_route $BASEIP $IF  TARGET_INTERFACE=`echo $IF | sed 's%:.*%%'`  ha_log "info: Sending Gratuitous Arp for $BASEIP on $IF [$TARGET_INTERFACE]"  [ -r ${CONF_D}/arp_config ] && . ${CONF_D}/arp_config  [ -r "${CONF_D}/arp_config:${TARGET_INTERFACE}" ] && . "${CONF_D}/arp_config:${TARGET_INTERFACE}"  # Set default values (can be overridden as described above)  : ${ARP_INTERVAL_MS=500}	# milliseconds between ARPs  : ${ARP_REPEAT=10}		# repeat count  : ${ARP_BACKGROUND=yes}	# no to run in foreground (no longer any reason to do this)  : ${ARP_NETMASK=ffffffffffff}	# netmask for ARP    ARGS="-i $ARP_INTERVAL_MS -r $ARP_REPEAT -p $SENDARPPIDFILE $TARGET_INTERFACE $BASEIP auto $BASEIP $ARP_NETMASK"  ha_log "$SENDARP $ARGS"  case $ARP_BACKGROUND in    yes) ($SENDARP $ARGS || ha_log "ERROR: Could not send gratuitous arps")&;;    *)	  $SENDARP $ARGS || ha_log "ERROR: Could not send gratuitous arps";;  esac}ip_status() {  BASEIP=`echo $1 | sed -e s'%/.*%%'`  IF=`find_interface $BASEIP`  case $SYSTYPE in    *BSD)	if		$IFCONFIG $IFCONFIG_A_OPT | grep "inet.*[: ]$BASEIP " >/dev/null 2>&1	then		echo "running"; exit 0	else		echo "stopped"; exit 3	fi;;    Linux|SunOS)			if		[ -z "$IF" ]	then		echo "stopped"; exit 3	else		case $IF in		  lo*)			echo "loopback"; exit 0			;;		  *)			echo "running"; exit 0			;;		esac	fi;;    *)			if		[ -z "$IF" ]	then		echo "stopped"; exit 3	else		echo "running"; exit 0	fi;;  esac}##	Determine if this IP address is really being served, or not.#	Note that we don't distinguish if *we're* serving it locally...#ip_monitor() {  BASEIP=`echo $1 | sed s'%/.*%%'`  TIMEOUT=1 # seconds  case $SYSTYPE in        Linux)            # -c count -t timetolive -q(uiet) -n(umeric) -W timeout            PINGARGS="-c 1 -q -n -W $TIMEOUT $BASEIP"            ;;        SunOS)            PINGARGS="$BASEIP $TIMEOUT"            ;;        *)            PINGARGS="-c 1 @PING_TIMEOUT_OPT@ -q $BASEIP"            ;;  esac  for j in 1 2 3  do    if      @PING@ $PINGARGS >/dev/null 2>&1    then      echo "OK"      exit 0    fi  done  echo "down"  exit 1}usage() {  echo $USAGE >&2  echo "$Id: IPaddr.in,v 1.5 2004/11/10 00:22:13 gshi Exp $"}##	Add or remove IP alias for the given IP address...#if  [ $# -eq 1 ]then  case $1 in    info)	cat <<-!INFO	Abstract=IP address takeover	Argument=IP address OR IP address/broadcast address OR IP address/broadcast address/netmaskbits	Description:	An IPaddr resource is an IP address which is to be taken over by \\	the owning node.  An argument is required, and is of this form:	    nnn.nnn.nnn.nnn/bbb.bbb.bbb.bbb	Where nnn.nnn.nnn.nnn is the IP address to be taken over, and\\	bbb.bbb.bbb.bbb is the broadcast address to be used with this address.	Since IPaddr is the "default" resource type, it is not necessary\\	to prefix the IP address by "IPaddr::".	This allows IPaddr::192.2.4.63 to be abbreviated as 192.2.4.63.	!INFO	exit 0;;  esacfiif  [ $# -ne 2 ]then  usage  exit 1ficase $2 in  start)	ip_start $1;;  stop)		ip_stop $1;;  status)	ip_status $1;;  monitor)	ip_monitor $1;;  *)		usage 		exit 1		;;esacexit $?### $Log: IPaddr.in,v $# Revision 1.5  2004/11/10 00:22:13  gshi# return value should be $? instead of 0## Revision 1.4  2004/11/09 07:33:00  zhenh# fix some bugs of exit code## Revision 1.3  2004/11/08 20:48:36  gshi# implemented logging daemon## The logging daemon is to double-buffer log messages to protect us from blocking# writes to syslog / logfiles.## Revision 1.2  2004/08/27 15:22:00  andrew# Changes required for 2-node testing to complete:# - Fix issues stemming from node UUID support.# - Ensure the two-node tests complete# - Fixes to the test harness and scripts# - Changed IP addresses and node unames in tests (remember the --ip1|2 and --node1|2 options)# - Stop status actions when stopping resources# - Extra validation, particularly of CIB messages# - Cleanups in the common XML code# - Finished integration of LRM operation status info# - Monitor op now occurs every 9s (will be configurable eventually)# - Patched IPaddr to return the correct $? on status ops## Other# - Updated the .spec.in file to include the OCF RA dir# - Updated the lrm/test/Makefile.am to put its basic sanity check into the tarball## Revision 1.1  2004/08/27 09:34:14  lars# Moving heartbeat resource agents to new directory for consistency.## Revision 1.56  2004/05/07 11:29:52  andrew# Treat Darwin the same as the other BSD variants## Revision 1.55  2004/04/27 10:54:13  horms# Ooops, the previous commit was a mistake## Revision 1.54  2004/04/27 10:51:40  horms# Fix for pid code for FreeBSD (and others)## Revision 1.53  2004/04/19 18:09:39  alan# Some Solaris patches from Dominique Petitpierre <Dominique.Petitpierre@adm.unige.ch> to MailTo and IPaddr.## Revision 1.52  2004/02/05 05:12:30  alan# Doubled the number of ARPs (10), over a period of 5 seconds## Revision 1.51  2004/01/30 22:49:54  alan# Changed IPaddr so it exits with proper LSB exit codes# for status.## Revision 1.50  2003/10/29 11:40:50  horms# Send arp  creates a driectory to store its pid file in on-the-fly. IPaddr does likewise for state files.## Revision 1.49  2003/10/29 05:38:59  horms# Need to create these directories on-the-fly after all.## Revision 1.48  2003/10/24 07:07:44  horms# remove send arps pid file on stop if it exists## Revision 1.47  2003/10/23 08:03:17  horms# IPaddr and IPaddr2 both kill send_arp on stop# IPaddr defaults to running send_arp in the background# IPaddr2 used arp_config in the same way as IPaddr## Revision 1.46  2003/10/23 05:34:03  horms# create state directories for resources at install time instead of run time.## Revision 1.45  2003/10/15 17:04:40  horms# Merged  get_hw_addr into and send_arp## Revision 1.44  2003/07/16 13:43:30  alan# Redirected some irrelevant error messages from ls to /dev/null## Revision 1.43  2003/07/12 16:19:54  alan# Fixed a bug in the new send_arp options and their invocation...## Revision 1.42  2003/07/12 14:27:21  alan# Changed IPaddr to not go into background for ARPs, and greatly shortened# the inter-ARP-interval by using a new send_arp option.# These behaviors be overridden by setting parameters in /etc/ha.d/conf/arp_config# and/or /etc/ha.d/conf/arp_config:${TARGET_INTERFACE}## Revision 1.41  2003/05/21 09:02:32  horms# Free alias search optimisation by Sean Reifschneider## Revision 1.40  2003/05/21 08:42:57  horms# Free alias search optimisation by Sean Reifschneider## Revision 1.39  2003/03/24 08:17:05  horms# merged in changes from stable branch## Revision 1.38  2003/03/15 02:18:54  horms# Fixed mkdir logic and removed bash-isms. Alan## Revision 1.37  2003/03/14 12:29:56  horms# Restore of loopback device requires a tmp directory.# This is now autocreated as necessary.## Revision 1.36  2003/02/12 05:40:22  alan# Put in a bug fix from Gregor G鰏tl of Austria to fix the language# of the ifconfig command to English/C.# I have no idea why it's necessary in addition to the fix that's already# there.## Revision 1.35  2003/02/03 15:40:35  msoffen# Splitting the ifconfig onto 2 lines failed miserably. Put back on one.## Revision 1.34  2002/12/10 22:42:00  horms# ipaddri -> ipaddr## Revision 1.33  2002/12/10 22:18:39  horms# If IPaddr is running on Linux, and a VIP is obtained that# is on a loopback alias, then the loopback alias and the associated# route if it exists, is removed before the alias, usually on an ethernet# interface, is brought up.## When the VIP is relinquished the alias on the loopback is restored.## This is intended for use in conjunction with the LVS, where the# same host may be a Linux Director and a Real Server.## This feature explictly only works on Linux, as LVS only works on Linux.## Thanks to Lorn Kay who did a lot of the ground work to get this fix working.## Revision 1.32  2002/11/20 09:16:01  horms# do not fail if an interface is already configured## Revision 1.31  2002/10/22 02:48:04  msoffen# Replaced find_interface_generic BSD code with more robust code.## Revision 1.30  2002/10/21 10:17:18  horms# hb api clients may now be built outside of the heartbeat tree## Revision 1.29  2002/09/04 15:23:36  msoffen# Changed for Solaris.  Removed "Add Route" and moved to subroutine (Left commented out call to subroutine though).# Corrected comment (added monitor as allowd parameter).## Revision 1.28  2002/08/17 14:35:58  alan# Changed BasicSanityCheck to assign the dummy IP address to the dead machine.## Fixed IPaddr.in so that it works again on Linux.## Revision 1.27  2002/08/16 14:18:42  msoffen# Changes to get IP takeover working properly on OpenBSD# Changed how *BSD deletes an alias.# Create get_hw_addr (uses libnet package).## Revision 1.26  2002/08/15 16:15:35  msoffen# Corrected so that BSD will properly get the status/etc. since it has# a single device for both IP's (not device:n).## Revision 1.25  2002/08/02 22:50:43  alan# Put in a minor Solaris bug fix for IPaddr.# If we get a MAC address that is missing a leading zero, then we add# it back in.## Revision 1.24  2002/08/02 03:29:16  horms# Reworked Lorn Kay's loopback interface patch for Linux.## Notes:## This script assumes that an IP address can only belong# to one interface. This is _wrong_. However, it works for# almost all cases so I'm happy to leave it as is for now.## In the mean time, this work arround allows us to have# manages addresses on the loopback interface on Linux,# which is very useful when heartbeat is used in conjunction# with the Linux Virtual Server, and a node is both# a Real Server and a Linux Director.## Revision 1.23  2002/07/30 17:33:34  horms# The old checking for an empty string without putting the suspect# variable in quotes trick. Gets 'em every time.## Revision 1.22  2002/07/27 06:02:21  horms# Lorn Kay's patch for IPaddr to better handle the presance of# managed IP addresses being present on a loopback interface.# Designed for use in conjunction with LVS Direct Routing.# Should be fully backwards compatible.## Revision 1.21  2002/07/09 16:42:22  msoffen# Deleted extra "debugging" lines .## Revision 1.20  2002/05/28 18:25:48  msoffen# Changes to replace send_arp with a libnet based version.  This works accross# all operating systems we currently "support" (Linux, FreeBSD, Solaris).## Revision 1.19  2002/05/15 04:25:47  msoffen# Corrected Ping problem so that it would work in FreeBSD (using parameters from configure.in).## Revision 1.18  2002/04/29 07:32:44  alan# Solaris extensions/enhancements from Thomas Hepper for Solaris 2.8## Revision 1.17  2002/03/21 02:03:00  alan# Added locking to the assignment of interfaces in IPaddr.## Revision 1.16  2002/03/14 04:28:51  alan# Changed all the resource scripts to have ID strings in them## Revision 1.15  2002/02/15 06:53:16  horms# Small changes to allow heartbeat to work on Solaris 8# * use unset LC_ALL and unset LANGUAGE instead of LC_ALL=en and LANGUAGE=en# * provide LOG_PERROR, as Solaris doesn't# -- Horms## Revision 1.14  2002/01/18 18:55:49  alan# Put in a generalization suggested by Matt Soffen to allow us# to handle BSD and Solaris network interfaces.## Revision 1.13  2001/10/24 20:23:09  alan# Changed INFO: to info: for consistency.## Revision 1.12  2001/10/12 04:54:22  alan# Changed IPaddr to be more BSD/Solaris compatible## Revision 1.11  2001/10/08 14:04:18  alan# Put a fix into IPaddr.in to make it work on Solaris as well as Linux.## Revision 1.10  2001/10/07 04:18:20  alan# Added some more portability patches from David Lee.## Revision 1.9  2001/10/07 04:00:56  alan# Got rid of a non-portable shell construct in IPaddr.in## Revision 1.8  2001/10/03 15:00:26  alan# Patch from Matt Soffen to add a comment about the IFEXTRA logic in the# IPaddr resource script.# Matt also replaced an errant echo with an ha_log() call.## Revision 1.7  2001/10/03 13:54:16  alan# Merged in Matt Soffen's changes and added some of my own for IPaddr...## CVg: Committing in .## Revision 1.6  2001/10/02 20:04:09  alan# I added wehat should be a redundnat fix for Fabrice of France.# He says it isn't redundant.  It's clearly harmless.## Revision 1.5  2001/07/19 15:59:55  alan# Put in Matt Soffen's pathname patch...## Revision 1.4  2001/07/02 17:23:23  alan# Changed the order of the ifdown and route del commands...## Revision 1.3  2001/06/29 21:23:47  alan# Put in a modified version of Matt Soffen's patch to make# IPaddr work under FreeBSD.# Don't know if it works under FreeBSD, but it works on Linux.## Revision 1.2  2001/06/28 20:35:00  alan# Patch from Juri to install our scripts with paths patched appropriately.## Revision 1.1  2001/06/28 12:16:44  alan# Committed the *rest* of Juri Haberland's script patch that I thought I# had already applied :-(.## Revision 1.9  2001/05/17 18:45:55  alan# Applied two patches for IPaddr from Emily Ratliff <emilyr@us.ibm.com>## Revision 1.8  2001/02/05 21:43:38  alan# Added "monitor" action to IPaddr.## Revision 1.7  2000/11/07 14:15:04  alan# Made the takeover of IP addresses go faster.# Removed the limit on 8 aliases per interface.## Revision 1.6  2000/06/12 06:11:09  alan# Changed resource takeover order to left-to-right# Added new version of nice_failback.  Hopefully it works wonderfully!# Regularized some error messages# Print the version of heartbeat when starting# Hosts now have three statuses {down, up, active}# SuSE compatability due to Friedrich Lobenstock and alanr# Other minor tweaks, too numerous to mention.## Revision 1.5  1999/12/30 03:18:50  alan# Put Stefan Salzer's fix on the place he put it in :-)  The same bug appeared# twice in the code.  I fixed it in one place, and so did he.  Now# it looks like they're both fixed.## Revision 1.4  1999/12/23 03:28:21  alan# Put in Stefan Salzer's fix to IPaddr to make it not confuse# x.y.z.1 with x.y.z.11 or similar...## Revision 1.3  1999/11/16 04:36:53  alan# Added fix from David Jules to make IPaddr work in France.# The problem is that various commands that IPaddr invokes (notably ifconfig)# produce different output in other locales than they do in LC_ALL=en# so the output wasn't recognized by IPaddr.  The fix is much simpler than# this explanation :-)## Revision 1.2  1999/11/10 20:33:04  alan# Deleted /proc/ha directory from build list# Added #!/bin/sh to lots (all?) of the scripts...## Revision 1.1.1.1  1999/09/23 15:31:24  alanr# High-Availability Linux## Revision 1.11  1999/09/12 06:56:53  alanr# Fixed the bugs that kept addresses w/netmasks and broadcast addresses from working.## Revision 1.10  1999/09/08 03:47:18  alanr# fixed things up so that send_arp doesn't just assume eth0 as the ethernet interface...## Revision 1.9  1999/08/22 04:49:42  alanr# Fixed a stupid syntax error.  Wonder how it got in here?## Revision 1.8  1999/08/21 05:43:38  alanr# added "info" argument to support GUI help screens, etc.## Revision 1.7  1999/08/17 18:09:16  alanr# More message changes.## Revision 1.6  1999/08/17 18:04:31  alanr# Minor message changes for Thomas' code.## Revision 1.5  1999/08/17 17:57:07  alanr# Put in Thomas Hepper's fix to make it obey netmasks and broadcast addrs# from base interface.## Revision 1.4  1999/08/17 05:00:44  alanr# added a dumb extra ### Revision 1.3  1999/08/17 04:57:57  alanr# Added RCS keywords, and bug fix from Thomas Hepper# th@ant.han.de to fix some kind of problem associated with PPP configs.###

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -