Rearrange xmpp hostname change scripts so we can only restart ejabberd once.

This commit is contained in:
James Valleroy 2014-04-01 21:17:38 -05:00
parent 2c41e63889
commit dadfb2220a
2 changed files with 17 additions and 22 deletions

View File

@ -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

View File

@ -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