Skip to content

Instantly share code, notes, and snippets.

@dotmanila
Last active January 3, 2016 04:59
Show Gist options
  • Save dotmanila/8412567 to your computer and use it in GitHub Desktop.
Save dotmanila/8412567 to your computer and use it in GitHub Desktop.
#!/bin/bash
WRITER_VIP=192.168.56.83
READER_VIP=192.168.56.84
PXC_CHECK='/usr/bin/clustercheck clustercheck password 0'
SCRIPT=$1
WEIGHT=101
case $SCRIPT in
'bad_pxc')
$PXC_CHECK || exit 1
;;
'prefer_pxc01')
[ "$(hostname|cut -d'.' -f1)" == 'pxc01' ] || exit 1
;;
'prefer_pxc02')
[ "$(hostname|cut -d'.' -f1)" == 'pxc02' ] || exit 1
;;
'nopreempt_writer')
[[ "$(hostname|cut -d'.' -f1)" != 'pxc01' && $(ip ad sh|grep $WRITER_VIP) && $(ip ad sh|grep $READER_VIP|grep -c inet) -eq 0 ]] || exit 1
;;
'nopreempt_reader')
[[ "$(hostname|cut -d'.' -f1)" != 'pxc02' && $(ip ad sh|grep $READER_VIP) && $(ip ad sh|grep $WRITER_VIP|grep -c inet) -eq 0 ]] || exit 1
;;
'repel_writer')
[ $(ip ad sh|grep $WRITER_VIP|grep -c inet) -eq 0 ] || exit 1
;;
'repel_reader')
[ $(ip ad sh|grep $READER_VIP|grep -c inet) -eq 0 ] || exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment