source: trunk/INSTALL/arquivos/scripts/http.sh @ 7503

Revision 7503, 4.2 KB checked in by wmerlotto, 11 years ago (diff)

Ticket #3191 - Alteracoes no instalador, para suportar novo SO e para realizar pequenos ajustes.

Line 
1
2# Servico HTTP (APACHE)
3
4# Parte comum da instalação da "aplicação" do Expresso para todos os SOs.
5# Parametro 1: diretório destino para onde os arquivos do Expresso serão copiados.
6cpexpresso ()
7{
8        # Faz a configuracao da nova API antes de copiar os arquivos
9        config_api
10
11        DIR_EXPRESSO="$1/expresso"
12        # Caso ja exista o diretorio destino, altera o nome
13        [ -e $DIR_EXPRESSO ] && mv $DIR_EXPRESSO $DIR_EXPRESSO-`date +"%F"`
14        # Copia o Expresso para o diretório indicado como parâmetro
15        echo "Copiando arquivos do Expresso Livre..."
16        cp -r "`dirname $PWD`" $DIR_EXPRESSO
17        # Copia o mkntpwd para o home do Expresso
18        mkdir -p /home/expressolivre
19        cp $ARQS/home/expressolivre/* /home/expressolivre/
20       
21        # Requisita a senha
22        get_pass
23        HEADER_PWD=`php $ARQS/scripts/pass.php $LDAP_PWD`
24        sed -e "s/HEADER_PWD/$HEADER_PWD/g" -e "s|EXPRESSO_DIR|$DIR_EXPRESSO|g" $ARQS/header.inc.php > $DIR_EXPRESSO/header.inc.php
25        chmod 640 $DIR_EXPRESSO/header.inc.php
26       
27        # Requisita o domino para corrigir o hosts do servidor, utilizado pelo apache
28        get_org
29        # Faz backup do hosts
30        cp -f /etc/hosts /etc/hosts.`date "+%s"` || log_erro "Erro ao copiar o /etc/hosts!"
31        NOVOHOSTS=`mktemp`
32        echo "127.0.0.1 $DOMAIN localhost `hostname`" > $NOVOHOSTS
33        cat /etc/hosts >> $NOVOHOSTS || log_erro "Erro ao agregar o /etc/hosts!"
34        mv -f $NOVOHOSTS /etc/hosts
35       
36        #Script para o CRON
37        sed -e "s|EXPRESSO_DIR|$DIR_EXPRESSO|g" $ARQS/expresso-cron > /tmp/expresso-cron
38}
39
40# Configura os arquivos da nova API
41config_api ()
42{
43        # Para pegar a organizacao e principalmente o LDAP_DN
44        get_org
45        # A principio so sera necessario configurar o LDAP
46        ARQ_LDAP="../prototype/config/OpenLDAP.srv"
47        mv $ARQ_LDAP "$ARQ_LDAP.orig"
48        cat "$ARQ_LDAP.orig" | sed -e "s/LDAP_DN/$LDAP_DN/g" > $ARQ_LDAP
49}
50
51http_debian ()
52{
53        # Instala o apache2 juntamente com o PHP5 e seus respectivos módulos
54        apt-get install -y apache2-mpm-prefork libapache2-mod-php5 apache2-utils \
55                php5 php5-common php5-dev php5-gd php5-imap php5-ldap php5-pgsql php5-cgi php5-cli php5-curl php5-xmlrpc php5-memcache php5-pspell \
56                libgv-php5 zip unzip memcached
57        # Copia os arquivos do Expresso Livre
58        cpexpresso "/var/www"
59        chown -R www-data:www-data /var/www/expresso /home/expressolivre
60
61        # descomente para gerar o certificado para o https
62        #apache2-ssl-certificate;
63        a2enmod rewrite
64        a2enmod ssl
65
66        # Ativa o script do CRON para o Debian e similares
67        sed -e "s|#DEBIAN||g" /tmp/expresso-cron > /etc/cron.d/expresso
68}
69
70http_debian_6 ()
71{
72        http_debian
73        # O nome do pacote do memcache no Debian é diferente do Ubuntu
74        apt-get -y install libmemcached5 || log_erro "Pacote nao encontrado"
75        # Copia a configuração do servidor apache2
76        cp -a debian/squeeze/etc/apache2/apache2.conf /etc/apache2/
77        cp -a debian/squeeze/etc/apache2/ports.conf /etc/apache2/
78        cp -a debian/squeeze/etc/apache2/sites-available/expresso /etc/apache2/sites-available/
79        cp -a debian/squeeze/etc/apache2/ssl/ /etc/apache2/
80
81        a2ensite expresso
82        a2dissite default
83
84        # Copia a configuração do PHP
85        #cp -a debian/squeeze/etc/php5/apache2/php.ini /etc/php5/apache2/
86        /etc/init.d/cron restart
87        /etc/init.d/apache2 restart
88
89        ## Alteracao para compatibilizar o diretorio de sessao do PHP
90        # o diretorio padrao da sessao do PHP eh do Centos.
91        sed -e "s|/dev/shm|/var/lib/php5|g" ../.htaccess > $DIR_EXPRESSO/.htaccess
92}
93
94http_ubuntu_1204 ()
95{
96        http_debian_6
97        # O nome do pacote do memcache no Ubuntu é diferente do Debian
98        apt-get -y install libmemcached6
99
100        cp -a ubuntu/12.04/etc/apache2/apache2.conf /etc/apache2/
101        /etc/init.d/cron restart
102        /etc/init.d/apache2 restart
103}
104
105http_rhel ()
106{
107        yum -y install httpd mod_ssl \
108                php php-cli php-ldap php-pgsql php-imap php-mbstring php-gd php-xml \
109                php-pecl-memcache graphviz-php php-pspell \
110                unzip zip memcached libmemcached
111
112        cpexpresso "/var/www/html"
113        chown -R apache:apache /var/www/html/expresso /home/expressolivre
114
115        chkconfig httpd on
116
117        # Ativa o script do CRON para o RedHat e similares
118        sed -e "s|#CENTOS||g" /tmp/expresso-cron > /etc/cron.d/expresso
119}
120
121http_rhel_6 ()
122{
123        http_rhel
124        # Para pegar ou definir o DOMAIN
125        get_org
126
127        cp -a rhel/6/etc/httpd/conf/httpd.conf /etc/httpd/conf/
128        sed -e "s/DOMAIN/$DOMAIN/g" rhel/6/etc/httpd/conf.d/expresso.conf > /etc/httpd/conf.d/expresso.conf
129        cp -a rhel/6/etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/
130        /etc/init.d/crond restart
131        service httpd restart
132}
133
Note: See TracBrowser for help on using the repository browser.