On 18/01/13 20:38, Jeremy McSpadden wrote:
apt-get remove postfix; apt-get install exim exim-pgsql ?.. i am still building 
the ubuntu installer. Iet me crank my ubuntu machine real quick.


Hi,
I also have been working on altering your Centos script to work on Ubuntu 12.04 server, so I thought I would send you my latest version, I think it is just about there, it installs and seems to work, but just needs tidying up.

Rowland Penny


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

#!/bin/bash

############
# Baruwa 2.0 Installer for Ubuntu 12.04 Server x64
#
# Adapted from the Centos installer written by
# Author - Jeremy McSpadden
# Contact - [email protected]
#
# This version by - Rowland Penny
# Contact - rpenny at f2s dot com
# Date - 1/18/2013
#
############

# VERSION TRACKING - Internal
VERSION="0.7" # Script Version
BRVER="2.0"     # Baruwa Version
UBUVER="12.04"  # OS Version

# Be sure we're root
USER=`whoami`
if [ "$USER" = "root" ]; then
    :
else
    echo "You must run this installer as root."
    exit 1
fi

# Check system type
OS=`uname -s`
if [ ${OS} = "Linux" ]; then
    :
else
    echo "Sorry, but this installer does not support the ${OS} platform."
    exit 1
fi

DISTRO=`cat /etc/os-release | grep NAME | head -n 1 | awk -F'=' {'print $2'} | 
awk -F'\"' {'print $2'}`
if [ ${DISTRO} = "Ubuntu" ]; then
    :
else
    echo "Sorry, but this installer does not support the ${DISTRO} 
distribution."
    exit 1
fi

RELEASE=`cat /etc/os-release  | grep VERSION_ID | awk -F'=' {'print $2'} | awk 
-F'\"' {'print $2'}`
if [ ${RELEASE} = "${UBUVER}" ]; then
    :
else
    echo "Sorry, but this installer does not support the ${RELEASE} release."
    exit 1
fi

HOSTN="hostname -s"
HOSTNAME=`hostname -f`
clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                                 Ubuntu Installer"
echo 
"------------------------------------------------------------------------------";
echo ""
echo "Welcome to the Baruwa ${BRVER} Ubuntu Installer. (Unofficial Version)"
echo "Before we begin: This installer was written for a new server install of 
Ubuntu ${UBUVER} x86_64"
echo "This installer is meant to assist you in installing Baruwa 2.0. You still 
need to know linux basics"
echo "and have an understanding of how Baruwa 2.0 operates. It is a complete 
re-write from the 1.0 branch."
echo "A lot of changes were made to the code and how it works. Please take the 
time to review the code that"
echo "I am using below so you understand what it is doing. This script will 
prompt you for the minimal amount"
echo "of questions needed to get Baruwa 2.0 installed and running. You will 
need to configure baruwa,"
echo "spamassassin rules, greylisting, RBL .. etc on your own."
echo ""
echo "If you are un-sure that you can maintain a Baruwa install, I recommend 
going with the"
echo "commercial product at http://www.baruwa.com; or the PAAS model at 
http://www.baruwa.net";
echo ""
echo "Please make sure you have added a hosts entry for your hostname of this 
server"
echo "into /etc/hosts or this script will fail. Please cancel if you have not. 
CTRL+C to Cancel"
echo ""
echo "Also, any bugs found in Baruwa itself should be reported to"
echo "the mailing list @ http://www.baruwa.org. You can contact me at rpenny at 
f2s dot com"
echo "with any concerns or additions you would like to see/add to this script."
echo ""
echo "I will assist you in installing Baruwa 2.0. This process could take a 
good 30 min+."
echo 
"------------------------------------------------------------------------------";
echo ""
echo "DO NOT PRESS ANY KEYS UNTIL ASKED, YOU WILL SKIP PASSWORD REQUESTS."
echo ""
echo -n "Press <enter> to continue"
echo ""
read randomkey

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                                REQUIRED DEBS";
echo 
"------------------------------------------------------------------------------";
echo "Installing required DEBs."
echo "This process will take some time."; sleep 3
export DEBIAN_FRONTEND='noninteractive'
# remove unrequired packages.
apt-get -y remove resolvconf popularity-contest

