diff options
| author | Juan L. Negron <juan.negron@canonical.com> | 2011-12-14 14:02:17 -0800 |
|---|---|---|
| committer | Juan L. Negron <juan.negron@canonical.com> | 2011-12-14 14:02:17 -0800 |
| commit | 64eb056811c8a8ee798ea43a7ff1251f3a810976 (patch) | |
| tree | 174bfb9fddc5396da825a0cb9cd1b5c1ced461c6 /hooks/config-changed | |
| parent | cf4544c7336a271854210f9da11c9d21339eee85 (diff) | |
Added config-changed hook to better handle replica_set_master variable
Diffstat (limited to 'hooks/config-changed')
| -rwxr-xr-x | hooks/config-changed | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/hooks/config-changed b/hooks/config-changed new file mode 100755 index 0000000..b678ceb --- /dev/null +++ b/hooks/config-changed @@ -0,0 +1,24 @@ +#!/bin/bash +# This must be renamed to the name of the relation. The goal here is to +# affect any change needed by relationships being formed +# This script should be idempotent. + +set -ux + +DEFAULT_REPLSET_NAME=`config-get replicaset` +REPLICASET_MASTER=`config-get replicaset_master` + +############################################################################################################ +# Are we connecting to an existing replica set? +############################################################################################################ +if [ "${REPLICASET_MASTER}" != "auto" ]; then + grep "${DEFAULT_REPLSET_NAME}" /etc/init/mongodb.conf + if [ $? -ne 0 ];then + sed -i -e "s/ -- / -- --replSet ${DEFAULT_REPLSET_NAME} /" /etc/init/mongodb.conf + service mongodb stop + rm -f /var/lib/mongodb/mongod.lock + service mongodb start + fi + mongo --host ${REPLICASET_MASTER} --eval "rs.add(\""${HOSTNAME}"\")" +fi + |
