Install script for SLES 11 (SUSE LINUX ENTERPRISE SERVER)

Use this forum for questions regarding installation, upgrading and configuration of OpenEMM

Moderator: moderator

roger
Posts: 8
Joined: Tue Mar 02, 2010 11:34 am

Install script for SLES 11 (SUSE LINUX ENTERPRISE SERVER)

Post by roger »

Below is my first cut of a install script that supports the installation of OpenEMM on a SLES 11 system, and if it has problems it's help text is hopefully a little more detailed. It should also be much nearer the correct script to handle most SUSE based systems.

The main changes are

a) The detailing of YaST to handle package management where needed.
b) More detail on how to clear out sendmail
c) More detail on clearing down defined user/group

Process

a) Copy and paste the script below to a file called

OpenEMM-Installer-SLES11-1.0.sh

b) chmod it so that you can run it as a script.
c) You may need to use dos2unix on the file to get the right LF/CR setting.

-------------------------------------------------------------------
#!/bin/bash

# Options


#
#
# THIS LIST OF RPMS MAY NEED TO CHANGED
# CHECK YaST TO SEE WHAT PACKAGE NAMES
# ARE USED.
#
#

RPM_REQUIRED="mysql-5.1.42-11.1 sendmail python-mysql wget"



SENDMAIL_CHECK="sendmail.mc mailertable"


function check_rpm
{
if ! [ `rpm -qa | grep $*` ]; then
INSTALLRPM="$INSTALLRPM $*"
fi
}

function check_sendmail
{
if [ `rpm -V sendmail | grep $* | cut -f3 -d' '` ]; then
SENDMAILMODDED="true"
fi
}

MY_HOSTNAME=`hostname`

echo "-------------------------------------------------"
echo "OpenEMM Installer for SUSE based Linux with a target of SLES 11"
echo "Version 1.0, based on Installer V1.2 from AGNITAS AG."
echo "-------------------------------------------------"
echo
echo "HINT: THIS INSTALLER IS CODED TO SUPPORT SLES 11"
echo
echo "Requirements:"
echo "1.) Download the latest copy of the OpenEMM Tarball 'OpenEMM-6.x-bin.tar.gz' from"
echo " 'http://sourceforge.net/projects/openemm ... 20software'"
echo " (Section: 'OpenEMM 6.x') rename it to 'OpenEMM-BIN-latest.tgz'"
echo " and move it in your current directory."
echo
echo "2.) Make sure the hostname of your system is valid."
echo " Your hostname seem to be:" $MY_HOSTNAME
echo " You can change it in the file '/etc/sysconfig/network'. Don't forget to"
echo " edit '/etc/hosts' as well and reboot to make the change valid."
echo
echo "3.) Make sure the host is connected to the internet and has a valid"
echo " Domain Name Service (DNS) entry. Consult your ISP for further"
echo " datails."
echo
echo "If you meet these requirements, type 'yes' to proceed with the"
echo "OpenEMM Installation."
echo
echo -n "Ready to install? (yes/no): "
read RDY

if ! [ "$RDY" == "yes" ]; then
exit 1
fi

echo
echo "+------------------------------OpenEMM Installation--------------------+"
echo "| System Integration Checkup |"
echo "+----------------------------------------------------------------------+"
echo

# Check for user 'root'

if ! [ `whoami` == "root" ]; then
echo "OpenEMM Installer: Please run the installer as Superuser 'root' (exiting)."
exit 1
fi

# Check for SuSE based Linux distribution

if [ -z /etc/SuSE-brand ]; then
echo ""
echo "OpenEMM Installer: Only SuSE Linux OS is supported (exiting)."
exit 1
fi

# Check for Sun JDK in '/opt/openemm.org/software/java'

if ! [ -d /opt/openemm.org/software/java ]; then
echo ""
echo "OpenEMM Installer: Sun JDK was not found on this system."
echo
echo "Please visit http://java.sun.com/javase/downloads/index.jsp and choose"
echo "'JDK 6 Update X'. Select platform 'Linux' and download the *.bin file."
echo "Run the file and follow the instructions on screen."
echo
echo "After the installation use the following commands (as root):"
echo
echo " mkdir -p /opt/openemm.org/software"
echo " mv jdk1.6.0_XX /opt/openemm.org/software"
echo " cd /opt/openemm.org/software"
echo " ln -s jdk1.6.0_XX java"
echo "(where XX = number of your JDK 6 Update, for example: 17)"
echo
echo "Restart the OpenEMM Installer after adding the Sun JDK (exiting)."
exit 1
else
echo "OpenEMM Installer: Sun JDK was found. You are using version:"
echo "---snip---"
/opt/openemm.org/software/java/bin/java -version
echo "---snap---"
fi