# Install baruwa repo
wget -cq -O - http://apt.baruwa.org/baruwa-apt-keys.gpg | apt-key add - &> 
/dev/null
echo "deb http://apt.baruwa.org/ubuntu precise main" >> 
/etc/apt/sources.list.d/baruwa.list
apt-get update

apt-get -y install ntp rabbitmq-server pyzor razor expect unrar-free htop arj 
zoo nomarch lzop cabextract p7zip rpm unrar-free ripole apparmor-profiles 
apparmor-utils gcc g++ git subversion libjpeg62-dev libxml2-dev libxslt1-dev 
cython libpq-dev libfreetype6-dev libldap2-dev libssl-dev swig libcrack2-dev 
libmemcached-dev libgeoip-dev python-dev libsasl2-dev libmysqlclient-dev 
python-setuptools postgresql postgresql-plpython sphinxsearch memcached 
mailscanner apache2 apache2-mpm-worker apache2-utils apache2.2-bin 
apache2.2-common javascript-common libapache2-mod-wsgi libaprutil1-dbd-sqlite3 
libaprutil1-ldap libart-2.0-2 libdbd-mysql-perl libjpeg-turbo8 libjpeg8 
libjs-dojo-core libjs-dojo-dijit libjs-dojo-dojox liblcms1 libyaml-0-2 
wwwconfig-common libstring-crc32-perl libev-perl libdbd-pg-perl 
libanyevent-perl python-virtualenv exim4-daemon-heavy libauthen-passphrase-perl 
libcrypt-blowfish-perl libcommon-sense-perl

pip install -U distribute

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                       VIRTUAL PYTHON ENVIRONMENT";
echo 
"------------------------------------------------------------------------------";
echo "This process could take a while." ; sleep 3

mkdir -p /home/baruwa
cd /home/baruwa
virtualenv --distribute px
source px/bin/activate
pip install -U distribute
export SWIG_FEATURES="-cpperraswarn -includeall -D__`uname -m`__ 
-I/usr/include/openssl"
curl -O https://raw.github.com/akissa/baruwa2/2.0.0/requirements.txt
pip install -r requirements.txt

curl https://sphinxsearch.googlecode.com/svn/trunk/api/sphinxapi.py -o 
px/lib/python2.7/site-packages/sphinxapi.py
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/patches/repoze.who-friendly-form.patch
curl -O 
https://raw.github.com/akissa/baruwa2/master/extras/patches/repoze-who-fix-auth_tkt-tokens.patch
cd /home/baruwa/px/lib/python2.7/site-packages/repoze/who/plugins
patch -p3 -i /home/baruwa/repoze.who-friendly-form.patch
patch -p4 -i /home/baruwa/repoze-who-fix-auth_tkt-tokens.patch
    
cd /home/baruwa
curl -O 
https://raw.github.com/akissa/baruwa2/master/extras/patches/0002-Disable-SSLv2_method.patch
curl -O http://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-0.21.1.tar.gz
tar xzf M2Crypto-0.21.1.tar.gz
cd M2Crypto-0.21.1/
patch -p1 -i ../0002-Disable-SSLv2_method.patch
python setup.py install
cd -

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                          POSTGRESQL CONFIGURATION";
echo 
"------------------------------------------------------------------------------";
echo "Lets set a password for the Postgresql user baruwa."
echo "What would you like this super secret"
echo "password to be?"
read PSQLPASS

mv /etc/postgresql/9.1/main/pg_hba.conf 
/etc/postgresql/9.1/main/pg_hba.conf.orig

cat > /etc/postgresql/9.1/main/pg_hba.conf << 'EOF'
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
local   all         postgres                          trust
host    all         all         127.0.0.1/32          md5
host    all         all         ::1/128               md5
EOF

sed -e "s/^#timezone = \(.*\)$/timezone = 'UTC'/" -i 
/etc/postgresql/9.1/main/postgresql.conf
# restart the service
service postgresql restart
cd /home/baruwa
su - postgres -c "psql postgres -c \"CREATE ROLE baruwa WITH LOGIN PASSWORD 
'${PSQLPASS}';\""
su - postgres -c 'createdb -E UTF8 -O baruwa -T template1 baruwa'
#su - postgres -c "psql baruwa -c \"CREATE LANGUAGE plpgsql;\""
su - postgres -c "psql baruwa -c \"CREATE LANGUAGE plpythonu;\""
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/baruwa/config/sql/admin-functions.sql
su - postgres -c 'psql baruwa -f /home/baruwa/admin-functions.sql'
service postgresql restart

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                        RABBITMQ CONFIGURATION";
echo 
"------------------------------------------------------------------------------";
echo "Lets set a password for RabbitMQ."
echo "What would you like this super secret"
echo "password to be?"
read RABPASS

