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