summaryrefslogtreecommitdiff
path: root/hooks/replica-set-relation-joined
blob: 317673c286498c19eaf1ab8834f5db1603b068f7 (plain)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 
#!/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` INSTALL_ORDER=$(echo ${JUJU_UNIT_NAME} | awk -F/ '{ print $2 }') ############################################################################################################ # Reconfigure the upstart script to include the replica-set option. # We'll need this so, when we add nodes, they can all talk to each other. # 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 relation-set hostname=`hostname -f` replset=${DEFAULT_REPLSET_NAME} install-order=${INSTALL_ORDER} echo $JUJU_REMOTE_UNIT joined