service rabbitmq-server start
rabbitmqctl add_user baruwa ${RABPASS}
rabbitmqctl add_vhost baruwa
rabbitmqctl set_permissions -p baruwa baruwa ".*" ".*" ".*"
rabbitmqctl delete_user guest

cd /etc/sphinxsearch
if [ -f /etc/sphinxsearch/sphinx.conf ]; then
    mv /etc/sphinxsearch/sphinx.conf /etc/sphinxsearch/sphinx.conf.orig
fi
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/sphinx/sphinx.conf
sed -i -e 's:sql_host =:sql_host = 127.0.0.1:' \
       -e 's:sql_user =:sql_user = baruwa:' \
       -e "s:sql_pass =:sql_pass = ${PSQLPASS}:" \
       -e 's:sql_db =:sql_db = baruwa:' sphinx.conf

sed -i s/sphinx/sphinxsearch/g sphinx.conf

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                        MAILSCANNER CONFIGURATION";
echo 
"------------------------------------------------------------------------------";
echo -n ""
echo "This process could take a while."; sleep 3

cd /home/baruwa
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/patches/mailscanner-baruwa-iwantlint.patch
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/patches/mailscanner-baruwa-sql-config.patch
cd /usr/sbin
patch -i /home/baruwa/mailscanner-baruwa-iwantlint.patch
cd /usr/share/MailScanner/MailScanner
patch -p3 -i /home/baruwa/mailscanner-baruwa-sql-config.patch
cd /home/baruwa
curl -O https://raw.github.com/akissa/baruwa2/2.0.0/extras/perl/BS.pm
mv BS.pm /etc/MailScanner/CustomFunctions/
cd /etc/MailScanner
mv MailScanner.conf MailScanner.conf.orig
cd /home/baruwa
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/mailscanner/MailScanner.conf
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/mailscanner/scan.messages.rules
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/mailscanner/nonspam.actions.rules
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/mailscanner/filename.rules
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/mailscanner/filetype.rules
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/mailscanner/filename.rules.allowall.conf
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/mailscanner/filetype.rules.allowall.conf
mv *.rules /etc/MailScanner/rules/
mv *.conf /etc/MailScanner/
chmod -R 777 /var/spool/MailScanner/

sed -i 's:DB Password = verysecretpw:DB Password = '${PSQLPASS}':' 
/etc/MailScanner/MailScanner.conf
sed -i s/"\/etc\/exim"/"\/etc\/exim4"/ /etc/MailScanner/MailScanner.conf
sed -i s/"Run As User = exim"/"Run As User = Debian-exim"/ 
/etc/MailScanner/MailScanner.conf
sed -i s/"Run As Group = exim"/"Run As Group = Debian-exim"/ 
/etc/MailScanner/MailScanner.conf
sed -i s/"Quarantine User = exim"/"Quarantine User = Debian-exim"/ 
/etc/MailScanner/MailScanner.conf
sed -i s/"Incoming Work User = exim"/"Incoming Work User = Debian-exim"/ 
/etc/MailScanner/MailScanner.conf
sed -i s/"Incoming Work Group = clam"/"Incoming Work Group = clamav"/ 
/etc/MailScanner/MailScanner.conf
sed -i 's:Virus Scanners = none:Virus Scanners = clamd:' 
/etc/MailScanner/MailScanner.conf
sed -i 's:use_auto_whitelist 0:#use_auto_whitelist 0:' 
/etc/MailScanner/spam.assassin.prefs.conf
sed -i 's:Custom Functions Dir = 
/usr/share/MailScanner/MailScanner/CustomFunctions:Custom Functions Dir = 
/etc/MailScanner/CustomFunctions:' /etc/MailScanner/MailScanner.conf
sed -i s/"4.84.3"/"4.84.5"/ /etc/MailScanner/MailScanner.conf
sed -i s/"\/var\/spool\/exim\/input"/"\/var\/spool\/exim4\/input"/ 
/etc/MailScanner/MailScanner.conf

