Scripting Kopano Server Updates

Kopano Collaboration Platform is the email server of choice for our new customers. With that said, we have a lot of these installations being maintained in production. Below is our first generation automation script to update Kopano to the latest 8.4.x release for users who are not using apt-get. Note this script is a modified version (to account for package naming convention) of our original script located at Scripting Zarafa 7.2.x Updates. Note you must have a Kopano Portal account to download the updates. In order to run this script, you will need to copy the downloaded packages and script below to the /tmp folder and run the script as seen below in the code block under usage.

#!/bin/bash
#
# Upgrade kopano server using customer portal packages  
#
#
if [ -n "$1" ];then
	rm /etc/nginx/sites-enabled/push /etc/nginx/sites-enabled/mail
	service nginx reload
	# update base debian server 
	apt-get update ; apt-get dist-upgrade
	# backup existing kopano server 
	read -p "Press [Enter] key to start backup..."
	cp -r /etc/kopano /etc/kopano.bkp
	cd /etc/kopano.bkp
	mysqldump -h mysql_host -u mysql_username -p'mysql_password' kopano > kopano-dump.sql
	# start kopano upgrade process
	read -p "Press [Enter] key to start upgrade..."
	cd /tmp
	file="$1"
	tar xvzf $file
	folder=`basename "$file" .tar.gz`
	cd $folder
	# remove unused kopano-dev 
	rm *kopano-dev*
	dpkg -Bi l* ; dpkg -i p* ; dpkg -i g* ; dpkg -i k* ; apt-get install -f
	# run again to ensure dependencies are met
	dpkg -Bi l* ; dpkg -i p* ; dpkg -i g* ; dpkg -i k* ; apt-get install -f
	apt-get autoremove
	# remove unused kopano services
	read -p "Press [Enter] key to remove unused services..."
	systemctl disable kopano-ical.service
	systemctl disable kopano-gateway.service
	service php5-fpm restart
	kopano-admin -V
	# enable z-push & webapp after upgrade
	ln -s /etc/nginx/sites-available/push /etc/nginx/sites-enabled
	ln -s /etc/nginx/sites-available/mail /etc/nginx/sites-enabled
	service nginx reload
	echo "Please verify that kopano is functioning, then delete /etc/kopano.bkp"
else
    echo "Usage: /tmp/kopano-core-upgrade [upgrade].tar.gz"
fi
Did you find this article useful? Why not share it with your friends?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.