diff --git a/tools/hb2openais.sh.in b/tools/hb2openais.sh.in index e9da0531d6..8231b38f57 100755 --- a/tools/hb2openais.sh.in +++ b/tools/hb2openais.sh.in @@ -1,590 +1,592 @@ #!/bin/sh # Copyright (C) 2008 Dejan Muhamedagic # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # . @sysconfdir@/ha.d/shellfuncs . $HA_NOARCHBIN/utillib.sh PROG=`basename $0` # FIXME: once this is part of the package! PROGDIR=`dirname $0` echo "$PROGDIR" | grep -qs '^/' || { test -f @sbindir@/$PROG && PROGDIR=@sbindir@ test -f $HA_NOARCHBIN/$PROG && PROGDIR=$HA_NOARCHBIN } # the default syslog facility is not (yet) exported by heartbeat # to shell scripts # DEFAULT_HA_LOGFACILITY="daemon" export DEFAULT_HA_LOGFACILITY AIS_CONF=/etc/ais/openais.conf AIS_KEYF=/etc/ais/authkey PY_HELPER=$HA_BIN/hb2openais-helper.py CIB=@HA_VARLIBDIR@/heartbeat/crm/cib.xml CIBSIG=@HA_VARLIBDIR@/heartbeat/crm/cib.xml.sig +CIBLAST=@HA_VARLIBDIR@/heartbeat/crm/cib.xml.last +CIBLAST_SIG=@HA_VARLIBDIR@/heartbeat/crm/cib.xml.sig.last HOSTCACHE=@HA_VARLIBDIR@/heartbeat/hostcache HB_UUID=@HA_VARLIBDIR@/heartbeat/hb_uuid DONE_F=$HA_VARRUN/heartbeat/.$PROG.conv_done BACKUPDIR=/var/tmp/`basename $PROG .sh`.backup BACKUP_FILES=" $CIB $CIBSIG $HOSTCACHE $HB_UUID $AIS_CONF " -RM_FILES=" $CIBSIG $HOSTCACHE $HB_UUID " -REMOTE_RM_FILES=" $CIB $CIBSIG $HOSTCACHE $HB_UUID " +RM_FILES=" $CIBSIG $HOSTCACHE $HB_UUID $CIBLAST $CIBLAST_SIG" +REMOTE_RM_FILES=" $CIB $CIBSIG $HOSTCACHE $HB_UUID $CIBLAST $CIBLAST_SIG" DIST_FILES=" $AIS_CONF $AIS_KEYF $DONE_F " MAN_TARF=/var/tmp/`basename $PROG .sh`.tar.gz : ${SSH_OPTS="-T"} usage() { cat</dev/null else ssh -T -o Batchmode=yes $1 true 2>/dev/null fi } findsshuser() { for u in "" $TRY_SSH; do rc=0 for n in `getnodes`; do [ "$node" = "$WE" ] && continue testsshuser $n $u || { rc=1 break } done if [ $rc -eq 0 ]; then echo $u return 0 fi done return 1 } newportinfo() { info "the port number for the multicast is set to 5405" info "please update your firewall rules (if any)" } changemediainfo() { info "openais uses multicast for communication" info "please make sure that your network infrastructure supports it" } multicastinfo() { info "multicast for openais ring $1 set to $2:$3" } netaddrinfo() { info "network address for openais ring $1 set to $2" } backup_files() { [ "$TEST_DIR" ] && return info "backing up $BACKUP_FILES to $BACKUPDIR" $DRY mkdir $BACKUPDIR || { echo sorry, could not create $BACKUPDIR directory echo please cleanup exit 1 } for f in $BACKUP_FILES; do $DRY cp -p $f $BACKUPDIR || { echo sorry, could not copy $f to $BACKUPDIR exit 1 } done } revert() { [ "$TEST_DIR" ] && return test -d $BACKUPDIR || { echo sorry, there is no $BACKUPDIR directory echo cannot revert exit 1 } for f in $BACKUP_FILES; do cp -p $BACKUPDIR/`basename $f` $f || { echo sorry, could not copy $BACKUPDIR/`basename $f` to $f } done } pls_press_enter() { [ "$TEST_DIR" ] && return cat< $AIS_CONF || fatal "cannot create $AIS_CONF" grep -wqs interface $AIS_CONF || fatal "no media found in $HA_CF" else openaisconf fi if [ "$TEST_DIR" ]; then info "Skipping OpenAIS authentication key generation ..." else info "Generating a key for OpenAIS authentication ..." $DRY ais-keygen || fatal "cannot generate the key using ais-keygen" fi # remove various files which could get in a way if [ -z "$TEST_DIR" ]; then $DRY rm -f $RM_FILES fi # remove the nodes section from the CIB tmpfile=`maketempfile` $MYSUDO sh -c "python $PY_HELPER zap_nodes <$CIB >$tmpfile" || fatal "cannot clear the nodes section from the CIB" if [ "$TEST_DIR" ]; then mv $tmpfile $TEST_DIR/cib-out.xml else $DRY $MYSUDO mv $tmpfile $CIB fi info "Cleared the nodes section in the CIB" info "Done converting ha.cf to openais.conf" # # first part done (openais), on to the CIB analyze_cib() { info "Analyzing the CIB..." $MYSUDO sh -c "python $PY_HELPER analyze_cib <$CIB" } part2() { intro_part2 || return 0 tmpfile=`maketempfile` opts="-c $HA_CF" [ "$TEST_DIR" ] && opts="-T $opts" $MYSUDO sh -c "python $PY_HELPER $opts convert_cib <$CIB >$tmpfile" || fatal "failed to process the CIB" if [ "$TEST_DIR" ]; then mv $tmpfile $TEST_DIR/cib-out.xml else $DRY $MYSUDO mv $tmpfile $CIB fi info "Processed the CIB successfully" } dcidle() { try_crmadmin=10 dc="" while [ -z "$dc" -a $try_crmadmin -gt 0 ]; do dc=`$MYSUDO crmadmin -D | awk '{print $NF}'` try_crmadmin=$((try_crmadmin-1)) done if [ x = x"$dc" ]; then echo "sorry, no dc found/elected" exit 1 fi maxcnt=60 cnt=0 while [ $cnt -lt $maxcnt ]; do stat=`$MYSUDO crmadmin -S $dc` ec=$? echo $stat | grep -qs S_IDLE && break [ "$1" = "-v" ] && echo $stat sleep 1 printf "." cnt=$((cnt+1)) done echo status: $stat echo waited: $cnt echo $stat | grep -qs S_IDLE } start_cluster() { $DRY /etc/init.d/openais start } wait_cluster() { printf "waiting for crm to start." for i in 1 2 3 4 5; do for j in 1 2; do sleep 1; printf "." done done dcidle } tune_ocfs2() { [ "$TEST_DIR" ] && return cat<