####################################################################################################################################################
sed -i s/"&BaruwaLog"/"no"/ /etc/MailScanner/MailScanner.conf                   
                                                                  #
# ABOVE LINE ADDED BECAUSE OF THE FOLLOWING FOUND IN LOGS, THIS WILL BE REMOVED 
WHEN PROPER CURE FOUND!                                            #
# Config: calling custom init function BaruwaLog                                
                                                                   #
# Could not use Custom Function code 
MailScanner::CustomConfig::InitBaruwaLog(0), it could not be "eval"ed.          
                              #
# Make sure the module is correct with perl -wc (Error: Undefined subroutine 
&MailScanner::CustomConfig::InitBaruwaLog called at (eval 79) line 1. # 
#                                                                               
                                                                   #
# This comes from the line 'Always Looked Up Last = &BaruwaLog' in 
MailScanner.conf                                                                
#
####################################################################################################################################################
mkdir -p /var/spool/exim.in/input
chown -R Debian-exim:Debian-exim /var/spool/exim.in

sed -i 's:/usr/local:/usr/:' /etc/MailScanner/autoupdate/clamav-autoupdate
sed -i s/"#run_mailscanner"/"run_mailscanner"/ /etc/default/mailscanner
sed -i 
s/"\/var\/lock\/MailScanner.off"/"\/var\/lock\/MailScanner\/MailScanner.off"/ 
/etc/init.d/mailscanner
sed -i 
s/"\/var\/lock\/subsys\/mailscanner"/"\/var\/lock\/MailScanner\/mailscanner"/ 
/etc/init.d/mailscanner

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                            BARUWA CONFIGURATION";
echo 
"------------------------------------------------------------------------------";
echo -n ""
echo ""; sleep 3

cd /home/baruwa
virtualenv --distribute px
source px/bin/activate
pip install -U distribute
export SWIG_FEATURES="-cpperraswarn -includeall -D__`uname -m`__ 
-I/usr/include/openssl"
pip install baruwa
px/bin/paster make-config baruwa production.ini

clear 2>/dev/null
echo "We now need to set a password for the sqlalchemy user baruwa."
echo "What would you like this super secret password to be?"
read ALCHEMYPASS

sed -i -e 
's|baruwa:@127.0.0.1:5432/baruwa|baruwa:'${ALCHEMYPASS}'@127.0.0.1:5432/baruwa|'
 \
        production.ini
sed -i -e 's:broker.password =:broker.password = '${ALCHEMYPASS}':' \
       -e "s:snowy.local:${HOSTNAME}:g" \
       -e 's:^#celery.queues:celery.queues:' production.ini
     
mkdir /etc/baruwa
mv production.ini /etc/baruwa

cat > /etc/sudoers.d/baruwa << 'EOF'
Defaults:baruwa !requiretty, visiblepw

baruwa ALL=(exim) NOPASSWD: /usr/sbin/exim -C /etc/exim4/exim_out.conf -M *, \
/usr/sbin/exim -C /etc/exim4/exim_out.conf -Mf *, \
/usr/sbin/exim -C /etc/exim4/exim_out.conf -Mrm *, \
/usr/sbin/exim -C /etc/exim4/exim_out.conf -Mg *, \
/usr/sbin/exim -C /etc/exim4/exim_out.conf -Mar *, \
/usr/sbin/exim -C /etc/exim4/exim_out.conf -qff, \
/usr/sbin/exim -Mrm *, \
/usr/sbin/exim -Mg *, \
/usr/sbin/exim -Mar *

baruwa ALL = NOPASSWD: /bin/kill -s HUP *
EOF
chmod 0440 /etc/sudoers.d/baruwa

cd /etc/exim4
curl -O https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/exim/exim.conf
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/exim/exim_out.conf
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/exim/macros.conf
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/exim/trusted-configs
mv /etc/exim4/exim.conf /etc/exim4/exim4.conf
sed -i s/"\/etc\/exim"/"\/etc\/exim4"/ /etc/exim4/exim4.conf
sed -i -e 's/spf/#spf = /' /etc/exim4/exim4.conf
sed -i s/"user = exim"/"user = Debian-exim"/ /etc/exim4/exim4.conf
sed -i -e 's/verysecretpw/'${ALCHEMYPASS}'/' /etc/exim4/macros.conf
sed -i -e 's/dbl_/#dbl_/' /etc/exim4/exim_out.conf
sed -i s/"\/etc\/exim"/"\/etc\/exim4"/ /etc/exim4/exim_out.conf
sed -i s/"\/etc\/exim"/"\/etc\/exim4"/ /etc/exim4/trusted-configs

