Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # 13.09.2019 Jonny Rimkus
- # Watchdog for ejabberd Cluster
- # 17.09.2019
- # add main ejabbderd node as variable
- # check if current node is missing from the cluster
- # and add it automatically or if -noauto arg was given return -1
- # path to ejabberdctl
- jabberctl="/usr/local/bin/ejabberdctl"
- # main ejabberd instance (node name for join_cluster)
- nodemain="[email protected]"
- # how many instances are in the cluster
- IN_CLUSTER=$($jabberctl list_cluster | grep "$nodemain" | wc -l)
- if [ "$IN_CLUSTER" -lt 1 ]; then
- if [ "$1" = "-noauto" ]; then
- echo "$(date '+%d.%m.%Y %H:%M:%S')# instance is not in cluster '$nodemain'"
- exit -1
- fi
- # not all instances are running, do a join_cluster
- echo -n "$(date '+%d.%m.%Y %H:%M:%S')# adding instance to cluster '$nodemain'..."
- $jabberctl --no-timeout join_cluster "$nodemain"
- if [ $? -ne 0 ]; then
- echo -n "$(date '+%d.%m.%Y %H:%M:%S')# error!"
- exit $?
- fi
- echo "$(date '+%d.%m.%Y %H:%M:%S') done"
- else
- # nothing to do, all instances
- echo "$(date '+%d.%m.%Y %H:%M:%S')# all instances are running"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement