diff --git a/pgpool/bin/pgpool_escalation b/pgpool/bin/pgpool_escalation new file mode 100644 index 0000000000000000000000000000000000000000..6ebf9bc282f440996cd7f743cceb48e0b33eaf12 --- /dev/null +++ b/pgpool/bin/pgpool_escalation @@ -0,0 +1,49 @@ +#!/bin/sh + +touch /tmp/pgpool_escalation + +DONE="[ done ]" +FAIL="[ fail ]" + +DOTSTRING="" +cols=`tput cols` +cols=$((cols - 10)) +cols=$((cols / 2)) +for i in `seq 1 $cols`; do + DOTSTRING=$DOTSTRING"." +done +function align_left() { + local chars="$1" + local str="${@:2}" + echo -n ${str}${chars:${#str}} +} + +function align_echo() { + if [[ "$1" != 0 ]]; then + echo $FAIL + echo "$2" + else + echo $DONE + fi +} + +# Start/Stop standalone jboss instance +result=`jboss-cli --controller=$1 --connect --commands="/host=standby/server=server-standalone:read-attribute(name=server-state)"` 2>$1 +if [[ $? != 0 ]]; then + align_left "$DOTSTRING" "Start server-standalone" + result=`jboss-cli --controller=$1 --connect --commands="/host=standby/server-config=server-standalone:start()"` 2>$1 + align_echo $? $result +else + if [[ $result = *"running"* ]]; then + align_left "$DOTSTRING" "Stop server-standalone" + result=`jboss-cli --controller=$1 --connect --commands="/host=standby/server-config=server-standalone:stop()"` 2>$1 + align_echo $? $result + fi +fi + +# Start/Stop et7daemon +if [[ ! -f /var/run/et7daemon.pid ]]; then + /etc/init.d/et7daemon start +else + /etc/init.d/et7daemon stop +fi