mkdir baruwa; cd baruwa
wget 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/exim/baruwa/exim-bcrypt.pl

service exim4 start

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                          PERL MODS CONFIGURATION";
echo 
"------------------------------------------------------------------------------";
echo "We are now going to install a few Perl Modules"
echo "that at not available via Apt Repo's."
echo "Please press Yes/Enter throughout the questions."
echo "Press enter to continue."
read randomkey

perl -MCPAN -e 'install Encoding::FixLatin'

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                         CELERYD CONFIGURATION";
echo 
"------------------------------------------------------------------------------";
echo -n ""
echo ""; sleep 3

cat > /etc/default/baruwa << 'EOF'
CELERYD_CHDIR="/home/baruwa"
CELERYD="$CELERYD_CHDIR/px/bin/paster celeryd /etc/baruwa/production.ini"
CELERYD_LOG_LEVEL="INFO"
CELERYD_LOG_FILE="/var/log/baruwa/celeryd.log"
CELERYD_PID_FILE="/var/run/baruwa/celeryd.pid"
CELERYD_USER="baruwa"
CELERYD_GROUP="baruwa"
EOF

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                          APACHE CONFIGURATION";
echo 
"------------------------------------------------------------------------------";
echo -n ""
echo ""; sleep 3

curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/config/mod_wsgi/apache.conf
mv apache.conf /etc/apache2/conf.d/baruwa.conf
service apache2 restart
service sphinxsearch start

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                        BARUWA ADMIN CONFIGURATION";
echo 
"------------------------------------------------------------------------------";
echo -n ""
echo ""; sleep 3
echo 
echo "You will be asked if you want to create an admin user."
echo "Please enter 'n' when asked."
cd /home/baruwa
virtualenv --distribute px
source px/bin/activate
pip install -U distribute
export SWIG_FEATURES="-cpperraswarn -includeall -D__`uname -m`__ 
-I/usr/include/openssl"
px/bin/paster setup-app /etc/baruwa/production.ini

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                        BARUWA ADMIN CONFIGURATION";
echo 
"------------------------------------------------------------------------------";
echo -n ""
echo ""; sleep 3
echo "We now need a username for the Baruwa Admin account"
echo "What name would you like to use?"
read ADMINUSER
echo
echo "We now need to set a password for the Admin user."
echo "What would you like this super secret password to be?"
echo "NOTE: it must be a complex password & not based on a dictionary word."
read ADMINPASS
echo
echo "What Email address do you want to use for the Adminuser ${ADMINUSER}?"
read ADMINEMAIL
/home/baruwa/px/bin/paster create-admin-user -u ${ADMINUSER} -p ${ADMINPASS} -e 
${ADMINEMAIL} -t UTC /etc/baruwa/production.ini  

indexer --all --rotate
mkdir -p /var/log/baruwa /var/run/baruwa 
/var/lib/baruwa/data/{cache,sessions,uploads} \
/var/lock/baruwa /etc/MailScanner/baruwa/signatures 
/etc/MailScanner/baruwa/dkim \
/etc/MailScanner/baruwa/rules /etc/apache2/logs

touch /etc/apache2/logs/baruwa-error_log
touch /etc/apache2/logs/baruwa-access_log
sed -i s/"python2.6"/"python2.7"/g /etc/apache2/conf.d/baruwa.conf
sed -i s/"python2.4"/"python2.7"/ /etc/apache2/conf.d/baruwa.conf

##############################################################################
# Setup Cron Jobs #
##############################################################################

cat > /etc/cron.hourly/baruwa-updateindex << 'EOF'
#!/bin/bash
#
indexer auditlog lists domains accounts organizations --rotate &>/dev/null
EOF
chmod +x /etc/cron.hourly/baruwa-updateindex

#paster celeryd /etc/baruwa/production.ini -f /var/log/baruwa/celeryd.log &
#paster serve --reload /etc/baruwa/production.ini

