Current time: 07-18-2025, 07:05 PM Hello There, Guest! (LoginRegister)


Post Reply 
MAIA Install Script zur vereinfachung...nicht fertig
Author Message
ZooL Offline
Moderator
*****
Moderators

Posts: 3,429
Joined: Jan 2007
Reputation: 79
Post: #1
MAIA Install Script zur vereinfachung...nicht fertig
Hallo Commnunity...
es wäre nicht schlecht wenn der MAIA installer auch noch fertig gestellt werden würde!

Code:
########################
#                      #
# ispCP Maia-Installer #
#                v0.1  #
########################

# This script installs Maia 1.0.2a and integrates it into
# a running ispCP (RC3) system on Debian Etch
# See http://www.isp-control.net/ispcp/wiki/maia
#
# Parts marked with "##" are TODO

# some settings & variables
DATE=`date +%Y%m%d`
DateTime=`date +%Y-%m-%d,%H:%M:%S`
fMaincf=/etc/postfix/main.cf
fMaincfBak=/etc/postfix/main.cf.before-maia-$DateTime-bak

fAmavisCnf=/etc/amavis/amavisd.conf
fAmavisCnfMaia=/etc/amavis/amavisd.conf.maia
fAmavisCnfBak=/etc/amavis/amavisd.conf-before-maia-$DateTime-bak

fTmp1=/tmp/ispCP-Maia-Inst_$DateTime_1.tmp
fTmp2=/tmp/ispCP-Maia-Inst_$DateTime_2.tmp

fLocalcf=/etc/spamassassin/local.cf

clear
echo ""
echo ""
echo "++++++++++++++++++++++++++++++++++++++"
echo "Welcome to ispCP Omega Maia-Installer."
echo "++++++++++++++++++++++++++++++++++++++"
echo ""
# Checking if ispCP is installed on the System
if test ! -d /var/www/ispcp
then
        echo "You have no ispCP Omega installed on your Server!"
        echo "Installation abort."
        exit
fi

# Install needed software packages
echo "Start to install Maia 1.0.2a on this ispCP Omega System!"
echo "Please press Enter to continue..."
read enter

# Ask the MySQL maia user & pw, and/or for mysql root to create the user
echo "We need some details about MySQL and the Maia User"
ok=0
while [ "$ok" = "0" ]; do
        read -ep "Do you want this Script to create the Maia User in MySQL? [y/n] " crDbMaUser
        for a in Y y; do
                if [ "$crDbMaUser" = "$a" ]; then crDbMaUser=y; ok=1; fi
        done
        for a in N n; do
                if [ "$crDbMaUser" = "$a" ]; then crDbMaUser=n; ok=1; fi
        done
done
# ask the MySQL root user
if [ "$crDbMaUser" = "y" ]
then
        ok=0
        while [ "$ok" = "0" ]; do
                read -ep "Username of the MySQL Root User?, eg. 'root': " dbRtUser
                read -ep "Password for this User?: " dbRtPass
                read -ep "Type the Password again to be sure: " dbRtPass2
                if [ "$dbRtPass" = "$dbRtPass2" ]; then ok=1; fi
        done
fi
# ask the MySQL maia user
ok=0
while [ "$ok" = "0" ]; do
        read -ep "Username of the MySQL Maia User?, eg. 'maia' or 'ispcp-maia': " dbMaUser
        read -ep "Password for this User?: " dbMaPass
        read -ep "Type the Password again to be sure: " dbMaPass2
        if [ "$dbMaPass" = "$dbMaPass2" ]; then ok=1;
fi
done

# We got all needed database infos at this point here

echo "Install needed packages..."
echo ""
apt-get update && apt-get upgrade
apt-get install libdbd-mysql-perl libdbi-perl libphp-jpgraph libossp-uuid-perl
echo ""
echo "Upgrade pear now..."
echo ""
pear upgrade-all
echo ""
echo "Install needed pear modules..."
echo ""
pear install Log Mail_Mime File Date DB DB_Pager Net_Sieve Net_Pop3
pear -d preferred_state=alpha install Image_Color Image_Canvas Image_Graph Numbers_Roman Numbers_Words
pear install Pager Net_SMTP Auth_SASL

