#!/bin/bash source /sbin/lang.sh || exit 1 source /boot/drbd.conf &>/dev/null #We want to use drbd with heartbeat at all? if [ "$DRBD" == "1" ] && [ "$CLUSTER_ID" ]; then #we want to receive/send heartbeats: ifconfig $ETH up if HEARTBEATS="`syndog $CLUSTER_ID --cat`"; then #received critical network config info, update network config NODE_ID=`cat /sys/class/net/$ETH/address` OTHER_NODE_ID=`echo "$HEARTBEATS"|cut -f3 -d' '|head -1` OTHER_BOOTED=`echo "$HEARTBEATS"|cut -f4 -d' '|head -1` #the node_ids determine the order of ip's. if [ "$NODE_ID" ">" "$OTHER_NODE_ID" ]; then SELECTED_LOCAL_IP=$LOCAL_IP SELECTED_REMOTE_IP=$REMOTE_IP else SELECTED_LOCAL_IP=$REMOTE_IP SELECTED_REMOTE_IP=$LOCAL_IP fi ifconfig $ETH:drbd $SELECTED_LOCAL_IP ifconfig $ETH up syn3-drbdconnect BEAT=`echo "$HEARTBEATS"|cut -f1 -d' '|sort |uniq` if [ "$OTHER_BOOTED" == 1 ];then if [ "$NODE_ID" ">" "$OTHER_NODE_ID" ]; then #this node primary prefered syn3-state drbd-heartbeat ALERT "PANIC! Both nodes are booted, please reboot OTHER node!" else #this node secondary prefered if [ "$STONITH" == "1" ] ;then #check if we receive the 'other node online' signal via a safe crosslink interface SAFE_STONITH_CHECK=`echo "$HEARTBEATS"|grep ^$ETH|cut -f4 -d' '|head -1` if [ "$SAFE_STONITH_CHECK" == "1" ]; then syn3-state drbd-heartbeat ALERT "PANIC! Both nodes are booted, THIS NODE WILL REBOOT NOW!" sleep 3 #time to read message reboot -f else syn3-state drbd-heartbeat ALERT "PANIC! Both nodes are booted, please reboot THIS node! (cannot auto reboot, packets received via unsafe interface)" fi else syn3-state drbd-heartbeat ALERT "PANIC! Both nodes are booted, please reboot THIS node!" fi fi else syn3-state drbd-heartbeat OK "`_DrbdHeartBeatOk \"$BEAT\"`" fi else syn3-state drbd-heartbeat ALERT "`_DrbdHeartBeatMissing`" fi else syn3-state drbd-heartbeat DELETE fi