cat > /etc/cron.d/baruwa << 'EOF'
*/3 * * * * exim /home/baruwa/px/bin/paster update-queue-stats 
/etc/baruwa/production.ini >/dev/null 2>&1
0 * * * * baruwa /home/baruwa/px/bin/paster update-sa-rules 
/etc/baruwa/production.ini >/dev/null 2>&1
0 * * * * root /home/baruwa/px/bin/paster update-delta-index --index messages 
--realtime /etc/baruwa/production.ini >/dev/null 2>&1
0 0 * * * baruwa /home/baruwa/px/bin/paster send-quarantine-reports 
/etc/baruwa/production.ini >/dev/null 2>&1
0 1 * * * baruwa /home/baruwa/px/bin/paster prunedb /etc/baruwa/production.ini 
>/dev/null 2>&1
9 1 * * * root /home/baruwa/px/bin/paster update-delta-index --index archive 
/etc/baruwa/production.ini >/dev/null 2>&1
0 2 * * * baruwa /home/baruwa/px/bin/paster prunequarantine 
/etc/baruwa/production.ini >/dev/null 2>&1
0 6 1 * * baruwa /home/baruwa/px/bin/paster send-pdf-reports 
/etc/baruwa/production.ini >/dev/null 2>&1
EOF

clear 2>/dev/null
##############################################################################
# Check Services/Permissions #
##############################################################################
getent group baruwa >/dev/null || groupadd -r baruwa
getent passwd baruwa >/dev/null || \
    useradd -r -g baruwa -d /var/lib/baruwa \
    -s /sbin/nologin -c "Baruwa User" baruwa
chown baruwa.baruwa -R /var/lib/baruwa \
        /var/run/baruwa /var/log/baruwa \
        /var/lock/baruwa /etc/MailScanner/baruwa
cd /home/baruwa
curl -O 
https://raw.github.com/akissa/baruwa2/2.0.0/extras/scripts/init/debian/baruwa.init
mv baruwa.init /etc/init.d/baruwa
chmod +x /etc/init.d/baruwa

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                          RESTART SERVICES";
echo 
"------------------------------------------------------------------------------";
echo -n ""
echo ""; sleep 3

if [ -d /var/lib/baruwa/data/templates/general ]; then
    :
else
    mkdir -p /var/lib/baruwa/data/templates/general
fi

if [ -d /var/lib/baruwa/data/templates/accounts ]; then
    :
else
    mkdir -p /var/lib/baruwa/data/templates/accounts
fi

chown -R baruwa: /var/log/baruwa
chown -R baruwa: /var/run/baruwa
chown -R www-data: /var/lib/baruwa/data
usermod -G Debian-exim baruwa

service apache2 restart
service memcached restart
service postgresql restart
service rabbitmq-server restart
service baruwa restart
update-rc.d baruwa defaults
service mailscanner restart

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                             UPDATE CLAMAV";
echo 
"------------------------------------------------------------------------------";
echo -n ""
echo ""; sleep 3
echo -n "Updating Clamav Definitions now."
echo ""
echo "First sort out Clamav Apparmor profile."
echo
echo "/var/spool/MailScanner/** rw," >> /etc/apparmor.d/local/usr.sbin.clamd 
echo "/var/spool/MailScanner/incoming/** rw," >> 
/etc/apparmor.d/local/usr.sbin.clamd 
service apparmor restart &> /dev/null
echo "Apparmor Updated & Restarted"
echo
freshclam
service clamav-daemon restart

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                        COMPLETING INSTALLATION";
echo 
"------------------------------------------------------------------------------";
echo -n ""
echo ""; sleep 3

echo "What email would you like root's email to be sent to?"
echo "ie: [email protected]"
read ROOTEMAIL
echo -n "root: ${ROOTEMAIL}" >> /etc/aliases
newaliases
echo ""
echo "What email would you like Administrative Emails sent to?"
echo "ie: [email protected]"
read ADMEMAIL
sed -i 's:email_to = baruwa@localhost:email_to = '${ADMEMAIL}':' 
/etc/baruwa/production.ini
echo ""
echo "What email would you like Report Emails sent from?"
echo "ie: [email protected]"
read REPEMAIL
sed -i 's:baruwa.reports.sender = 
[email protected]:baruwa.reports.sender = '${REPEMAIL}':' 
/etc/baruwa/production.ini
echo ""
echo "What email would you like Error Emails sent from?"
echo "ie: [email protected]"
read ERREMAIL
echo
sed -i 's:error_email_from = baruwa@localhost:error_email_from = 
'${ERREMAIL}':' /etc/baruwa/production.ini
sed -i s/"ms.home.topdog-software.com"/"${HOSTNAME}"/ 
/etc/apache2/conf.d/baruwa.conf

