#!/bin/bash # Criado por João Alfredo Knopik Junior # Colaborações: # "William Fernando Merlotto" # "Alexandre Felipe Muller de Souza" # Translate by SERPRO ... set -e # Para caso de erro if [ $UID != 0 ]; then { echo "This script is to be run with superuser, root or sudo"; exit 1; } fi apt-get update || { echo "Fail in apt-get update"; exit 1; } apt-get install -y dialog debconf-utils ## change the debconf to critical, to not be questions ... debconf-set-selections ./arqs-conf/debconf.critical ## End of DebConf configuration BACKTITLE='Install of ExpressoLivre 1.2' INTRO=' Welcome to ExpressoLivre install! 3 (three) questions will be show to you. - Choose one password. - Choose one organization. - Choose one domain. With the answers above, the script will install and configure the ExpressoLivre. ' #..................................................................... dialog --backtitle "$BACKTITLE" \ --cr-wrap \ --msgbox "$INTRO" \ 17 55 && #..................................................................... LDAP_PWD=$( dialog --stdout --inputbox 'Type one password:' 0 0 ) #..................................................................... ORG=$( dialog --stdout --inputbox 'Type one organizazation:(ex.: serpro)' 0 55 ) #..................................................................... DOMAIN=$( dialog --stdout --inputbox 'Type your domain:(ex.: '$ORG'.com)' 0 55 ) #..................................................................... dialog --backtitle "$BACKTITLE" --cr-wrap --msgbox \ "The ExpressoLivre install will start now." 10 65 && #..................................................................... apt-get install -y apache2-mpm-prefork libapache2-mod-php5 apache2-utils php5 php5-common php5-dev php5-gd php5-imap php5-ldap php5-pgsql php5-cgi php5-cli postgresql-8.1 postgresql-common postgresql-client-8.1 postgresql-client-common slapd ldap-utils db4.2-util cyrus-admin-2.2 cyrus-clients-2.2 cyrus-common-2.2 cyrus-doc-2.2 cyrus-imapd-2.2 libcyrus-imap-perl22 postfix postfix-ldap libsasl2 libsasl2-modules sasl2-bin nmap vim libmail-imapclient-perl libparse-recdescent-perl libterm-readkey-perl libterm-readline-perl-perl zip unzip graphviz lsb-base openssl ssl-cert || { echo "Is not possible continue. Fail package instalation"; exit 1;} ############################################################################################ # GET VARs LDAP_DN=`php ./arqs-conf/makedn.php $DOMAIN` LDAP_DC=`php ./arqs-conf/makedc.php $DOMAIN` LDAP_PWD_MD5=`slappasswd -v -s $LDAP_PWD -h {MD5}` LDAP_PWD_MD5=`php ./arqs-conf/regexp.php $LDAP_PWD_MD5` HEADER_PWD=`php ./arqs-conf/pass.php $LDAP_PWD` ############################################################################################ # POSTGRES cp ./arqs-conf/etc/postgresql/8.1/main/postgresql.conf /etc/postgresql/8.1/main/ cp ./arqs-conf/etc/postgresql/8.1/main/pg_hba.conf /etc/postgresql/8.1/main/ /etc/init.d/postgresql-8.1 restart su - postgres -c 'dropdb expresso' || { echo "Expresso database not exist. [OK]"; } su - postgres -c 'createdb -E LATIN1 expresso' || { echo "Fail Databse create. [FAIL]"; exit 1;} sed -e "s/LDAP_DN/$LDAP_DN/g" -e "s/LDAP_PWD/$LDAP_PWD/g" -e "s/ORG/$ORG/g" -e "s/DOMAIN/$DOMAIN/g" ./arqs-conf/expresso_en.dump > /tmp/expresso_en.dump /etc/init.d/postgresql-8.1 restart su - postgres -c 'psql -f /tmp/expresso_en.dump expresso' rm /tmp/expresso_en.dump ############################################################################################ a2enmod rewrite; if [ -e /var/www/expresso/contactcenter/setup/external_catalogs.inc.php ] then cp /var/www/expresso/contactcenter/setup/external_catalogs.inc.php ../contactcenter/setup/external_catalogs.inc.php #Save client contact_center chown -R www-data.www-data ../contactcenter/setup/external_catalogs.inc.php fi cp -r -p ../../expresso/ /var/www/ cp ./arqs-conf/etc/apache2/apache2.conf /etc/apache2/ cp ./arqs-conf/etc/apache2/ports.conf /etc/apache2/ cp ./arqs-conf/etc/apache2/sites-available/default /etc/apache2/sites-available/ cp -r -p ./arqs-conf/etc/apache2/ssl/ /etc/apache2/ cp ./arqs-conf/etc/php5/apache2/php.ini /etc/php5/apache2/ mkdir /php_sessions/ || { echo "folder already exist. [OK]"; } chmod -R 777 /php_sessions/ /etc/init.d/apache2 restart ############################################################################################ # OPENLDAP /etc/init.d/slapd stop sed -e "s/LDAP_DN/$LDAP_DN/g" -e "s/LDAP_PWD_MD5/$LDAP_PWD_MD5/g" ./arqs-conf/etc/ldap/slapd.conf.etch > /etc/ldap/slapd.conf cp ./arqs-conf/etc/ldap/schema/* /etc/ldap/schema/ rm -rf /var/lib/ldap mkdir /var/lib/ldap cp ./arqs-conf/etc/ldap/DB_CONFIG /var/lib/ldap/ chown -R openldap. /var/lib/ldap/ /etc/init.d/slapd start /etc/init.d/slapd stop sleep 2 sed -e "s/LDAP_DN/$LDAP_DN/g" -e "s/LDAP_PWD_MD5/$LDAP_PWD_MD5/g" -e "s/ORG/$ORG/g" -e "s/DOMAIN/$DOMAIN/g" -e "s/LDAP_DC/$LDAP_DC/g" ./arqs-conf/expresso.ldif > /tmp/expresso.ldif sleep 2 slapadd -v -l /tmp/expresso.ldif chown -R openldap. /var/lib/ldap/* sleep 2 /etc/init.d/slapd start rm /tmp/expresso.ldif ############################################################################################ # CYRUS cp ./arqs-conf/etc/imapd.conf /etc/ cp ./arqs-conf/etc/cyrus.conf /etc/ sed -e "s/LDAP_DN/$LDAP_DN/g" ./arqs-conf/etc/saslauthd.conf > /etc/saslauthd.conf cp ./arqs-conf/etc/default/saslauthd /etc/default/ cp -p ./arqs-conf/usr/bin/cyradm_expresso /usr/bin/ /etc/init.d/saslauthd restart sleep 4 /etc/init.d/cyrus2.2 restart sleep 4 ./arqs-conf/cyrus.pl $LDAP_PWD ############################################################################################ # POSTFIX sed -e "s/LDAP_DN/$LDAP_DN/g" -e "s/DOMAIN/$DOMAIN/g" ./arqs-conf/etc/postfix/main.cf > /etc/postfix/main.cf sed -e "s/DOMAIN/$DOMAIN/g" ./arqs-conf/etc/postfix/expresso-dominios > /etc/postfix/expresso-dominios cp ./arqs-conf/etc/postfix/master.cf /etc/postfix/ adduser postfix mail /etc/init.d/postfix restart postmap /etc/postfix/expresso-dominios echo "127.0.0.1 $DOMAIN" >> /etc/hosts ############################################################################################ # mkpasswd mkdir /home/expressolivre || { echo "Diretório já existe. [OK]"; } cp ./arqs-conf/home/expressolivre/* /home/expressolivre/ chown -R www-data.www-data /home/expressolivre/ ############################################################################################ # HEADER_INC_PHP sed -e "s/HEADER_PWD/$HEADER_PWD/g" ./arqs-conf/header.inc.php > /var/www/expresso/header.inc.php chown www-data.www-data /var/www/expresso/header.inc.php ############################################################################################ ## Change the debconf to high, default of Debian Etch. debconf-set-selections ./arqs-conf/debconf.high ## End of DebConf configuration dialog --backtitle "$BACKTITLE" --cr-wrap --msgbox "End of install. www.expressolivre.org" 7 55 && echo '.'