Blame Artworks/Webenv/Mailman/svn-install.sh

Alain Reguera Delgado 46de3c
#!/bin/bash
Alain Reguera Delgado 46de3c
# Install Mailman customization using a remote svn installation source 
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
DOINSTALL=N
Alain Reguera Delgado 46de3c
SVNDIR=http://centos.org/svn/artwork/trunk/Extras/Mailman/
Alain Reguera Delgado 46de3c
EXPORTDIR=Exported_files
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
echo 'Looking for available customizations ...'
Alain Reguera Delgado 46de3c
select MM_VALIDVERSION in `svn list $SVNDIR | sed 's!/$!!' | grep -v install.sh`;do
Alain Reguera Delgado 46de3c
	break;
Alain Reguera Delgado 46de3c
done
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
# Check mailman package from available repository
Alain Reguera Delgado 46de3c
function check_mailman_yuminstall {
Alain Reguera Delgado 46de3c
	# This customization was built for
Alain Reguera Delgado 46de3c
	# mailman-2.1.9-4.el5 and only tested on it. It may not work in other
Alain Reguera Delgado 46de3c
	# version. If other version is found show a warning message about this
Alain Reguera Delgado 46de3c
	# issue and let the user decide what to do.
Alain Reguera Delgado 46de3c
	MM_VERSION=`yum info mailman | egrep '^Version: ' | cut -f2 -d' '`
Alain Reguera Delgado 46de3c
	MM_RELEASE=`yum info mailman | egrep '^Release: ' | cut -f2 -d' '`
Alain Reguera Delgado 46de3c
	MM_REPOSIT=`yum info mailman | egrep '^Repo   : ' | sed	-r 's/^Repo   : //'`
Alain Reguera Delgado 46de3c
	MM_VERSREL="$MM_VERSION-$MM_RELEASE"
Alain Reguera Delgado 46de3c
	if [ $MM_VERSREL == $MM_VALIDVERSION ];then
Alain Reguera Delgado 46de3c
		return 0
Alain Reguera Delgado 46de3c
	else
Alain Reguera Delgado 46de3c
		echo "   Package found : mailman-$MM_VERSREL"
Alain Reguera Delgado 46de3c
		echo "   Repository    : $MM_REPOSIT"
Alain Reguera Delgado 46de3c
  		echo "   ****************************************************"
Alain Reguera Delgado 46de3c
		echo "   WARNING!: You are trying to apply"
Alain Reguera Delgado 46de3c
		echo "             mailman-$MM_VALIDVERSION customization to"
Alain Reguera Delgado 46de3c
		echo "             mailman-$MM_VERSREL and that may not work!"
Alain Reguera Delgado 46de3c
  		echo "   ****************************************************"
Alain Reguera Delgado 46de3c
		printf "   Do you want to apply it anyway ? [y/N]: "
Alain Reguera Delgado 46de3c
		read DOINSTALL
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
		if [ "$DOINSTALL" == 'y' ];then
Alain Reguera Delgado 46de3c
			return 0
Alain Reguera Delgado 46de3c
		else
Alain Reguera Delgado 46de3c
			exit 1;
Alain Reguera Delgado 46de3c
		fi
Alain Reguera Delgado 46de3c
	fi
Alain Reguera Delgado 46de3c
}
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
# Apply customization
Alain Reguera Delgado 46de3c
function install_mailman_customization {
Alain Reguera Delgado 46de3c
	echo 'Downloading customization ...'
Alain Reguera Delgado 46de3c
  	svn export ${SVNDIR}${MM_VALIDVERSION} $EXPORTDIR --quiet --force
Alain Reguera Delgado 46de3c
	echo 'Applying customization ...'
Alain Reguera Delgado 46de3c
	/bin/cp -r $EXPORTDIR/Mailman/* /usr/lib/mailman/Mailman/
Alain Reguera Delgado 46de3c
	/bin/cp -r $EXPORTDIR/messages/* /usr/lib/mailman/messages/
Alain Reguera Delgado 46de3c
	/bin/cp -r $EXPORTDIR/templates/* /usr/lib/mailman/templates/
Alain Reguera Delgado 46de3c
	/bin/cp $EXPORTDIR/mailman.conf /etc/httpd/conf.d/
Alain Reguera Delgado 46de3c
	rm -r $EXPORTDIR
Alain Reguera Delgado 46de3c
}
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
# Verify mailman local installation 
Alain Reguera Delgado 46de3c
function check_mailman_localinstall {
Alain Reguera Delgado 46de3c
	echo "Looking for local installation ..."
Alain Reguera Delgado 46de3c
	# Is mailman already installed ?
Alain Reguera Delgado 46de3c
	rpm -q mailman-$MM_VALIDVERSION > /dev/null
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
	if [ $? == 0 ]; then
Alain Reguera Delgado 46de3c
		# Package is already installed ... jump to customization
Alain Reguera Delgado 46de3c
		install_mailman_customization
Alain Reguera Delgado 46de3c
		# and exit;
Alain Reguera Delgado 46de3c
		exit 0;
Alain Reguera Delgado 46de3c
	else
Alain Reguera Delgado 46de3c
		echo   "   mailman-$MM_VALIDVERSION is not installed."
Alain Reguera Delgado 46de3c
		printf '   Do you want to install it now ? [y/N]: '
Alain Reguera Delgado 46de3c
		read DOINSTALL
Alain Reguera Delgado 46de3c
	
Alain Reguera Delgado 46de3c
		if [ "$DOINSTALL" == 'y' ];then
Alain Reguera Delgado 46de3c
			return 0
Alain Reguera Delgado 46de3c
		else
Alain Reguera Delgado 46de3c
			exit 1
Alain Reguera Delgado 46de3c
		fi
Alain Reguera Delgado 46de3c
	fi
Alain Reguera Delgado 46de3c
}
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
# Install mailman package from available repository
Alain Reguera Delgado 46de3c
function install_mailman {
Alain Reguera Delgado 46de3c
	check_mailman_yuminstall
Alain Reguera Delgado 46de3c
	yum -y install mailman
Alain Reguera Delgado 46de3c
	install_mailman_customization
Alain Reguera Delgado 46de3c
}
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
check_mailman_localinstall
Alain Reguera Delgado 46de3c
install_mailman
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
# After this you need to configure your mailman:
Alain Reguera Delgado 46de3c
# (Take a look to: /usr/share/doc/mailman-2.1.9/INSTALL.REDHAT)
Alain Reguera Delgado 46de3c
#
Alain Reguera Delgado 46de3c
# 1. Create your site password:
Alain Reguera Delgado 46de3c
#
Alain Reguera Delgado 46de3c
#	/usr/lib/mailman/bin/mmsitepass
Alain Reguera Delgado 46de3c
#
Alain Reguera Delgado 46de3c
# 2. Define the first mailing list. 
Alain Reguera Delgado 46de3c
#
Alain Reguera Delgado 46de3c
#	/usr/lib/mailman/bin/newsite mailman@domain.tld
Alain Reguera Delgado 46de3c
#
Alain Reguera Delgado 46de3c
# 3. Restart the Apache web server
Alain Reguera Delgado 46de3c
#
Alain Reguera Delgado 46de3c
#	/sbin/service httpd restart
Alain Reguera Delgado 46de3c
#
Alain Reguera Delgado 46de3c
# 4. Start mailman daemon
Alain Reguera Delgado 46de3c
#
Alain Reguera Delgado 46de3c
# 	/sbin/service mailman start
Alain Reguera Delgado 46de3c
#
Alain Reguera Delgado 46de3c
#
Alain Reguera Delgado 46de3c
# ... and thats all folks! :)