Last active
January 3, 2016 04:59
-
-
Save dotmanila/8412567 to your computer and use it in GitHub Desktop.
Support script for https://gist.github.com/dotmanila/8412562
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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