echo ""
echo "Stoping Postfix now..."
echo ""
/etc/init.d/postfix stop
echo ""
echo "Installing AMaVis, Spamassassin and ClamAV now..."
echo ""
apt-get install amavisd-new spamassassin clamav clamav-daemon
echo ""

echo "Creating a main.cf Backup file..."
cp $fMaincf $fMaincfBak

# remove the # in the line "#content_filter = amavis:[127.0.0.1]:10024"
sed -e "s/^#content_filter = amavis:\[127.0.0.1\]:10024/content_filter = amavis:[127.0.0.1]:10024/" $fMaincfBak > $fMaincf

echo ""
echo "Download special amavis.conf for Maia..."
echo ""
cd /etc/amavis
wget http://www200.pair.com/mecham/amavisd.conf.maia
mv amavisd.conf.maia $fAmavisCnf
if [ -f $fAmavisCnf ]
then
        echo "Creating $fAmavisCnf backup file..."
        cp $fAmavisCnf $fAmavisCnfBak
fi

# set mydomain & myhostname
mydom=`hostname -d`
myhst=`hostname -f`
echo "Setting mydomain & myhostname to $mdom & $myhst"
sed -e "s/^\$mydomain = 'yourdomain.tld';/\$mydomain = '$mydom';/" $fAmavisCnfMaia > $fTmp1
sed -e "s/^\$myhostname = 'host.yourdomain.tld';/\$myhostname = '$myhst';/" $fTmp1 > $fTmp2

###cp $fTmp2 $fAmavisCnf
# insert some variables into amavis-conf
echo ""
echo "Inserting some variables into $fAmavisCnf ..."
lFind1="\$final_bad_header_destiny = D_DISCARD;"
# find the line...
if [ -z $(grep -l "$lFind1" $fAmavisCnf) ]
then
        echo "Did not find the "$lFind1" line in $fAmavisCnf"
        echo "installation abort."
        exit
fi
lInsert1="\\
\$warnvirussender = 1;\\
\$warnspamsender = 0;\\
\$warnbannedsender = 1;\\
\$warnvirusrecip = 1;\\
\$warnbannedrecip = 1;"
if [ -z $(grep -l "$lInsert1" $fAmavisCnf) ]
then
        sed -e "/$lFind1/a\
$lInsert1" $fTmp2 > $fAmavisCnf
fi

## Joximu is working here...


# Checking about spamassassin folder
if test ! -d /etc/spamassassin/
then
echo ""
echo "No spamassassin folder found - create one..."
echo ""
mkdir /etc/spamassassin/
else
echo "Found a Spamassassin folder..."
fi

# Checking the local.cf
if test -f /etc/spamassassin/local.cf
then
echo ""
echo "Found a Spamassassin config - we will use it..."
echo ""

## SHOULD WE ASK TO OVERWRITE THE CURRENT local.cf ??
## BEACUSE IF SPAMASSASSIN IS INSTALLED BY THIS SCRIPT, IT WILL CREATE A local.cf
## BUT IF SPAMASSASSIN WAS INSTALLED BEFORE MAYBE THE CONFIG IS CHANGED TO THE NEED BY THE ADMIN

else
echo "Creating a default Spamassassin config..."
cat >  $fLocalcf << EOF
# SpamAssassin config file for version 3.x
# NOTE: NOT COMPATIBLE WITH VERSIONS 2.5 or 2.6
# See http://www.yrex.com/spam/spamconfig25.php for earlier versions

# How many hits before a message is considered spam.
required_score           5.0

# Encapsulate spam in an attachment (0=no, 1=yes, 2=safe)
report_safe             1

# Enable the Bayes system
use_bayes               1

# Enable Bayes auto-learning
bayes_auto_learn              1

# Enable or disable network checks
skip_rbl_checks         0
use_razor2              1
use_dcc                 1
use_pyzor               1

# Mail using languages used in these country codes will not be marked
# as being possibly spam in a foreign language.
ok_languages            all

# Mail using locales used in these country codes will not be marked
# as being possibly spam in a foreign language.
ok_locales              all
EOF

fi

