source: companies/serpro/doc-expressolivre/expressoInstallDebian-etch_en.sh @ 903

Revision 903, 6.9 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

Line 
1#!/bin/bash
2
3# Criado por João Alfredo Knopik Junior <jakjr@celepar.pr.gov.br>
4# Colaborações:
5#       "William Fernando Merlotto" <william@prognus.com.br>
6#       "Alexandre Felipe Muller de Souza" <amuller@celepar.pr.gov.br>
7# Translate by SERPRO ...
8
9set -e # Para caso de erro
10
11if [ $UID != 0 ]; then {
12        echo "This script is to be run with superuser, root or sudo";
13        exit 1;
14        }
15fi
16
17apt-get update || { echo "Fail in apt-get update"; exit 1; }
18
19apt-get install -y dialog debconf-utils
20
21## change the debconf to critical, to not be questions ...
22debconf-set-selections ./arqs-conf/debconf.critical
23## End of DebConf configuration
24
25BACKTITLE='Install of ExpressoLivre 1.2'
26INTRO='
27Welcome to ExpressoLivre install!
28
293 (three) questions will be show to you.
30- Choose one password.
31- Choose one organization.
32- Choose one domain.
33
34With the answers above, the script will
35install and configure the ExpressoLivre.
36'
37#.....................................................................
38dialog --backtitle "$BACKTITLE" \
39   --cr-wrap \
40   --msgbox "$INTRO" \
41   17 55 &&
42#.....................................................................
43LDAP_PWD=$( dialog --stdout --inputbox 'Type one password:' 0 0 )
44#.....................................................................
45ORG=$( dialog --stdout --inputbox 'Type one organizazation:(ex.: serpro)' 0 55 )
46#.....................................................................
47DOMAIN=$( dialog --stdout --inputbox 'Type your domain:(ex.: '$ORG'.com)' 0 55 )
48
49#.....................................................................
50dialog --backtitle "$BACKTITLE" --cr-wrap --msgbox \
51"The ExpressoLivre install will start now." 10 65 &&
52#.....................................................................     
53
54apt-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;}
55
56############################################################################################
57# GET VARs
58LDAP_DN=`php ./arqs-conf/makedn.php $DOMAIN`
59LDAP_DC=`php ./arqs-conf/makedc.php $DOMAIN`
60LDAP_PWD_MD5=`slappasswd -v -s $LDAP_PWD -h {MD5}`
61LDAP_PWD_MD5=`php ./arqs-conf/regexp.php $LDAP_PWD_MD5`
62HEADER_PWD=`php ./arqs-conf/pass.php $LDAP_PWD`
63############################################################################################
64# POSTGRES
65cp ./arqs-conf/etc/postgresql/8.1/main/postgresql.conf /etc/postgresql/8.1/main/
66cp ./arqs-conf/etc/postgresql/8.1/main/pg_hba.conf /etc/postgresql/8.1/main/
67/etc/init.d/postgresql-8.1 restart
68
69su - postgres -c 'dropdb expresso'  || { echo "Expresso database not exist. [OK]"; }
70su - postgres -c 'createdb -E LATIN1 expresso'  || { echo "Fail Databse create. [FAIL]"; exit 1;}
71
72sed -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
73/etc/init.d/postgresql-8.1 restart
74su - postgres -c 'psql -f /tmp/expresso_en.dump expresso'
75rm /tmp/expresso_en.dump
76
77############################################################################################
78
79a2enmod rewrite;
80
81if [ -e /var/www/expresso/contactcenter/setup/external_catalogs.inc.php ]
82 then
83 cp /var/www/expresso/contactcenter/setup/external_catalogs.inc.php ../contactcenter/setup/external_catalogs.inc.php
84 #Save client contact_center
85 chown -R www-data.www-data ../contactcenter/setup/external_catalogs.inc.php
86 fi
87
88cp -r -p ../../expresso/ /var/www/
89cp ./arqs-conf/etc/apache2/apache2.conf /etc/apache2/
90cp ./arqs-conf/etc/apache2/ports.conf /etc/apache2/
91cp ./arqs-conf/etc/apache2/sites-available/default /etc/apache2/sites-available/
92cp -r -p ./arqs-conf/etc/apache2/ssl/ /etc/apache2/
93
94cp ./arqs-conf/etc/php5/apache2/php.ini /etc/php5/apache2/
95mkdir /php_sessions/ || { echo "folder already exist. [OK]"; }
96chmod -R 777 /php_sessions/
97
98/etc/init.d/apache2 restart
99
100############################################################################################
101# OPENLDAP
102/etc/init.d/slapd stop
103sed -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
104cp ./arqs-conf/etc/ldap/schema/* /etc/ldap/schema/
105rm -rf /var/lib/ldap
106mkdir /var/lib/ldap
107cp ./arqs-conf/etc/ldap/DB_CONFIG /var/lib/ldap/
108chown -R openldap. /var/lib/ldap/
109/etc/init.d/slapd start
110/etc/init.d/slapd stop
111
112sleep 2
113sed -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
114
115sleep 2
116slapadd -v -l /tmp/expresso.ldif
117chown -R openldap. /var/lib/ldap/*
118
119sleep 2
120/etc/init.d/slapd start
121rm /tmp/expresso.ldif
122############################################################################################
123# CYRUS
124cp ./arqs-conf/etc/imapd.conf /etc/
125cp ./arqs-conf/etc/cyrus.conf /etc/
126sed -e "s/LDAP_DN/$LDAP_DN/g" ./arqs-conf/etc/saslauthd.conf > /etc/saslauthd.conf
127cp ./arqs-conf/etc/default/saslauthd /etc/default/
128
129cp -p ./arqs-conf/usr/bin/cyradm_expresso /usr/bin/
130
131/etc/init.d/saslauthd restart
132sleep 4
133
134/etc/init.d/cyrus2.2 restart
135
136sleep 4
137./arqs-conf/cyrus.pl $LDAP_PWD
138
139############################################################################################
140# POSTFIX
141sed -e "s/LDAP_DN/$LDAP_DN/g" -e "s/DOMAIN/$DOMAIN/g" ./arqs-conf/etc/postfix/main.cf > /etc/postfix/main.cf
142sed -e "s/DOMAIN/$DOMAIN/g" ./arqs-conf/etc/postfix/expresso-dominios > /etc/postfix/expresso-dominios
143cp ./arqs-conf/etc/postfix/master.cf /etc/postfix/
144adduser postfix mail
145/etc/init.d/postfix restart
146postmap /etc/postfix/expresso-dominios
147echo "127.0.0.1         $DOMAIN" >> /etc/hosts
148############################################################################################
149# mkpasswd
150mkdir /home/expressolivre || { echo "Diretório já existe. [OK]"; }
151cp ./arqs-conf/home/expressolivre/* /home/expressolivre/
152chown -R www-data.www-data /home/expressolivre/
153############################################################################################
154# HEADER_INC_PHP
155sed -e "s/HEADER_PWD/$HEADER_PWD/g" ./arqs-conf/header.inc.php > /var/www/expresso/header.inc.php
156chown www-data.www-data /var/www/expresso/header.inc.php
157
158############################################################################################
159
160## Change the debconf to high, default of Debian Etch.
161debconf-set-selections ./arqs-conf/debconf.high
162## End of DebConf configuration
163
164dialog --backtitle "$BACKTITLE" --cr-wrap --msgbox "End of install. www.expressolivre.org" 7 55 &&
165
166echo '.'
Note: See TracBrowser for help on using the repository browser.