...
Code Block |
---|
#!/bin/bash # # # # Simple script for cluster services to use for bare metal ethernet interface # # chkconfig: 345 89 14 # description: Starts and stops the clustered service network interface # processname: net # # Source function library. . /etc/init.d/functions SIPX_IP='172.16.1.5' SIPX_INTERFACE=eth0 CLUS_INTERFACE=eth2 ISCSI_INTERFACE=eth1 PROG_NAME=clusnet RETVAL=0 DEFAULT_GW=`cat /etc/sysconfig/network-scripts/ifcfg-$SIPX_INTERFACE | grep GATEWAY | sed 's/GATEWAY=//g'` SUBNET_MASK=`cat /etc/sysconfig/network-scripts/ifcfg-$SIPX_INTERFACE | grep NETMASK | sed 's/NETMASK=//g'` INTUP=`/sbin/ifconfig | grep -c $SIPX_INTERFACE`; # <define any local shell functions used by the code that follows> start() { echo -n "Starting $SIPX_INTERFACE: " ip address flush dev eth0 sleep 3 ipifconfig address$SIPX_INTERFACE add $SIPX_IP/ netmask $SUBNET_MASK brd + dev eth0up ip route add default via $DEFAULT_GW dev $SIPX_INTERFACE echo echo -n $"$SIPX_INTERFACE is up."; success $"$SIPX_INTERFACE is up."; echo chkconfig postgresql off return $RETVAL } stop() { echo -n "Shutting down $SIPX_INTERFACE: " ifdown $SIPX_INTERFACE ifup $SIPX_INTERFACE ifup $ISCSI_INTERFACE ifup $CLUS_INTERFACE echo echo -n $"Interface $SIPX_INTERFACE is down."; success $"Interface $SIPX_INTERFACE is down."; echo chkconfig postgresql off return $RETVAL } getstatus() { if [ $INTUP -lt 1 ] then echo echo -n $"Interface $SIPX_INTERFACE is down." failure $"Interface $SIPX_INTERFACE is down." echo return 1; fi echo echo -n $"Interface $SIPX_INTERFACE is up."; success $"Interface $SIPX_INTERFACE is up."; echo return $RETVAL } case "$1" in start) start ;; stop) stop ;; status) getstatus ;; restart) stop sleep 5 start ;; *) echo "Usage: $PROG_NAME {start|stop|status|restart}" exit 1 ;; esac exit $RETVAL |
...