From dadfb2220a58635933588bafaec5ebe5d1d0bb1b Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Tue, 1 Apr 2014 21:17:38 -0500 Subject: [PATCH] Rearrange xmpp hostname change scripts so we can only restart ejabberd once. --- actions/xmpp-hostname-change | 35 +++++++++++++------------------- actions/xmpp-pre-hostname-change | 4 +++- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/actions/xmpp-hostname-change b/actions/xmpp-hostname-change index a417b7592..2c209b052 100755 --- a/actions/xmpp-hostname-change +++ b/actions/xmpp-hostname-change @@ -37,6 +37,18 @@ DEBIAN_FRONTEND=noninteractive dpkg-reconfigure jwchat # Debconf can't handle our manual changes to ejabberd's config yet. sed -i "s/$old_hostname/$hostname/g" /etc/ejabberd/ejabberd.cfg +# Install the backup file as a fallback +ejabberdctl --node $OLDNODE install_fallback $NEWFILE + +# Convert the backup to new node name +ejabberdctl --node $OLDNODE mnesia_change_nodename $OLDNODE $NEWNODE $OLDFILE $NEWFILE + +# Stop ejabberd +ejabberdctl --node $OLDNODE stop + +# Wait for old node to completely shutdown +sleep 10 + # Make sure there aren't files in the Mnesia spool dir mkdir -p /var/lib/ejabberd/oldfiles mv /var/lib/ejabberd/*.* /var/lib/ejabberd/oldfiles/ @@ -44,24 +56,5 @@ mv /var/lib/ejabberd/*.* /var/lib/ejabberd/oldfiles/ # Start ejabberd service ejabberd restart -# It can take a while to start up... -for i in {1..12} -do - if ejabberdctl status ; then - break - else - sleep 10 - fi -done - -# Convert the backup to new node name -ejabberdctl mnesia_change_nodename $OLDNODE $NEWNODE $OLDFILE $NEWFILE - -# Install the backup file as a fallback -ejabberdctl install_fallback $NEWFILE - -# Stop ejabberd -ejabberdctl stop - -# Start ejabberd -service ejabberd restart +# Remove old hostname from /etc/hosts +sed -i "/$old_hostname/d" /etc/hosts diff --git a/actions/xmpp-pre-hostname-change b/actions/xmpp-pre-hostname-change index 95c1e4d7a..f5a6a1645 100755 --- a/actions/xmpp-pre-hostname-change +++ b/actions/xmpp-pre-hostname-change @@ -21,4 +21,6 @@ OLDFILE=/tmp/old.backup ejabberdctl backup $OLDFILE -ejabberdctl stop + +# Add old hostname to /etc/hosts so we can still access the running node. +echo "127.0.0.1 `hostname`" >>/etc/hosts