# Add clamav to the amavis group
echo ""
echo "Adding the ClamAV User to the AMaVis Group..."
echo ""
usermod -G amavis clamav

# Start MySQL before AMaVis
echo ""
echo "Change MySQL & AMaViS startup..."
echo ""
update-rc.d -f mysql remove
update-rc.d mysql start 18 2 3 4 5 . stop 22 0 1 6 .

# Restart the Services
echo""
echo"Restart the changed Services..."
echo""
/etc/init.d/amavis restart
/etc/init.d/clamav-daemon restart
/etc/init.d/postfix restart

# Download and install Maia
echo "Please specify your Language now..."
echo ""
echo "Available languages are: en,de,fr,hu,it,nl,no,pl,sv"
echo "Your language is:" $answer
read answer
echo ""
echo "Downloading Maia, Themes and Language file..."
echo ""
mkdir /usr/src/maia
cd /usr/src/maia
wget http://www.maiamailguard.com/files/maia-1.0.2a.tar.gz
wget http://www.maiamailguard.com/files/maia-lang-$answer.tar.gz
wget http://ratsnet.org/vhcs/maia_vhcs_theme_v2.12.tar.bz2

echo ""
echo "Decompress the Files..."
echo ""
tar -xzf maia-1.0.2a.tar.gz
tar -xzf maia-lang-$answer.tar.gz
tar -xjvf maia_vhcs_theme_v2.12.tar.bz2

## MUST BE CHANGED - JOXIMU CREATED "dbRtPass"

echo "Creating the Maia DB..."
echo "Please type your MySQL root password now:"
echo "CREATE DATABASE maia;" >> /tmp/maiadb.sql
echo "quit;" >> /tmp/maiadb.sql
mysql -u root -p < /tmp/maiadb.sql
rm /tmp/maiadb.sql

## WE NEED THE TYPED PASSWORD IN A VARIABLE WAY FOR FOR DB ACCOUNT LATER :-/

echo ""
echo "Type in a password for the AMaVis User now"
passwd amavis
chsh -s /bin/false amavis

cd /usr/src/maia/maia-1.0.2

## BIG BUILDING - SAME PASSWORD PROBLEM :-/

echo ""
echo "Please type your MySQL Maia password:"
mysql -u root -p maia < maia-mysql.sql

echo "GRANT CREATE, DROP, ALTER, SELECT, INSERT, UPDATE, DELETE ON" >> /tmp/maiadb2.sql
echo "maia.* TO amavis@localhost IDENTIFIED BY '$amavispw';" >> /tmp/maiadb2.sql
echo "quit;" >> /tmp/maiadb2.sql
echo ""
echo "Please type your MySQL Maia password again:"

## UNTIL HERE

echo ""
echo "Creating the needed directories..."
echo ""
mkdir /var/lib/amavis/maia
mkdir /var/lib/amavis/maia/scripts
mkdir /var/lib/amavis/maia/templates
mv maia.conf.dist maia.conf

## HERE WE MUST ALSO CHANGE SOME LINES IN THE MAIA.CONF

# Change $password to your AMaViS Password and $base_url to http://admin.yourserver.tld/tools/antispam
# $script_dir = "/var/lib/amavis/maia/scripts";
# $template_dir = "/var/lib/amavis/maia/templates";
# $pid_file = "/var/run/amavis/.process-quarantine.pid";