clear 2>/dev/null
echo 
"------------------------------------------------------------------------------";
echo "                        DISPLAY SETTINGS";
echo 
"------------------------------------------------------------------------------";
echo -n ""
echo ""; sleep 3
cat >> /home/baruwa/install.txt <<EOF
Your Postgres Password is : ${PSQLPASS}
Your RabbitMQ Password is : ${RABPASS}
Your Baruwa Password is : ${ALCHEMYPASS}

The Baruwa Admin User is : ${ADMINUSER}
The Password for ${ADMINUSER} is : ${ADMINPASS}

Emails for ${ADMINUSER} will be sent to : ${ADMINEMAIL}
Your root emails will be sent to : ${ROOTEMAIL}
Your Reports will be sent from : ${REPEMAIL}
Your Errors wil be sent from ${ERREMAIL}

You log into the Webpage at http://${HOSTNAME}
With the Username: ${ADMINUSER}
And the Password: ${ADMINPASS}
EOF

echo "Your Postgres Password is : ${PSQLPASS} "
echo "Your RabbitMQ Password is : ${RABPASS}"
echo "Your Baruwa Password is : ${ALCHEMYPASS}"
echo ""
echo "The Baruwa Admin User is : ${ADMINUSER}"
echo "The Password for ${ADMINUSER} is : ${ADMINPASS}"
echo
echo "Emails for ${ADMINUSER} will be sent to : ${ADMINEMAIL}"
echo "Your root emails will be sent to : ${ROOTEMAIL}"
echo "Your Reports will be sent from : ${REPEMAIL}"
echo "Your Errors wil be sent from ${ERREMAIL}"
echo ""
echo "You log into the Webpage at http://${HOSTNAME}";
echo "With the Username: ${ADMINUSER}"
echo "And the Password: ${ADMINPASS}"
echo 
echo "You can also find this information in the file:"
echo "/home/baruwa/install.txt"
echo
echo "Press <enter> to send an email to ${ADMEMAIL} "
read randomkey

##############################################################################
# Email Results #
##############################################################################

cat >> /tmp/message <<EOF 
Baruwa 2.0 Install for ${HOSTNAME}
----------------------------------

Your Postgres Password is : ${PSQLPASS}
Your Rabbit-MQ Password is : ${RABPASS}
Your Baruwa Password is : ${ALCHEMYPASS}

The Baruwa Admin User is : ${ADMINUSER}
The Password for ${ADMINUSER} is : ${ADMINPASS}

Emails for ${ADMINUSER} will be sent to : ${ADMINEMAIL}
Your root emails will be sent to : ${ROOTEMAIL}
Your Reports will be sent from : ${REPEMAIL}
Your Errors wil be sent from : ${ERREMAIL}

You log into the Webpage at http://${HOSTNAME}
With the Username: ${ADMINUSER}
And the Password: ${ADMINPASS}

Please visit http://baruwa.org/docs/2.0/guide/admin/index.html
and follow the guide on how to configure your install.
--
Baruwa 2.0 Installer by Jeremy McSpadden
[email protected]

Rewritten by Rowland Penny
rpenny at f2s dot com

Please support the Baruwa project by donating at
http://pledgie.com/campaigns/12056
EOF

/usr/bin/mail -s Baruwa 2.0 Install for ${HOSTNAME} < /tmp/message "${ADMEMAIL}"

clear 2>/dev/null
echo "An email has been sent to "${ADMEMAIL}"."
echo "You may now log into the Webpage at http://${HOSTNAME}";
echo "With the Username: ${ADMINUSER}"
echo "And the Password: ${ADMINPASS}"
echo "Press <enter> to exit"
read randomkey

#/etc/apache2/conf.d/phppgadmin -> ../../phppgadmin/apache.conf
_______________________________________________
Keep Baruwa FREE - http://pledgie.com/campaigns/12056

Reply via email to