summaryrefslogtreecommitdiff
path: root/hooks/replica-set-relation-joined
diff options
authorJuan L. Negron <juan.negron@canonical.com>2011-12-14 14:02:17 -0800
committerJuan L. Negron <juan.negron@canonical.com>2011-12-14 14:02:17 -0800
commit64eb056811c8a8ee798ea43a7ff1251f3a810976 (patch)
tree174bfb9fddc5396da825a0cb9cd1b5c1ced461c6 /hooks/replica-set-relation-joined
parentcf4544c7336a271854210f9da11c9d21339eee85 (diff)
Added config-changed hook to better handle replica_set_master variable
Diffstat (limited to 'hooks/replica-set-relation-joined')
-rwxr-xr-xhooks/replica-set-relation-joined16
1 files changed, 9 insertions, 7 deletions
diff --git a/hooks/replica-set-relation-joined b/hooks/replica-set-relation-joined
index 6285ac4..317673c 100755
--- a/hooks/replica-set-relation-joined
+++ b/hooks/replica-set-relation-joined
@@ -6,6 +6,7 @@
set -ux
DEFAULT_REPLSET_NAME=`config-get replicaset`
+INSTALL_ORDER=$(echo ${JUJU_UNIT_NAME} | awk -F/ '{ print $2 }')
############################################################################################################
# Reconfigure the upstart script to include the replica-set option.
@@ -13,13 +14,14 @@ DEFAULT_REPLSET_NAME=`config-get replicaset`
# Replica sets can only talk to each other if they all belong to the same
# set. In our case, we have defaulted to "myset".
############################################################################################################
+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
-grep "${DEFAULT_REPLSET_NAME}" /etc/init/mongodb.conf || 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
-
-relation-set hostname=`hostname -f` replset=${DEFAULT_REPLSET_NAME} install-time=`facter install-time`
+relation-set hostname=`hostname -f` replset=${DEFAULT_REPLSET_NAME} install-order=${INSTALL_ORDER}
echo $JUJU_REMOTE_UNIT joined