echo ""
echo "Copy the files and set the right permissions..."
echo ""
cp /usr/src/maia/maia-1.0.2/maia.conf /etc/maia.conf
cp -R /usr/src/maia/maia-1.0.2/scripts/* /var/lib/amavis/maia/scripts
cp -R /usr/src/maia/maia-1.0.2/templates/* /var/lib/amavis/maia/templates
chown -R amavis /var/lib/amavis/maia
chgrp -R amavis /var/lib/amavis/maia
chmod 640 /var/lib/amavis/maia/templates/*.tpl
chmod 750 /var/lib/amavis/maia/scripts/*.pl
chown amavis /etc/maia.conf
chgrp amavis /etc/maia.conf
chmod 640 /etc/maia.conf

# Correct the directories in the script

## WE NEED TO CHANGE HERE '/var/amavisd/maia/scripts' to /var/lib/amavis/maia/scripts
## IN THE /var/lib/amavis/maia/scripts/process-quarantine.pl

# Testing the Config
echo ""
echo "Testing the config..."
echo ""
cd /var/lib/amavis/maia/scripts
./configtest.pl
echo ""
echo "NOT INSTALLED is OK for some modules"
echo "Please press Enter to continue..."
read enter

# Import the Spamassassin rules
cd /var/lib/amavis/maia/scripts
echo ""
echo "Import the Spamassassin rules..."
echo ""
./load-sa-rules.pl

# Install the Webinterface
echo ""
echo "Installing the Webinterface..."
echo ""
mkdir /var/www/ispcp/gui/tools/antispam
cp -R /usr/src/maia/maia-1.0.2/php/* /var/www/ispcp/gui/tools/antispam

# The Language Files...
mkdir /var/www/ispcp/gui/tools/antispam/locale/$answer
cp -R /usr/src/maia/$answer/* /var/www/ispcp/gui/tools/antispam/locale/$answer

# Edit the config.php
cd /var/www/ispcp/gui/tools/antispam
mv config.php.dist config.php

## WE MUST CHANGE THIS IN THE CONFIG.PHP AND NEED ALSO THE AMaVis PW HERE

## $default_display_language = "de";
## $maia_sql_dsn = "mysql://amavis:%amavispw@tcp(localhost:3306)/maia";
## $address_rewriting_type = 4;
## $auth_method = "pop3";

# Install Smarty
# Alternatively we can use "apt-get install smarty" but not sure about the Versionumber
echo ""
echo "Download Smarty and install it..."
echo ""
cd /usr/src/maia/
wget http://smarty.php.net/do_download.php?download_file=Smarty-2.6.18.tar.gz
tar -xzf Smarty-2.6.18.tar.gz
cd Smarty-2.6.18/libs
mkdir /var/www/ispcp/gui/tools/antispam/libs/Smarty
cp -R ./* /var/www/ispcp/gui/tools/antispam/libs/Smarty

# Uncomment the "$smarty_path = "/usr/share/php/smarty/libs"" in the "/var/www/ispcp/gui/tools/antispam/config.php"
# remove the # in the line "$smarty_path = "/usr/share/php/smarty/libs"

## THIS DOES NOT WORK - WHY ? :-/
## Answer: It is a PHP File, comments are marked as // and not as #
sed -e "s/^#$smarty_path = "/usr/share/php/smarty/libs";/" /var/www/ispcp/gui/tools/antispam/config.php

# Installing the old VHCS Blue Theme and set permissions
echo ""
echo "Installing the Theme and set the right permissions..."
echo ""
mkdir /var/www/ispcp/gui/tools/antispam/themes/modern_blue
cp -R /usr/src/maia/modern_blue/* /var/www/ispcp/gui/tools/antispam/themes/modern_blue
chown -R vu2000:www-data /var/www/ispcp/gui/tools/antispam
chmod -R 555 /var/www/ispcp/gui/tools/antispam
chmod -R 755 /var/www/ispcp/gui/tools/antispam/themes

# Creating Alias "antispam" in the Apacheconfig
## THIS LINE SHOULD PLACED UNDER "Alias /ftp    /var/www/ispcp/gui/tools/filemanger/"

echo "Alias /antispam     /var/www/ispcp/gui/tools/antispam/" >> /etc/apache2/sites-available/00_master.conf
/etc/init.d/apache2 restart

# POINT 15 IS SET TO THE END

# Install the Maia AMaVis Version
echo ""
echo "Installing the Maia AMaVis Version..."
echo ""
mv /usr/sbin/amavisd-new /usr/sbin/amavisd-bak
cp /usr/src/maia/maia-1.0.2/amavisd-maia /usr/sbin/amavisd-new
chown root /usr/sbin/amavisd-new
chmod 755 /usr/sbin/amavisd-new

# Add the needed lines for Maia in the Spamassassin local.cf
echo ""
echo "Modify the Spamassassin config for Maia.."
echo ""

## THE AMAVIS PASSWORD IS NEEDED HERE TOO :-/
## I USED ALSO $amavispw IN HERE FOR THE PASSWORD

cat >> $fLocalcf << EOF
bayes_store_module Mail::SpamAssassin::BayesStore::SQL
bayes_sql_dsn DBI:mysql:maia
bayes_sql_username amavis
bayes_sql_password $amavispw
bayes_sql_override_username amavis
bayes_auto_learn_threshold_nonspam 0.1
bayes_auto_learn_threshold_spam 10.0
bayes_use_hapaxes 1
bayes_use_chi2_combining 1
bayes_ignore_header ReSent-Date
bayes_ignore_header ReSent-From
bayes_ignore_header ReSent-Message-ID
bayes_ignore_header ReSent-Subject
bayes_ignore_header ReSent-To
bayes_ignore_header Resent-Date
bayes_ignore_header Resent-From
bayes_ignore_header Resent-Message-ID
bayes_ignore_header Resent-Subject
bayes_ignore_header Resent-To
bayes_ignore_header X-Received-From-IP
bayes_ignore_header X-Virus-Scanned
bayes_ignore_header X-Spam-Status
bayes_ignore_header X-Spam-Level
bayes_ignore_header X-Sender
bayes_ignore_header X-Mailer
# Auto-Whitelist configuration
auto_whitelist_factory Mail::SpamAssassin::SQLBasedAddrList
user_awl_dsn DBI:mysql:maia
user_awl_sql_username amavis
user_awl_sql_password $amavispw
EOF

# Creating a symlink to the AMaViS config
ln -s /etc/amavis/amavisd.conf /etc/amavisd.conf

# Restarting AMaVis
echo ""
echo "Restarting AMaVis..."
echo ""
/etc/init.d/amavis restart

# POINT 18 "Register as Maia-Admin" IS ALSO SET TO THE END

# Creating the Cron entry's with the needed scripts

## NEED TO CREATE THE CRON HERE
##crontab –u amavis -e
##55 * * * * /var/lib/amavis/maia/scripts/process-quarantine.pl --learn --report
##1 * * * * /var/lib/amavis/maia/scripts/stats-snapshot.pl
##5 1 * * * /var/lib/amavis/maia/scripts/expire-quarantine-cache.pl
##@weekly /var/lib/amavis/maia/scripts/send-quarantine-reminders.pl
###15 1 * * * /var/lib/amavis/maia/scripts/send-quarantine-digests.pl

# POINT 20: IS THIS STILL A BUG OR IS IT FIXED ?

# POINT 15 IS MOVED TO HERE
## ONLY PRINT THE EXAMPLE URL. MAYBE WE CAN USE THE REAL HOSTNAME HERE
echo ""
echo "Please open your Browser and go to this site to test the GUI"
echo "-> http://admin.yourserver.tld/tools/antispam/admin/configtest.php"
echo ""
echo "Here should every Module looks OK until:"
echo "PostgreSQL Support"
echo "PEAR::Net_IMAP"
echo "IMAP library"
echo "LDAP library"
echo "MCrypt library"
echo ""
echo "If not, you need to install it via 'pear install modulname'"
echo ""
echo "Please press Enter to continue if you are ready..."
read enter

# The User should register as Maia-Admin
## ONLY PRINT THE EXAMPLE URL. MAYBE WE CAN USE THE REAL HOSTNAME HERE
clear
echo ""
echo ""
echo "+++++++++++++++++++++++++++++++++++++++"
echo "Your Maia Installation was successfuly!"
echo "+++++++++++++++++++++++++++++++++++++++"
echo ""
echo "Open your Browser and go to this site:"
echo "-> http://admin.yourserver.tld/tools/antispam/login.php?super=register"
echo "and register you as Maia Admin."
echo ""
echo "For more infos or problems please vist http://www.isp-control.net"
echo ""



BeNe kann uns vieleicht sagen was noch fehlt... oder welche fehler bisher aufgetreten sind
ansonsten bitte in einer VM Testen...

danke schonmal im voraus
02-19-2009 10:45 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
MAIA Install Script zur vereinfachung...nicht fertig - ZooL - 02-19-2009 10:45 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)