# Above is autogenerated; DEBUG here is run-time DEBUG=0 export XSL_FILE SAXON_JAR DEBUG die() { echo "$*" exit 1 } _validate() { if [ $DEBUG -eq 1 ]; then echo "debug: adding . to $PATH" export PATH="$PATH:." fi which ccs_flatten &> /dev/null || die "Can't find ccs_flatten in path!" which java &> /dev/null || die "Can not find java in path!" if [ -z "$XSL_FILE" ]; then if [ $DEBUG -eq 1 ]; then XSL_FILE=./cluconf2cib.xsl echo "debug: using $XSL_FILE" else die "Please specify path to XSLT script using -X ." fi fi if [ -z "$SAXON_JAR" ]; then if [ $DEBUG -eq 1 ]; then SAXON_JAR=/usr/share/java/saxon.jar echo "debug: using $SAXON_JAR" else die "Please specify path to saxon.jar using -J ." fi fi [ -d /usr/share/cluster ] || die "/usr/share/cluster does not exist." [ -f /usr/share/cluster/service.sh ] || die "Missing rgmanager resource agents?" [ -f "$XSL_FILE" ] || die "$XSL_FILE does not exist!" [ -f "$SAXON_JAR" ] || die "$SAXON_JAR does not exist!" [ -f "$1" ] || die "Input file $1 not found" if [ -f "$2" ]; then [ $3 -ne 0 ] || die "Output file $2 exists; please remove or use -f" fi return 0 } help() { cat < Specify path to XSLT script -J Specify path to Saxon jar file -h This message EOT } # main declare conf_in cib_out xsl_file saxon_jar conf_out opt do_update tmp declare force_update no_verify # defaults conf_in="/etc/cluster/cluster.conf" cib_out="cib-converted.xml" conf_out="" do_update=0 no_verify=0 force_update=0 tmp=$(mktemp /tmp/ccs2cib.tmp.XXXXXX) while getopts i:o:X:J:Rr:dnhf opt; do case $opt in d) DEBUG=1 ;; i) conf_in="$OPTARG" ;; o) cib_out="$OPTARG" ;; R) do_update=1 ;; r) do_update=1 conf_out="$OPTARG" ;; n) no_verify=1 ;; f) force_update=1 ;; X) XSL_FILE="$OPTARG" ;; J) SAXON_JAR="$OPTARG" ;; h) help $0 exit 0 ;; *) echo "Error parsing $opt" help $0 exit 1 ;; esac done [ -z "$conf_out" ] && conf_out="$conf_in" _validate "$conf_in" "$cib_out" $force_update echo " * Converting configuration" if ! ccs_flatten "$conf_in" > $tmp; then rm -f $tmp die "Flattening of configuration file failed." fi if ! java -jar $SAXON_JAR -xsl:$XSL_FILE $tmp > $cib_out; then rm -f $tmp die "Conversion failed." fi echo " * Calling crm_verify to validate the configuration." if [ $no_verify -eq 0 ]; then crm_verify --xml-file $cib_out -V || die "Validation failed." fi if [ $do_update -ne 0 ]; then echo " * Disabling rgmanager in $conf_out" rm -f $tmp disable_rgmanager "$conf_in" > "$tmp" || die "Failed to disable rgmanager" mv "$tmp" "$conf_out" if [ "$conf_out" = "/etc/cluster/cluster.conf" ]; then if clustat -Q &> /dev/null; then echo " * Calling cman_tool to update cluster.conf" cman_tool version -r else echo " * You will need to manually copy $conf_out to the other cluster" echo " nodes using scp, ccs_sync, or some other utility." fi fi fi echo " * Proposed cib stored in $cib_out" exit 0