# Check for existence of '/home/openemm' and other tell tales

if [ -d "/home/openemm" ] || [ `grep openemm /etc/group` ] || [ `grep openemm /etc/passwd` ]; then
echo ""
echo "OpenEMM Installer: Found a previous OpenEMM installation. Please stop it,"
echo "and remove the defined user and group by using the following commands"
echo ""
echo "userdel -rf openemm"
echo "groupdel openemm"
echo "rm -r /home/openemm"
echo ""
echo "Depending on the state of the last install not all of the above may"
echo "Complete."
echo ""
echo "Restart the OpenEMM Installer."
exit 1
else
echo "OpenEMM Installer: '/home/openemm' is clean."
fi

# Check if the sendmail RPM is installed

if ! [ `rpm -qa | grep sendmail-8` ]; then
echo ""
echo "OpenEMM Installer: Sendmail was not found. Currently, only Sendmail is"
echo "supported as Mail Transfer Agent (MTA). Please consult your OS documentation"
echo "on how to install Sendmail."
exit 1
else
echo "OpenEMM Installer: Sendmail version 8 was found."
fi

# Check if the Sendmail installation is clean

for parameter in $SENDMAIL_CHECK; do
check_sendmail $parameter
done

if ! [ -z "$SENDMAILMODDED" ]; then
echo ""
echo "OpenEMM Installer: Some files of your Sendmail package were modified."
echo "Please reinstall the Sendmail package by:"
echo ""
echo " a) Removing the Sendmail package from within YaST / Software Management"
echo " b) rm -r /etc/mail"
echo " c) Install the Sendmail package from within YaST / Software Management"
echo ""
echo "During this process YaST will reinstall postfix, which you then have to remove"
echo "during the re-installation of Sendmail."
echo ""
echo "ONLY DO THIS IF sendmail is to be used just for OpenEMM as all config is lost"
echo "due to the deleting of the /etc/mail directory."
echo ""
echo "and restart the OpenEMM Installer (exiting)."
exit 1
else
echo "OpenEMM Installer: Sendmail configuration files are clean."
fi

# Check for required RPMs

for rpm in $RPM_REQUIRED; do
check_rpm $rpm
done

if ! [ -z "$INSTALLRPM" ]; then
echo "OpenEMM Installer is unable to find RPM package(s) missing: $INSTALLRPM"
echo "Please check/install these packages with YaST"
echo ""
echo "HINT - The packages may have different names - modify this batch file at line 14"
echo "and restart the OpenEMM Installer (exiting)."
exit 1
else
echo "OpenEMM Installer: All required RPM packages were found."
fi

echo
echo "+------------------------------OpenEMM Installation--------------------+"
echo "| Network Settings |"
echo "+----------------------------------------------------------------------+"
echo

# Check DNS lookup for my hostname

echo -n "OpenEMM Installer: Determinating your IP address..."
TEMP_HOSTLOOKUP=`host $MY_HOSTNAME`
if [ $? -gt 0 ]; then
echo "OpenEMM Installer: Please check the DNS entry for your system."
echo "Could not determinate a valid DNS entry (exiting)."
exit 1
fi
IP_ADDR=`echo $TEMP_HOSTLOOKUP | cut -f 4 -d' '`

echo $IP_ADDR
echo
echo -n "Is this IP address correct? (yes/no): "

read IP_CORRECT

if [ "$IP_CORRECT" == "no" ]; then
echo "OpenEMM Installer: Please configure your IP address by editing"
echo "the file '/etc/sysconfig/network' and restart the Network (exiting)."
exit 1
fi

####
# Verification done.
####

echo
echo "+------------------------------OpenEMM Installation--------------------+"
echo "| OpenEMM Binary & Documentation Setup |"
echo "+----------------------------------------------------------------------+"
echo

# Add user/group 'openemm'

echo "OpenEMM Installer: Adding group and user 'openemm'"
groupadd openemm
useradd -g openemm -m -d /home/openemm -c "OpenEMM" openemm

# Unpacking binary files to '/home/openemm'

if ! [ -f OpenEMM-BIN-latest.tgz ]; then
echo "OpenEMM Installer: OpenEMM tarball with file name OpenEMM-BIN-latest.tgz"
echo "was not found in this directory."
exit 1
else
echo "OpenEMM Installer: Unpacking 'OpenEMM-BIN-latest.tgz' to '/home/openemm'"
tar zxf OpenEMM-BIN-latest.tgz -C /home/openemm
echo "OpenEMM Installer: Setting critical permissions"
chown -R openemm:openemm /home/openemm/.bash* *
chown root:root /home/openemm/bin/smctrl
chmod 6755 /home/openemm/bin/smctrl
chown root:root /home/openemm/conf/bav/bav.rc
chmod 0600 /home/openemm/conf/bav/bav.rc
fi

# Unpacking documentation/license/sql files to '/usr/share/doc/OpenEMM-latest'

echo "OpenEMM Installer: Docs/License goes to '/usr/share/doc/OpenEMM-latest'"
rm -rf /usr/share/doc/OpenEMM-latest
mkdir -p /usr/share/doc/OpenEMM-latest
mv /home/openemm/USR_SHARE/* /usr/share/doc/OpenEMM-latest
rm -rf /home/openemm/USR_SHARE

# Find out OpenEMM version of the to be installed package

OPENEMM_INSTALL_VERSION=`grep logon.title /home/openemm/webapps/core/WEB-INF/classes/messages.properties | cut -d" " -f 3`

echo
echo "+------------------------------OpenEMM Installation--------------------+"
echo "| MySQL-Database Settings |"
echo "+----------------------------------------------------------------------+"
echo
echo -n "Your MySQL root password (just Enter for none): "
read MYSQL_ROOT_PASSWORD

# Check for existing 'openemm' database in MySQL

mysql -u root --password="$MYSQL_ROOT_PASSWORD" << EOF > /tmp/openemm_checkup_mysql
show databases
EOF
if [ `grep -v openemm_cms /tmp/openemm_checkup_mysql | grep openemm` ]; then
echo "WARNING: found an existing OpenEMM database! Options:"
echo "continue .) to use the existing database. Hint: If the database"
echo " was created by an earlier version of OpenEMM, you"
echo " need to upgrade it to version $OPENEMM_INSTALL_VERSION"
echo " by using the scripts in '/usr/share/doc/OpenEMM-latest'"
echo "delete .) removes the database and initialize a new, clean"
echo " OpenEMM version $OPENEMM_INSTALL_VERSION database."
echo " WARNING: ALL PREVIOUS DATA WILL BE LOST!"
echo
echo -n "Your choice (continue/delete): "
read EXISTING_OPENEMM_DB_CHOICE
if [ "$EXISTING_OPENEMM_DB_CHOICE" == "delete" ]; then
echo "OpenEMM Installer: dropping existing 'openemm' (and 'openemm_cms') database."
mysqladmin -u root -f --password="$MYSQL_ROOT_PASSWORD" drop openemm &>/dev/null
mysqladmin -u root -f --password="$MYSQL_ROOT_PASSWORD" drop openemm_cms &>/dev/null
echo "OpenEMM Installer: creating new 'openemm' and 'openemm_cms' database."
mysqladmin -u root --password="$MYSQL_ROOT_PASSWORD" create openemm
mysqladmin -u root --password="$MYSQL_ROOT_PASSWORD" create openemm_cms
echo "OpenEMM Installer: initialize 'openemm' and 'openemm_cms' database."
mysql -u root --password="$MYSQL_ROOT_PASSWORD" openemm < /usr/share/doc/OpenEMM-latest/openemm-$OPENEMM_INSTALL_VERSION.sql
mysql -u root --password="$MYSQL_ROOT_PASSWORD" openemm_cms < /usr/share/doc/OpenEMM-latest/openemm_cms.sql
else
echo "OpenEMM Installer: keeping existing 'openemm' (and 'openemm_cms') database."
fi
else
echo "OpenEMM Installer: creating new 'openemm' and 'openemm_cms' database."
mysqladmin -u root --password="$MYSQL_ROOT_PASSWORD" create openemm
mysqladmin -u root --password="$MYSQL_ROOT_PASSWORD" create openemm_cms
echo "OpenEMM Installer: initialize 'openemm' and 'openemm_cms' database."
mysql -u root --password="$MYSQL_ROOT_PASSWORD" openemm < /usr/share/doc/OpenEMM-latest/openemm-$OPENEMM_INSTALL_VERSION.sql
mysql -u root --password="$MYSQL_ROOT_PASSWORD" openemm_cms < /usr/share/doc/OpenEMM-latest/openemm_cms.sql
fi

# Modifications of local files (sendmail/openemm/logrotate.d-syslog)

echo
echo "+------------------------------OpenEMM Installation--------------------+"
echo "| Newsletter Settings |"
echo "+----------------------------------------------------------------------+"
echo
echo "Please define a sender address for your newsletter(s)."
echo "An example is 'newletter@openemm.org'"
echo -n "Your sender address? "
read SENDER_ADDRESS

SENDER_HOSTNAME=`echo $SENDER_ADDRESS | cut -f 2 -d@`

echo "SENDERHOST:" $SENDER_HOSTNAME
echo
echo "Please define a URL for your redirection links."
echo "An example is 'http://redirection.openemm.org:8080'"
echo -n "Your redirection URL? "
read RDIR_URL
RDIR_HOSTNAME=`echo $RDIR_URL | cut -f 3 -d'/' | cut -f 1 -d':'`

echo
echo "+------------------------------OpenEMM Installation--------------------+"
echo "| Modification of local files |"
echo "+----------------------------------------------------------------------+"
echo


echo "OpenEMM Installer: Tuning '/etc/mail/sendmail.mc'."
sed -e 's/^DAEMON_OPTIONS/dnl DAEMON_OPTIONS/' /etc/mail/sendmail.mc > /tmp/sendmail.mc
echo "INPUT_MAIL_FILTER(\`bav', \`S=unix:/home/openemm/var/run/bav.sock,F=T')dnl" >> /tmp/sendmail.mc
cp /tmp/sendmail.mc /etc/mail
echo "OpenEMM Installer: Creating '/etc/mail/relay-domains'."
echo "$SENDER_HOSTNAME" > /etc/mail/relay-domains
echo "OpenEMM Installer: Tuning '/etc/mail/mailertable'."
echo "$SENDER_HOSTNAME procmail:/home/openemm/conf/bav/bav.rc" > /etc/mail/mailertable
echo "OpenEMM Installer: Compilation of sendmail changes"
make -C /etc/mail &>/dev/null
echo "OpenEMM Installer: Creating '/home/openemm/conf/bav/bav.conf-local'."
echo "$SENDER_ADDRESS alias:ext_1@$SENDER_HOSTNAME" > /home/openemm/conf/bav/bav.conf-local
chown openemm /home/openemm/conf/bav/bav.conf-local
chgrp openemm /home/openemm/conf/bav/bav.conf-local
echo "OpenEMM Installer: Updating Redirection/Mailloop Domain in MySQL."
mysql -u root --password="$MYSQL_ROOT_PASSWORD" openemm << EOF
update company_tbl set rdir_domain="$RDIR_URL"
EOF
mysql -u root --password="$MYSQL_ROOT_PASSWORD" openemm << EOF
update company_tbl set mailloop_domain="$SENDER_HOSTNAME"
EOF
echo "OpenEMM Installer: Tuning '/etc/logrotate.d/syslog'."
if ! [ `grep create /etc/logrotate.d/syslog | tr -d ' '` ]; then
sed -e 's/sharedscripts/sharedscripts\n create 0604/' /etc/logrotate.d/syslog > /tmp/syslog
cp /tmp/syslog /etc/logrotate.d/syslog
fi

echo "OpenEMM Installer: Tuning permissions on '/var/log/maillog' to 604."
chmod 604 /var/log/maillog

echo
echo "+------------------------------OpenEMM Installation--------------------+"
echo "| Final steps |"
echo "+----------------------------------------------------------------------+"
echo
echo "Firewall Setup: You need to tune your firewall settings as following:"
echo " Port 25/TCP (SMTP) - OPEN"
echo " Port 8080/TCP (OpenEMM - Redirection) - OPEN"
echo " Port 8044/TCP (OpenEMM - Upgrade Service) - OPEN"
echo
echo "You will find the current firewall configuration in '/etc/sysconfig/iptables'"
echo
echo "DNS Setup: You need to create the following DNS entries:"
echo $SENDER_HOSTNAME" IN A "$IP_ADDR
echo $SENDER_HOSTNAME" IN MX 10 "$MY_HOSTNAME
echo $RDIR_HOSTNAME" IN A "$IP_ADDR
echo
echo "For further information about DNS entries consult your ISP."
echo
echo "OpenEMM Installer: Installation done. Become user 'openemm' by running"
echo " 'su - openemm' and start OpenEMM with 'OpenEMM.sh start'"
echo
echo "You can access OpenEMM with your web browser via URL yourdomain.com:8080."
echo "Login with user 'admin', password 'openemm' and change it immediately!"
echo
maschoff
Site Admin
Posts: 2608
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Post by maschoff »

Thank you! Could you please post it in the OpenEMM wiki at http://www.openemm.org/wiki/OpenEMM_Wiki_Home ? I think that would make it easier for other readers to find it.
OpenEMM Maintainer
roger
Posts: 8
Joined: Tue Mar 02, 2010 11:34 am

Post by roger »

LOL

The reason why I started to re-write the RedHat script was that I was finding it hard to follow the SUSE instructions on the wiki. I've still got more configuration work to do that requires me to understand the wiki so if I get that far I'll see what I can do.

One problem is that the wiki page is for OpenEMM 5.1.x and so needs a complete update.
maschoff
Site Admin
Posts: 2608
Joined: Thu Aug 03, 2006 10:20 am
Location: Munich, Germany
Contact:

Post by maschoff »

And our problem is that we stopped using Suse some time ago. The latest version we have is in the PDF of the Install Guide.
OpenEMM Maintainer
Post Reply