source: branches/2.2/doc-expressolivre/debian/expressoInstallDebian-squeeze.sh @ 5101

Revision 5101, 8.4 KB checked in by niltonneto, 9 years ago (diff)

Ticket #2282 - Corrigido script para liberar permissão de escrita em /php_sessions

  • Property svn:executable set to *
Line 
1#!/bin/bash
2
3set -e # Para caso de erro
4
5if [ $UID != 0 ]; then {
6        echo "Este script deve ser executado como superusuario, root ou sudo";
7        exit 1;
8        }
9fi
10
11apt-get update || { echo "Falha ao atualizar o apt-get"; exit 1; }
12
13apt-get install -y dialog debconf-utils
14
15## Mudamos o debconf para critical, para que nao sejam feitas perguntas desnecessarias.
16debconf-set-selections ./arqs-conf/debconf.critical
17## Fim da configuracao do DebConf
18
19BACKTITLE='Instalacao do ExpressoLivre 2.2'
20INTRO='
21Bem-Vindo(a) a instalacao do ExpressoLivre!
22
233 (tres) perguntas serao feitas a voce.
24- Escolha uma senha.
25- Escolha uma organizacao.
26- Escolha um domi­nio.
27
28Com estas informacoes o script podera
29instalar e configurar o ExpressoLivre.
30'
31#.....................................................................
32dialog --backtitle "$BACKTITLE" \
33   --cr-wrap \
34   --msgbox "$INTRO" \
35   17 55 &&
36#.....................................................................
37LDAP_PWD=$( dialog --stdout --inputbox 'Digite uma senha:' 0 0 )
38#.....................................................................
39ORG=$( dialog --stdout --inputbox 'Digite uma organizacao:(ex.: celepar)' 0 55 )
40#.....................................................................
41DOMAIN=$( dialog --stdout --inputbox 'Digite seu dominio:(ex.: '$ORG'.com.br)' 0 55 )
42
43#.....................................................................
44dialog --backtitle "$BACKTITLE" --cr-wrap --msgbox \
45"A instalacao dos pacotes necessarios para o ExpressoLivre ira comecar agora." 10 65 &&
46#.....................................................................
47
48apt-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 slapd ldap-utils db4.7-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-2 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 "Impossível continuar, erro no nome dos pacotes"; exit 1; }
49
50############################################################################################
51# GET VARs
52LDAP_DN=`php ./arqs-conf/makedn.php $DOMAIN`
53LDAP_DC=`php ./arqs-conf/makedc.php $DOMAIN`
54LDAP_PWD_MD5=`slappasswd -v -s $LDAP_PWD -h {MD5}`
55LDAP_PWD_MD5=`php ./arqs-conf/regexp.php $LDAP_PWD_MD5`
56HEADER_PWD=`php ./arqs-conf/pass.php $LDAP_PWD`
57############################################################################################
58# APACHE
59# descomente para gerar o certificado para o https
60#apache2-ssl-certificate;
61
62a2enmod rewrite
63a2enmod ssl
64
65cp -r -p ../../../expresso/ /var/www/
66cp ./arqs-conf/etc/apache2/apache2.conf.lenny /etc/apache2/apache2.conf
67cp ./arqs-conf/etc/apache2/sites-available/default.lenny /etc/apache2/sites-available/expresso
68cp ./arqs-conf/etc/apache2/ports.conf.lenny /etc/apache2/ports.conf
69cp -r -p ./arqs-conf/etc/apache2/ssl/ /etc/apache2/
70
71cp ./arqs-conf/etc/php5/apache2/php.ini /etc/php5/apache2/
72mkdir /php_sessions/ || { echo "Diretorio ja existe. [OK]"; }
73chown -R www-data. /php_sessions/
74chmod -R 770 /php_sessions/
75
76a2ensite expresso
77a2dissite default
78
79# Linha adicionada para resolver alguns warnings quando "apache2ctl configtest"
80HOST=`hostname` ; mv /etc/hosts /etc/hosts.ori ; echo 127.0.0.1 $DOMAIN localhost $HOST  > /etc/hosts ; cat /etc/hosts.ori >> /etc/hosts ; rm /etc/hosts.ori
81
82/etc/init.d/apache2 restart
83
84############################################################################################
85# OPENLDAP
86/etc/init.d/slapd stop
87sed -e "s/LDAP_DN/$LDAP_DN/g" -e "s/LDAP_PWD_MD5/$LDAP_PWD_MD5/g" ./arqs-conf/etc/ldap/slapd.conf.lenny > /etc/ldap/slapd.conf
88cp ./arqs-conf/etc/ldap/schema_utf8/* /etc/ldap/schema/
89cp ./arqs-conf/etc/default/slapd /etc/default/slapd
90
91rm -rf /var/lib/ldap
92mkdir /var/lib/ldap
93
94chown -R openldap:openldap /var/lib/ldap/
95
96/etc/init.d/slapd start
97/etc/init.d/slapd stop
98
99sleep 2
100sed -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
101
102sleep 2
103slapadd -v -l /tmp/expresso.ldif -f /etc/ldap/slapd.conf
104chown -R openldap. /var/lib/ldap/*
105
106sleep 2
107/etc/init.d/slapd start
108rm /tmp/expresso.ldif
109
110############################################################################################
111# CYRUS
112cp ./arqs-conf/etc/imapd.conf /etc/
113cp ./arqs-conf/etc/cyrus.conf /etc/
114sed -e "s/LDAP_DN/$LDAP_DN/g" ./arqs-conf/etc/saslauthd.conf > /etc/saslauthd.conf
115cp ./arqs-conf/etc/default/saslauthd-lenny /etc/default/saslauthd
116
117cp -p ./arqs-conf/usr/bin/cyradm_expresso /usr/bin/
118
119/etc/init.d/saslauthd restart
120sleep 4
121
122/etc/init.d/cyrus2.2 restart
123
124sleep 4
125./arqs-conf/cyrus.pl $LDAP_PWD
126
127############################################################################################
128# POSTFIX
129sed -e "s/LDAP_DN/$LDAP_DN/g" -e "s/DOMAIN/$DOMAIN/g" ./arqs-conf/etc/postfix/main.cf > /etc/postfix/main.cf
130sed -e "s/DOMAIN/$DOMAIN/g" ./arqs-conf/etc/postfix/expresso-dominios > /etc/postfix/expresso-dominios
131cp ./arqs-conf/etc/postfix/master.cf /etc/postfix/
132adduser postfix mail
133/etc/init.d/postfix restart
134postmap /etc/postfix/expresso-dominios
135
136sleep 10
137
138############################################################################################
139# mkpasswd
140mkdir /home/expressolivre || { echo "Diretorio ja existe. [OK]"; }
141cp ./arqs-conf/home/expressolivre/* /home/expressolivre/
142chown -R www-data:www-data /home/expressolivre/
143############################################################################################
144# HEADER_INC_PHP
145sed -e "s/HEADER_PWD/$HEADER_PWD/g" ./arqs-conf/header.inc.php > /var/www/expresso/header.inc.php
146chown www-data:www-data /var/www/expresso/header.inc.php
147
148############################################################################################
149# POSTGRES
150apt-get install -y postgresql postgresql-common postgresql-client postgresql-client-common || { echo "Erro ao iniciar. Sem problema.[OK]";}
151#parando o servico e fazendo backup
152/etc/init.d/postgresql stop
153mv /var/lib/postgresql/8.4/main /var/lib/postgresql/8.4/main_backup_$(date +%s)
154
155su - postgres -c 'export LANG=pt_BR.ISO-8859-1;/usr/lib/postgresql/8.4/bin/initdb -E latin1 -D /var/lib/postgresql/8.4/main'
156
157# Link Simbolico para Server.crt
158ln -sf /etc/ssl/certs/ssl-cert-snakeoil.pem /var/lib/postgresql/8.4/main/server.crt
159
160# Link Simbolico para Server.key
161ln -sf /etc/ssl/private/ssl-cert-snakeoil.key /var/lib/postgresql/8.4/main/server.key
162
163echo "COPIANDO ARQUIVOS DE CONFIGURACAO DO EXPRESSO PARA O PGSQL...."
164cp ./arqs-conf/etc/postgresql/8.4/main/postgresql.conf /etc/postgresql/8.4/main/
165cp ./arqs-conf/etc/postgresql/8.4/main/pg_hba.conf /etc/postgresql/8.4/main/
166
167#restaurando o proprietario para postgres
168chown postgres:postgres /etc/postgresql/8.4/main/postgresql.conf
169chown postgres:postgres /etc/postgresql/8.4/main/pg_hba.conf
170
171/etc/init.d/postgresql start
172
173su - postgres -c 'dropdb expresso'  || { echo "Banco expresso nao existia. [OK]"; }
174su - postgres -c 'createdb -E LATIN1 expresso'  || { echo "Problemas na criacao do banco expresso. [Falhou]"; exit 1;}
175
176sed -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.dump > /tmp/expresso.dump
177
178su - postgres -c 'psql -f /tmp/expresso.dump expresso'
179
180rm /tmp/expresso.dump
181
182##### CREATE WORKFLOW DATABASE
183#cp ./arqs-conf/workflow.dump /tmp
184#su - postgres -c 'psql < /tmp/workflow.dump -U postgres'
185#rm /tmp/workflow.dump
186#### END CREATE
187
188/etc/init.d/postgresql restart
189
190############################################################################################
191echo Acerta permissoes das pastas crls e temp em /var/www/expresso/security:
192chown www-data:www-data /var/www/expresso/security/temp
193chown www-data:www-data /var/www/expresso/logs
194chown -R www-data:www-data /var/www/expresso/security/crls
195chown www-data:www-data /var/www/expresso/security/crl_admin/crl_admin.py
196chmod 755 /var/www/expresso/security/temp
197chmod 755 /var/www/expresso/security/crls
198chmod 755 /var/www/expresso/security/crl_admin/crl_admin.py
199
200############################################################################################
201
202## Mudamos o debconf para high, default do Debian Squeeze.
203debconf-set-selections ./arqs-conf/debconf.high
204## Fim da configuracao do DebConf
205
206dialog --backtitle "$BACKTITLE" --cr-wrap --msgbox "FIM. www.expressolivre.org" 7 55 &&
207
208echo '.'
Note: See TracBrowser for help on using the repository browser.