source: publico/ILSAPL/install/2.4-beta/install.sh @ 5317

Última Alteração nesse arquivo desde 5317 foi 5317, incluída por lucianodefazio, 8 anos atrás

Instalador SAPL 2.4 - compilação e instalação do lxml via pacote

File size: 33.3 KB
Linha 
1#!/bin/sh
2#
3# Unified SAPL installer build script
4# Maintainer: Jean Rodrigo Ferri (jeanferri at interlegis.gov.br)
5# Original Author: Kamal Gill (kamalgill at mac.com)
6#
7# Note: this script must be run as root
8#
9
10# Configure SAPL installation options
11INSTALL_HOME=/var/interlegis/SAPL-2.4
12EFFECTIVE_USER=zope
13LOCAL_HOME=$INSTALL_HOME
14PY_HOME=$INSTALL_HOME/Python-2.4
15SITECUSTOMIZE_FILE=$PY_HOME/lib/python2.4/sitecustomize.py
16PY=$PY_HOME/bin/python2.4
17ZOPE_HOME=$INSTALL_HOME/Zope-2.9
18#MYSQL_HOME=$INSTALL_HOME/mysql
19SITE_PACKAGES=$PY_HOME/lib/python2.4/site-packages
20INSTANCE_HOME=$INSTALL_HOME/instances
21SAPL_HOME=$INSTANCE_HOME/sapl24
22#PYTHON_EGG_CACHE=$SAPL_HOME/var/.python-eggs
23PRODUCTS_HOME=$SAPL_HOME/Products
24PWFILE=$INSTALL_HOME/adminPassword.txt
25SAPL_STARTUP_SCRIPT=$SAPL_HOME/bin/startsapl.sh
26SAPL_SHUTDOWN_SCRIPT=$SAPL_HOME/bin/shutdownsapl.sh
27SAPL_RESTART_SCRIPT=$SAPL_HOME/bin/restartsapl.sh
28RECEIPTS_HOME=$INSTALL_HOME/receipts
29
30#export PYTHON_EGG_CACHE
31
32# Include the following tarballs in the packages/ directory in the bundle
33PYTHON_TB=Python-2.4.6.tar.bz2
34PYTHON_DIR=Python-2.4.6
35PYXML_TB=PyXML-0.8.4.tar.bz2
36PYXML_DIR=PyXML-0.8.4
37REPLAB_TB=reportlab_2_0.tar.bz2
38REPLAB_DIR=reportlab_2_0
39JPEG_TB=jpeg-6b.tar.bz2
40JPEG_DIR=jpeg-6b
41ZLIB_TB=zlib-1.2.3.tar.bz2
42ZLIB_DIR=zlib-1.2.3
43PIL_TB=Imaging-1.1.6.tar.bz2
44PIL_DIR=Imaging-1.1.6
45ZOPE_TB=Zope-2.9.12-final.tar.bz2
46ZOPE_DIR=Zope-2.9.12-final
47SAPL_TB=SAPL.tar.bz2
48SAPL_DIR=ILSAPL
49CMF_TB=CMF-1.6.4-final.tar.bz2
50CMF_DIR=CMF-1.6.4-final
51TXNG2_TB=TextIndexNG-2.2.0.tar.bz2
52TXNG2_DIR=TextIndexNG2
53HSCRIPTS_TB=HelperScripts.tar.bz2
54HSCRIPTS_DIR=HelperScripts
55ETREE_TB=elementtree-1.2.6-20050316.tar.bz2
56ETREE_DIR=elementtree-1.2.6-20050316
57SETUP_TB=setuptools-0.6c7-py2.4.tar.bz2
58LIBXML2_TB=libxml2-2.7.8.tar.bz2
59LIBXML2_DIR=libxml2-2.7.8
60LIBXSLT_TB=libxslt-1.1.26.tar.bz2
61LIBXSLT_DIR=libxslt-1.1.26
62PYLIBXML2_TB=libxml2-python-2.6.21.tar.bz2
63PYLIBXML2_DIR=libxml2-python-2.6.21
64MYSQLPYTHON_TB=MySQL-python-1.2.1.tar.bz2
65MYSQLPYTHON_DIR=MySQL-python-1.2.1
66TRML2PDF_TB=trml2pdf-1.2.tar.bz2
67TRML2PDF_DIR=trml2pdf
68SDE_TB=StructuredDoc.tar.bz2
69SDE_DIR=StructuredDoc
70ZMYSQLDA_TB=ZMySQLDA-2.0.8.tar.bz2
71ZMYSQLDA_DIR=ZMySQLDA
72LXML2_TB=lxml-2.3.1.tar.bz2
73LXML2_DIR=lxml-2.3.1
74PYOAI_TB=pyoai-2.4.3.tar.bz2
75PYOAI_DIR=pyoai-2.4.3
76
77# Capture current working directory for build script
78PWD=`pwd`
79
80PACKAGES_DIR=packages
81PKG=$PWD/$PACKAGES_DIR
82
83GNU_TAR=`which tar`
84GCC=`which gcc`
85GPP=`which g++`
86GNU_MAKE=`which make`
87TAR_BZIP2_FLAG="--bzip2"
88#TAR_BZIP2_FLAG="-j"
89
90# The Unified Installer requires root privileges to install
91ROOT_INSTALL=1
92
93#####
94# Verifica se existe uma instalacao do SAPL 2.2
95if [ -d /var/lib/zope2.8/instance/sapl ]; then
96    INST_PATH="/var/lib/zope2.8/instance/sapl"
97else
98    INST_PATH="/var/lib/zope2.9/instance/sapl"
99fi
100
101#####
102# Verifica se existe uma instalacao do SAPL 2.3
103if [ -d /var/interlegis/SAPL-2.3/ ]; then
104    INST_PATH="/var/interlegis/SAPL-2.3"
105else
106    INST_PATH="/var/interlegis/SAPL-2.3"
107fi
108
109if [ -e $INST_PATH ]; then
110    echo ""
111    echo -e "\033[1;31mUma instalacao do SAPL 2.3/2.2/2.1 foi detectada\033[m"
112    echo -e "\033[1;31mExecute a instalacao descrita em:\033[m"
113    echo -e "\033[1;31mhttp://colab.interlegis.gov.br/wiki/HOWTO-Migracao22-23\033[m"
114    echo -e "\033[1;31mou\033[m"
115    echo -e "\033[1;31mhttp://colab.interlegis.gov.br/wiki/HOWTO-Migracao23-24\033[m"
116    echo -e "\033[1;31mDependendo da sua versao\033[m"
117    echo -e "\033[1;31mRoteiro alternativo\033[m"
118    echo -e "\033[1;31mInstalacao abortada\033[m"
119    echo ""
120    exit 1
121fi
122
123#################################################################
124# Exit if potential conflict with existing install at $INSTALL_HOME
125if [ -e $INSTALL_HOME ]
126then
127    echo ""
128    echo -e "\033[1;31mUma instalacao anterior foi detectada em $INSTALL_HOME.\033[m"
129    echo -e "\033[1;31mInstalacao abortada\033[m"
130    echo ""
131    exit 1
132fi
133
134# Verifica se existe o mysql server está sendo executado
135
136mysql_pid=`ps ax | grep mysqld_safe  | grep \/bin\/ | cut -d " " -f1`
137mysql_port=`netstat -ant | grep 3306 | cut -d ':' -f 2 | cut -d ' ' -f 1`
138
139
140if [ ! $mysql_pid ] && [ ! $mysql_port ]; then
141
142    echo ""
143    echo -e "\033[1;31mO Mysql Server não está em execução\033[m"
144    echo -e "\033[1;31mPara continuar a instalação, o MySQL deve estar em execução.\033[m"
145    echo -e "\033[1;31mInstalação abortada\033[m"
146    echo ""
147    exit 1
148fi
149
150# Caso esteja sendo executado, pergunta o usuário e senha
151
152ok=0
153while [ $ok = 0 ]; do
154
155    echo "Digite o nome do usuário MySQL: "
156    read usuario
157
158    if [ -z $usuario ]; then
159        echo -e "\033[1;31mO usuário não pode ser em branco!\033[m";
160    else
161        ok=1
162    fi
163   
164done
165
166echo "Digite a senha do usuário admin (root) do MySQL: "
167read senha
168
169echo "Testando usuário e senha: "
170
171if [ -z $senha ]; then
172    mysqladmin status -u $usuario > /dev/null 2>&1
173else
174    mysqladmin status -u $usuario --password=$senha > /dev/null 2>&1
175fi
176
177if [ $? -gt 0 ]; then
178
179    echo ""
180    echo -e "\033[1;31mO usuário e/ou senha estão incorretos!\033[m";
181    echo -e "\033[1;31mInstalacao abortada\033[m"
182    echo ""
183    exit 1
184fi
185
186# Verifica se existe o banco 'interlegis'
187if [ -z $senha ]; then
188    mysqlcheck interlegis -u $usuario > /dev/null 2>&1
189else
190    mysqlcheck interlegis -u $usuario --password=$senha > /dev/null 2>&1
191fi
192
193if [ "$?" = "0" ]; then
194
195    echo ""
196    echo -e "\033[1;31mUma instalacao do SAPL 2.3/2.2/2.1 foi detectada\033[m"
197    echo -e "\033[1;31mO instalador encontrou o database 'interlegis' no servidor MySQL\033[m"
198    echo -e "\033[1;31mExecute a instalacao descrita em:\033[m"
199    echo -e "\033[1;31mhttp://colab.interlegis.gov.br/wiki/HOWTO-Migracao22-23\033[m"
200    echo -e "\033[1;31mou\033[m"
201    echo -e "\033[1;31mhttp://colab.interlegis.gov.br/wiki/HOWTO-Migracao23-24\033[m"
202    echo -e "\033[1;31mDependendo da sua versao\033[m"
203    echo -e "\033[1;31mRoteiro alternativo\033[m"
204    echo -e "\033[1;31mInstalacao abortada\033[m"
205    echo ""
206    exit 1
207fi
208
209############################
210# Configure zlib and libjpeg
211#
212# This install requires the zlib and libjpeg libraries, which are
213# usually installed as system libraries.
214# Set the options below to
215#   auto -   to have this program determine whether or not you need the
216#            library installed, and where.
217#   global - to force install to /usr/local/ (requires root)
218#   local  - to force install to $INSTALL_HOME (or $LOCAL_HOME) for static link
219#   no     - to force no install
220INSTALL_ZLIB=auto
221INSTALL_JPEG=auto
222
223# library need determination
224if [ $INSTALL_ZLIB = "auto" ]
225then
226    # check for zconf.h, zlib.h, libz.[so|a]
227    if [ -e /usr/include/zconf.h ] || [ -e /usr/local/include/zconf.h ]
228    then
229        HAVE_ZCONF=1
230        #echo have zconf
231    else
232        HAVE_ZCONF=0
233        #echo no zconf
234    fi
235        if [ -e /usr/include/zlib.h ] || [ -e /usr/local/include/zlib.h ]
236        then
237                HAVE_ZLIB=1
238                #echo have zlib
239        else
240                HAVE_ZLIB=0
241                #echo no zlib
242        fi
243        if [ -e /usr/lib/libz.so ] || [ -e /usr/local/lib/libz.so ] || \
244       [ -e /usr/lib/libz.dylib ] || [ -e /usr/local/lib/libz.dylib ] || \
245       [ -e /usr/lib/libz.a ] || [ -e /usr/local/lib/libz.a ]
246        then
247                HAVE_LIBZ=1
248                #echo have libz
249        else
250                HAVE_LIBZ=0
251                #echo no libz
252        fi
253    if [ $HAVE_ZCONF -eq 1 ] && [ $HAVE_ZLIB -eq 1 ] && [ $HAVE_LIBZ -eq 1 ]
254    then
255        INSTALL_ZLIB=no
256        #echo do not install zlib
257    fi
258    if [ $INSTALL_ZLIB = "auto" ] && [ $ROOT_INSTALL -eq 1 ]
259    then
260        INSTALL_ZLIB="global"
261    fi
262    if [ $INSTALL_ZLIB = "auto" ]
263    then
264        INSTALL_ZLIB="local"
265    fi
266    echo -e "\033[32mzlib installation: $INSTALL_ZLIB\033[m"
267fi
268
269if [ $INSTALL_JPEG = "auto" ]
270then
271    # check for jpeglib.h and libjpeg.[so|a]
272    if [ -e /usr/include/jpeglib.h ] || [ -e /usr/local/include/jpeglib.h ]
273    then
274        HAVE_JPEGH=1
275    else
276        HAVE_JPEGH=0
277    fi
278    if [ -e /usr/lib/libjpeg.so ] || [ -e /usr/local/lib/libjpeg.so ] || \
279       [ -e /usr/lib/libjpeg.dylib ] || [ -e /usr/local/lib/libjpeg.dylib ] || \
280       [ -e /usr/lib/libjpeg.a ] || [ -e /usr/local/lib/libjpeg.a ]
281    then
282        HAVE_LIBJPEG=1
283    else
284        HAVE_LIBJPEG=0
285    fi
286    if [ $HAVE_JPEGH -eq 1 ] && [ $HAVE_LIBJPEG -eq 1 ]
287    then
288        INSTALL_JPEG="no"
289    fi
290    if [ $INSTALL_JPEG = "auto" ] && [ $ROOT_INSTALL -eq 1 ]
291    then
292        INSTALL_JPEG="global"
293    fi
294    if [ $INSTALL_JPEG = "auto" ]
295    then
296        INSTALL_JPEG="local"
297    fi
298    echo -e "\033[32mlibjpeg installation: $INSTALL_JPEG\033[m"
299fi
300
301
302#############################
303# Preflight dependency checks
304#
305# Abort install if not running as root
306if [ `whoami` != root ] && [ $ROOT_INSTALL -eq 1 ]
307then
308    echo "Este script de instalação precisa ser executado como root.  Uso: sudo ./install.sh  ( or su ; ./install.sh )."
309    exit 1
310fi
311
312# Abort install if no gcc
313if [ ! -e /usr/bin/gcc ]
314then
315    echo "Nota: gcc é necessário para a instalação. Saindo agora."
316    exit 1
317fi
318
319# Abort install if no g++
320if [ ! -e /usr/bin/g++ ]
321then
322    echo "Nota: g++ é necessário para a instalação. Saindo agora."
323    exit 1
324fi
325
326# Abort install if no make
327if [ ! -e /usr/bin/make ]
328then
329    echo "Nota: make é necessário para a instalação. Saindo agora."
330    exit 1
331fi
332
333# Abort install if this script is not run from within it's parent folder
334if [ ! -e $PACKAGES_DIR ]
335then
336    echo "Nota: Este script de instalação precisa ser executado dentro de um diretório.  Uso: sudo ./install.sh  (or su ; ./install.sh)"
337    exit 1
338fi
339
340
341#################################
342# Install will begin in 3 seconds
343echo ""
344echo -e "\033[32mInstalando SAPL 2.4-beta em $INSTALL_HOME\033[m"
345sleep 3
346echo ""
347
348
349##################
350# build zlib 1.2.3
351# Note that, even though we're building static libraries, python
352# is going to try to build a shared library for it's own use.
353# The "-fPIC" flag is thus required for some platforms.
354if [ "X$INSTALL_ZLIB" = "Xglobal" ]
355then
356    echo "Compiling and installing zlib ..."
357    cd $PKG
358    $GNU_TAR $TAR_BZIP2_FLAG -xf $ZLIB_TB
359    chmod -R 775 $ZLIB_DIR
360    cd $ZLIB_DIR
361    CFLAGS="-fPIC" ./configure
362    $GNU_MAKE test
363    $GNU_MAKE install
364    cd $PKG
365    if [ -d $ZLIB_DIR ]
366    then
367        rm -rf $ZLIB_DIR
368    fi
369elif [ "X$INSTALL_ZLIB" = "Xlocal" ]
370then
371    echo "Compiling and installing local zlib ..."
372    cd $PKG
373    $GNU_TAR $TAR_BZIP2_FLAG -xf $ZLIB_TB
374    chmod -R 775 $ZLIB_DIR
375    cd $ZLIB_DIR
376    CFLAGS="-fPIC" ./configure --prefix=$LOCAL_HOME
377    $GNU_MAKE test
378    $GNU_MAKE install
379    cd $PKG
380    if [ -d $ZLIB_DIR ]
381    then
382        rm -rf $ZLIB_DIR
383    fi
384    if [ ! -e "$LOCAL_HOME/lib/libz.a" ]
385    then
386        echo "Install of local libz failed"
387        exit 1
388    fi
389else
390    echo "Skipping zlib compile and install"
391fi
392
393
394###################
395# build libjpeg v6b
396if [ "X$INSTALL_JPEG" = "Xglobal" ]
397then
398    echo "Compiling and installing jpeg system libraries ..."
399
400    # It's not impossible that the /usr/local hierarchy doesn't
401    # exist. The libjpeg install will not create it itself.
402    # (The zlib install will, but we can't count on it having
403    # run, since we've made it an option.)
404    if [ ! -e /usr/local ]
405    then
406        mkdir /usr/local
407    fi
408    if [ ! -e /usr/local/bin ]
409    then
410        mkdir /usr/local/bin
411    fi
412    if [ ! -e /usr/local/include ]
413    then
414        mkdir /usr/local/include
415    fi
416    if [ ! -e /usr/local/lib ]
417    then
418        mkdir /usr/local/lib
419    fi
420    if [ ! -e /usr/local/man ]
421    then
422        mkdir /usr/local/man
423    fi
424    if [ ! -e /usr/local/man/man1 ]
425    then
426        mkdir /usr/local/man/man1
427    fi
428
429    cd $PKG
430    $GNU_TAR $TAR_BZIP2_FLAG -xf $JPEG_TB
431    chmod -R 775 $JPEG_DIR
432    cd $JPEG_DIR
433    # Oddities to workaround: on Mac OS X, using the "--enable-static"
434    # flag will cause the make to fail. So, we need to manually
435    # create and place the static library.
436    ./configure CFLAGS='-fPIC'
437    $GNU_MAKE
438    $GNU_MAKE install
439    ranlib libjpeg.a
440    cp libjpeg.a /usr/local/lib
441    cp *.h /usr/local/include
442    cd $PKG
443    if [ -d $JPEG_DIR ]
444    then
445            rm -rf $JPEG_DIR
446    fi
447elif [ "X$INSTALL_JPEG" = "Xlocal" ]
448then
449    echo "Compiling and installing jpeg local libraries ..."
450
451    mkdir $LOCAL_HOME/lib
452    mkdir $LOCAL_HOME/bin
453    mkdir $LOCAL_HOME/include
454    mkdir $LOCAL_HOME/man
455    mkdir $LOCAL_HOME/man/man1
456
457    cd $PKG
458    $GNU_TAR $TAR_BZIP2_FLAG -xf $JPEG_TB
459    chmod -R 775 $JPEG_DIR
460    cd $JPEG_DIR
461    # Oddities to workaround: on Mac OS X, using the "--enable-static"
462    # flag will cause the make to fail. So, we need to manually
463    # create and place the static library.
464    ./configure CFLAGS='-fPIC' --prefix=$LOCAL_HOME
465    $GNU_MAKE
466    $GNU_MAKE install
467    # --enable-static flag doesn't work on OS X, make sure
468    # we get an install anyway
469    if [ ! -e "$LOCAL_HOME/lib/libjpeg.a" ]
470    then
471        ranlib libjpeg.a
472        cp libjpeg.a $LOCAL_HOME/lib
473        cp *.h $LOCAL_HOME/include
474    fi
475
476    if [ ! -e "$LOCAL_HOME/lib/libjpeg.a" ]
477    then
478        echo "Local install of libjpeg has failed"
479        exit 1
480    fi
481
482    cd $PKG
483    if [ -d $JPEG_DIR ]
484    then
485            rm -rf $JPEG_DIR
486    fi
487else
488    echo "Skipping libjpeg compile/install"
489fi
490
491
492######################################
493# Build Python (with readline support)
494# note: Install readline before running this script
495echo -e "\033[32mInstalando Python 2.4.6...\033[m"
496cd $PKG
497$GNU_TAR -jxf $PYTHON_TB
498chmod -R 775 $PYTHON_DIR
499cd $PYTHON_DIR
500# Look for Leopard
501uname -v | grep "Darwin Kernel Version 9" > /dev/null
502if [ "$?" = "0" ]; then
503    # patch for Leopard setpgrp
504    sed -E -e "s|(CPPFLAGS=.+)|\\1 -D__DARWIN_UNIX03|" -i.bak Makefile.pre.in
505    # if /opt/local is available, make sure it's included in the component
506    # build so that we can get fixed readline lib
507    if [ -d /opt/local/include ] && [ -d /opt/local/lib ]; then
508        sed -E -e "s|#(add_dir_to_list\(self\.compiler\..+_dirs, '/opt/local/)|\\1|" -i.bak setup.py
509    fi
510fi
511./configure \
512    --prefix=$PY_HOME \
513    --with-readline \
514    --with-zlib \
515    --disable-tk \
516    --with-gcc="$GCC"
517make
518make install
519# make sistecustomize.py file
520touch $SITECUSTOMIZE_FILE
521echo "import sys" >> "$SITECUSTOMIZE_FILE"
522echo "sys.setdefaultencoding('iso-8859-1')" >> "$SITECUSTOMIZE_FILE"
523
524cd $PKG
525if [ -d $PYTHON_DIR ]
526then
527    rm -rf $PYTHON_DIR
528fi
529
530#########################
531# install ReportLab 2.0
532echo -e "\033[32mInstalando ReportLab (PDF toolkit)...\033[m"
533cd $PKG
534$GNU_TAR -jxf $REPLAB_TB
535mv $REPLAB_DIR/reportlab $SITE_PACKAGES/reportlab
536cd $PKG
537if [ -d $REPLAB_DIR ]
538then
539    rm -rf $REPLAB_DIR
540fi
541
542########################
543# install trml2pdf 1.2
544echo -e "\033[32mInstalando trml2pdf...\033[m"
545cd $PKG
546$GNU_TAR -jxf $TRML2PDF_TB
547mv $TRML2PDF_DIR $SITE_PACKAGES/$TRML2PDF_DIR
548cd $PKG
549if [ -d $TRML2PDF_DIR ]
550then
551    rm -rf $TRML2PDF_DIR
552fi
553
554###################
555# build PyXML 0.8.4
556echo -e "\033[32mCompilando e instalando PyXML ...\033[m"
557cd $PKG
558$GNU_TAR -jxf $PYXML_TB
559chmod -R 775 $PYXML_DIR
560cd $PYXML_DIR
561$PY ./setup.py build
562$PY ./setup.py install
563cd $PKG
564if [ -d $PYXML_DIR ]
565then
566    rm -rf $PYXML_DIR
567fi
568
569#########################
570# install setuptools
571echo -e "\033[32mInstalando setuptools via ez_setup...\033[m"
572cd $PKG
573$GNU_TAR -jxf $SETUP_TB
574$PY ./ez_setup.py -l
575if [ -e setup*.egg ]
576then
577    rm -rf setup*.egg
578fi
579rm ez_setup.py
580
581#################
582# build PIL 1.1.6
583echo -e "\033[32mCompilando e instalando PIL ...\033[m"
584cd $PKG
585$GNU_TAR -jxf $PIL_TB
586chmod -R 775 $PIL_DIR
587cd $PIL_DIR
588$PY ./setup.py build_ext -i
589$PY ./selftest.py
590$PY ./setup.py install
591cd $PKG
592if [ -d $PIL_DIR ]
593then
594    rm -rf $PIL_DIR
595fi
596
597#####################
598# install ElementTree
599echo -e "\033[32mInstalando ElementTree ...\033[m"
600cd $PKG
601$GNU_TAR -jxf $ETREE_TB
602chmod -R 775 $ETREE_DIR
603cd $ETREE_DIR
604$PY ./setup.py build
605$PY ./setup.py install
606cd $PKG
607if [ -d $ETREE_DIR ]
608then
609        rm -rf $ETREE_DIR
610fi
611
612#################
613# install libxml2
614echo -e "\033[32mInstalando libxml2 ...\033[m"
615cd $PKG
616$GNU_TAR -jxf $LIBXML2_TB
617chmod -R 775 $LIBXML2_DIR
618cd $LIBXML2_DIR
619./configure --with-python=$PY
620make
621make install
622cd $PKG
623if [ -d $LIBXML2_DIR ]
624then
625    rm -rf $LIBXML2_DIR
626fi
627
628#################
629# install libxslt
630echo -e "\033[32mInstalando libxslt ...\033[m"
631cd $PKG
632$GNU_TAR -jxf $LIBXSLT_TB
633chmod -R 775 $LIBXSLT_DIR
634cd $LIBXSLT_DIR
635./configure --with-python=$PY --prefix=/usr/local --with-libxml-prefix=/usr/local --with-libxml-include-prefix=/usr/local/include --with-libxml-libs-prefix=/usr/local/lib
636make
637make install
638cd $PKG
639if [ -d $LIBXSLT_DIR ]
640then
641    rm -rf $LIBXSLT_DIR
642fi
643
644########################
645# Install libxml2-python
646# Properly configure libxml2-python to use our libxml2/libxslt
647echo -e "\033[32mConfiguring libxml2-python ...\033[m"
648cd $PKG
649$GNU_TAR -jxf $PYLIBXML2_TB
650chmod -R 775 $PYLIBXML2_DIR
651cd $PYLIBXML2_DIR
652# Point libxml2-python to /usr/local/lib and /usr/local/include for libxml2/libxslt headers
653# escape string for sed-compatible string replacement (warning: insane hack ahead)
654# replace ROOT with /usr/local (to bypass OSX's libxml2/libxslt)
655FIND="ROOT = r'/usr'"
656REPLACE="ROOT = r'/usr/local'"
657ESCAPED_REPLACE=`echo $REPLACE | sed 's/\//\\\@/g' | tr @ /`
658# replace /usr/include with /usr/local/include (to bypass OSX's libxml2/libxslt)
659FIND2="/usr/include"
660REPLACE2="/usr/local/include"
661ESCAPED_REPLACE2=`echo $REPLACE2 | sed 's/\//\\\@/g' | tr @ /`
662ESCAPED_REPLACE3=`echo $FIND2 | sed 's/\//\\\@/g' | tr @ /`
663FILE=setup.py
664mv $FILE $FILE.tmp
665cat $FILE.tmp | sed "s/^.*ROOT = r\'\/usr\'.*$/$ESCAPED_REPLACE/g" | \
666sed "s/^.*\/usr\/include.*$/\"$ESCAPED_REPLACE2\", \"$ESCAPED_REPLACE3\",/g" > $FILE
667rm $FILE.tmp
668# With the proper libraries in setup.py, now install libxml2-python
669$PY ./setup.py install
670cd $PKG
671if [ -d $PYLIBXML2_DIR ]
672then
673    rm -rf $PYLIBXML2_DIR
674fi
675$PY_HOME/bin/python -c "import libxml2"
676if [ $? -gt 0 ]
677then
678    echo "Python libxml2 support is missing; something went wrong in the libxml2 build;"
679    echo "probably missing development headers."
680    echo "This is an optional component. It's absence will result in a log warning."
681fi
682
683#################
684# install lxml
685echo -e "\033[32mCompilando e Instalando lxml-2.3.1 ...\033[m"
686cd $PKG
687$GNU_TAR -jxf $LXML2_TB
688chmod -R 775 $LXML2_DIR
689cd $LXML2_DIR
690$PY ./setup.py build --with-xslt-config=/usr/local/include/libxslt
691$PY ./setup.py install
692cd $PKG
693if [ -d $LXML2_DIR ]
694then
695    rm -rf $LXML2_DIR
696fi
697
698
699#########################
700# install PyOAI 2.4.3
701echo -e "\033[32mCompilando e instalando PyOAI (OAI-PMH)...\033[m"
702cd $PKG
703$GNU_TAR -jxf $PYOAI_TB
704chmod -R 775 $PYOAI_DIR
705cd $PYOAI_DIR
706$PY ./setup.py build
707$PY ./setup.py install
708cd $PKG
709if [ -d $PYOAI_DIR ]
710then
711    rm -rf $PYOAI_DIR
712fi
713
714###################
715# build Zope 2.9.12
716echo -e "\033[32mCompilando e instalando Zope 2.9.12 ...\033[m"
717cd $PKG
718$GNU_TAR -jxf $ZOPE_TB
719chmod -R 775 $ZOPE_DIR
720cd $ZOPE_DIR
721./configure --with-python=$PY --prefix=$ZOPE_HOME
722make
723make install
724cd $PKG
725if [ -d $ZOPE_DIR ]
726then
727    rm -rf $ZOPE_DIR
728fi
729
730###################
731# install MySQL-python
732echo -e "\033[32mCompilando e instalando MySQL-python ...\033[m"
733cd $PKG
734$GNU_TAR -jxf $MYSQLPYTHON_TB
735cd $MYSQLPYTHON_DIR
736$PY setup.py build
737$PY setup.py install
738if [ $? -gt 0 ]; then
739    echo ""
740    echo -e "\033[1;31mErro na compilação do python-mysql!\033[m";
741    echo -e "\033[1;31mInstalação abortada!\033[m";
742    echo ""
743    exit 1
744fi
745cd $PKG
746if [ -d $MYSQLPYTHON_DIR ]
747then
748    rm -rf $MYSQLPYTHON_DIR
749fi
750
751######################
752# Postinstall steps
753######################
754
755##########################
756# Generate random password
757echo -e "\033[32mGenerando senha randomica ...\033[m"
758cd $PKG
759$GNU_TAR -jxf $HSCRIPTS_TB
760chmod -R 775 $HSCRIPTS_DIR
761cd $HSCRIPTS_DIR
762PASSWORD_SCRIPT=./generateRandomPassword.py
763PASSWORD=`$PY $PASSWORD_SCRIPT`
764cd $PKG
765
766
767####################
768# Create SAPL instance
769
770echo -e "\033[32mCriando instancia SAPL ...\033[m"
771$ZOPE_HOME/bin/mkzopeinstance.py --dir=$SAPL_HOME --user=admin:$PASSWORD
772
773#########################################
774# Configure mount point
775echo "<zodb_db documentos>
776    # Zodb para conter documento do sapl
777    <filestorage>
778      path $SAPL_HOME/var/DocumentosSapl.fs
779    </filestorage>
780    mount-point /sapl/sapl_documentos
781</zodb_db>
782
783#<zodb_db antigo>
784# Mount-point apontando para um Data.fs
785# de versão anterior
786#    <filestorage>
787#      path $SAPL_HOME/old/Data.fs
788#    </filestorage>
789#    mount-point /sapl_old
790#</zodb_db>" >> $SAPL_HOME/etc/zope.conf
791
792########################################
793# Criando a pasta 'old' para a migracao
794
795#if [ ! -d $SAPL_HOME/old ]; then
796#    mkdir $SAPL_HOME/old
797#    chown zope:zope $SAPL_HOME/old
798#fi
799
800#####################################
801# Set effective-user in etc/zope.conf
802# set user in ZEO server
803mv $SAPL_HOME/etc/zope.conf $SAPL_HOME/etc/zope.conf.tmp
804cat $SAPL_HOME/etc/zope.conf.tmp | sed 's/^.*#.*effective-user.*chrism.*$/effective-user zope/g'> $SAPL_HOME/etc/zope.conf
805rm $SAPL_HOME/etc/zope.conf.tmp
806
807###############################################################
808# Extract and move SDE tarball to Products folder of Instance
809echo -e "\033[32mExtraindo SDE tarball ...\033[m"
810cp $PKG/$SDE_TB $INSTALL_HOME/$SDE_TB
811cd $INSTALL_HOME
812$GNU_TAR -jxf ./$SDE_TB
813rm $INSTALL_HOME/$SDE_TB
814mv $INSTALL_HOME/$SDE_DIR $PRODUCTS_HOME
815chmod -R 775 $PRODUCTS_HOME
816cd $PKG
817
818###############################################################
819# Extract and move ZMySQLDA tarball to Products folder of Instance
820echo -e "\033[32mExtraindo ZMySQLDA tarball ...\033[m"
821cp $PKG/$ZMYSQLDA_TB $INSTALL_HOME/$ZMYSQLDA_TB
822cd $INSTALL_HOME
823$GNU_TAR -jxf ./$ZMYSQLDA_TB
824rm $INSTALL_HOME/$ZMYSQLDA_TB
825mv $INSTALL_HOME/$ZMYSQLDA_DIR $PRODUCTS_HOME
826chmod -R 775 $PRODUCTS_HOME
827cd $PKG
828
829###############################################################
830# Extract and move CMFL tarball to Products folder of Instance
831echo -e "\033[32mExtraindo CMF tarball ...\033[m"
832cp $PKG/$CMF_TB $INSTALL_HOME/$CMF_TB
833cd $INSTALL_HOME
834$GNU_TAR -jxf ./$CMF_TB
835rm $INSTALL_HOME/$CMF_TB
836mv $INSTALL_HOME/$CMF_DIR/* $PRODUCTS_HOME
837if [ -d $CMF_DIR ]
838then
839    rm -rf $CMF_DIR
840fi
841chmod -R 775 $PRODUCTS_HOME
842cd $PKG
843
844######################
845# Install TextIndexNG2
846echo -e "\033[32mInstalando TextIndexNG2\033[m"
847cp $PKG/$TXNG2_TB $PRODUCTS_HOME
848cd $PRODUCTS_HOME
849$GNU_TAR -jxf ./$TXNG2_TB
850chmod -R 775 ./$TXNG2_DIR
851rm $PRODUCTS_HOME/$TXNG2_TB
852cd $PRODUCTS_HOME/$TXNG2_DIR
853$PY ./setup.py install
854cd $PKG
855
856###############################################################
857# Extract and move SAPL tarball to Products folder of Instance
858echo -e "\033[32mExtraindo o SAPL tarball ...\033[m"
859cp $PKG/$SAPL_TB $INSTALL_HOME/$SAPL_TB
860cd $INSTALL_HOME
861$GNU_TAR -jxf ./$SAPL_TB
862svn up $SAPL_DIR
863mv $SAPL_DIR $PRODUCTS_HOME
864mv $PRODUCTS_HOME/$SAPL_DIR/Products/PythonModules $PRODUCTS_HOME
865rm $INSTALL_HOME/$SAPL_TB
866chmod -R 775 $PRODUCTS_HOME
867cd $PKG
868
869########################
870# Write password to file
871echo -e "\033[32mEscrevendo, em arquivo, o password randomico ...\033[m"
872touch $PWFILE
873# Write admin password and startup/shutdown info to password file
874echo "Use as informações da conta a seguir para logar no Zope Management Interface" >> "$PWFILE"
875echo "A conta tem privilégios de 'Manager'." >> "$PWFILE"
876echo " " >> "$PWFILE"
877echo "  Username: admin" >> "$PWFILE"
878echo "  Senha: $PASSWORD" >> "$PWFILE"
879echo " " >> "$PWFILE"
880echo "Antes de iniciar o SAPL, você deverá rever as configurações em:" >> "$PWFILE"
881echo " " >> "$PWFILE"
882echo "  $SAPL_HOME/etc/zope.conf" >> "$PWFILE"
883echo " " >> "$PWFILE"
884echo "Ajuste as portas do SAPL antes de inicar seu uso, caso necessário" >> "$PWFILE"
885echo " " >> "$PWFILE"
886echo "Para iniciar o SAPL, execute o seguinte comando no terminal:" >> "$PWFILE"
887echo " " >> "$PWFILE"
888echo "  sudo $SAPL_STARTUP_SCRIPT" >> "$PWFILE"
889echo " " >> "$PWFILE"
890echo "Para parar o SAPL, execute o seguinte comando no terminal:" >> "$PWFILE"
891echo " " >> "$PWFILE"
892echo "  sudo $SAPL_SHUTDOWN_SCRIPT" >> "$PWFILE"
893echo " " >> "$PWFILE"
894
895####################################################
896# Write SAPL startup/shutdown/restart scripts to file
897
898# Write startup script
899echo -e "\033[32mEscrevendo o arquivo de script startup ...\033[m"
900touch $SAPL_STARTUP_SCRIPT
901echo "#!/bin/sh" >> "$SAPL_STARTUP_SCRIPT"
902echo "#" >> "$SAPL_STARTUP_SCRIPT"
903#echo "PYTHON_EGG_CACHE=$SAPL_HOME/var/.python-eggs" >> "$SAPL_STARTUP_SCRIPT"
904#echo "export PYTHON_EGG_CACHE" >> "$SAPL_STARTUP_SCRIPT"
905echo "# SAPL startup script" >> "$SAPL_STARTUP_SCRIPT"
906echo "#" >> "$SAPL_STARTUP_SCRIPT"
907#echo "echo 'Starting MySQL server...'" >> "$SAPL_STARTUP_SCRIPT"
908#echo "$MYSQL_HOME/bin/mysqld_safe --user=mysql &" >> "$SAPL_STARTUP_SCRIPT"
909#echo "sleep 1" >> "$SAPL_STARTUP_SCRIPT"
910echo "echo 'Starting SAPL server...'" >> "$SAPL_STARTUP_SCRIPT"
911echo "$SAPL_HOME/bin/zopectl start" >> "$SAPL_STARTUP_SCRIPT"
912
913# Write shutdown script
914echo -e "\033[32mEscrevendo o arquivo de script shutdown ...\033[m"
915touch $SAPL_SHUTDOWN_SCRIPT
916echo "#!/bin/sh" >> "$SAPL_SHUTDOWN_SCRIPT"
917echo "#" >> "$SAPL_SHUTDOWN_SCRIPT"
918echo "# SAPL shutdown script" >> "$SAPL_SHUTDOWN_SCRIPT"
919echo "#" >> "$SAPL_SHUTDOWN_SCRIPT"
920echo "echo 'Stopping SAPL server...'" >> "$SAPL_SHUTDOWN_SCRIPT"
921echo "$SAPL_HOME/bin/zopectl stop" >> "$SAPL_SHUTDOWN_SCRIPT"
922#echo "sleep 1" >> "$SAPL_SHUTDOWN_SCRIPT"
923#echo "echo 'Stopping MySQL server...'" >> "$SAPL_SHUTDOWN_SCRIPT"
924#echo "$MYSQL_HOME/bin/mysqladmin -u root shutdown" >> "$SAPL_SHUTDOWN_SCRIPT"
925
926# Write restart script
927echo -e "\033[32mEscrevendo o arquivo de script restart ...\033[m"
928touch $SAPL_RESTART_SCRIPT
929echo "#!/bin/sh" >> "$SAPL_RESTART_SCRIPT"
930echo "#" >> "$SAPL_RESTART_SCRIPT"
931echo "# SAPL restart script" >> "$SAPL_RESTART_SCRIPT"
932echo "#" >> "$SAPL_RESTART_SCRIPT"
933#echo "echo 'Restarting MySQL server...'" >> "$SAPL_RESTART_SCRIPT"
934#echo "$MYSQL_HOME/bin/mysqladmin -u root shutdown" >> "$SAPL_RESTART_SCRIPT"
935#echo "$MYSQL_HOME/bin/mysqld_safe --user=mysql &" >> "$SAPL_RESTART_SCRIPT"
936echo "echo 'Restarting SAPL server...'" >> "$SAPL_RESTART_SCRIPT"
937echo "$SAPL_HOME/bin/zopectl restart" >> "$SAPL_RESTART_SCRIPT"
938
939#########################################################
940# Fix path for Zope command line utils (repozo.py et.al.)
941echo -e "\033[32mEscrevendo o arquivo de script restart ...\033[m"
942echo "$INSTALL_HOME/lib/python" > "$SITE_PACKAGES/zope.pth"
943
944#####################################
945# Clean up any .DS_Store files (OS X)
946find $INSTALL_HOME -name '.DS_Store' -delete
947
948################################################
949# Add user account via platform-specific methods
950echo -e "\033[32mAdding user account 'zope' to system ...\033[m"
951# Add unprivileged user account via 'useradd', if exists (Linux)
952if [ -e /usr/sbin/useradd ]
953then
954    /usr/sbin/useradd $EFFECTIVE_USER
955# Add unprivileged user account via 'adduser', if exists (*BSD)
956elif [ -e /usr/sbin/adduser ]
957then
958    /usr/sbin/adduser -f $PKG/$HSCRIPTS_DIR/adduser.txt
959fi
960
961# Add zope user to NetInfo if we're on Mac OS X
962# try dscl for Mac OS X
963if [ -e /usr/bin/dscl ]; then
964    UNAME=$EFFECTIVE_USER
965    # find or create a $UNAME group
966    dscl . search /groups RecordName $UNAME | grep "($UNAME)" > /dev/null
967    if [ "$?" = "0" ]; then
968        gid=$(dscl . read /groups/$UNAME PrimaryGroupID | cut -d" " -f2 -)
969    else
970        gid="50"
971        dscl . search /groups PrimaryGroupID $gid | grep "($gid)" > /dev/null
972        while [ "$?" = "0" ]; do
973            if [ "$gid" = "500" ]; then
974                echo Falhou ao achar uid disponível abaixo de 500. Saindo.
975                exit 1
976            else
977                gid=$(($gid + 1))
978                dscl . search /groups PrimaryGroupID $gid | grep "($gid)" > /dev/null
979            fi
980        done
981        echo Criando grupo $UNAME com gid $gid via dscl...
982        dscl . -create /groups/$UNAME
983        dscl . -create /groups/$UNAME gid $gid
984    fi
985    # find or create a $UNAME user
986    dscl . search /users RecordName $UNAME | grep "($UNAME)" > /dev/null
987    if [ "$?" != "0" ]; then
988        # Add zope user via dscl, with a uid below 500
989        echo Criando usuário zope
990        uiddef=$gid
991        dscl . search /users UniqueID $uiddef | grep "($uiddef)" > /dev/null
992        while [ "$?" = "0" ]; do
993            if [ "$uiddef" = "500" ]; then
994                echo Falhou ao achar uid disponível abaixo de 500. Saindo.
995                exit 1
996            else
997                uiddef=$(($uiddef + 1))
998                dscl . search /users UniqueID $uiddef | grep "($uiddef)" > /dev/null
999            fi
1000        done
1001        #
1002        echo Criando usuário $UNAME com uid $uiddef via dscl...
1003        dscl . -create /users/$UNAME
1004        if [ "$?" = "0" ]; then
1005            dscl . -create /users/$UNAME UniqueID $uiddef
1006            dscl . -create /users/$UNAME RealName "SAPL Administrator"
1007            dscl . -create /users/$UNAME PrimaryGroupID $gid
1008            dscl . -create /users/$UNAME NFSHomeDirectory $INSTALL_HOME
1009            dscl . -create /users/$UNAME Password '*'
1010            dscl . -create /users/$UNAME UserShell /usr/bin/false
1011        else
1012            echo "Criação do usuário zope falhou"
1013            exit 1
1014        fi
1015    else
1016        oldgid=$(dscl . read /users/$UNAME PrimaryGroupID | cut -f2 -d" " -)
1017        if [ $oldgid != $gid ]; then
1018            dscl . -create /users/$UNAME PrimaryGroupID $gid
1019        fi
1020    fi
1021elif [ -e /usr/bin/niutil ]; then
1022    niutil -readprop -t localhost/local /users/$EFFECTIVE_USER uid
1023    if [ "$?" != "0" ]
1024    then
1025        # Add zope user to NetInfo, with a uid below 500
1026        echo Criando o usuário zope
1027        uiddef="50"
1028        niutil -readprop -t localhost/local /users/uid=$uiddef name
1029        while [ "$?" = "0" ]
1030        do
1031            if [ "$uiddef" = "500" ]
1032            then
1033                echo Falhou ao achar uid disponível abaixo de 500. Saindo.
1034                exit 1
1035            else
1036                uiddef=`echo $uiddef + 1 | bc`
1037                niutil -readprop -t localhost/local /users/uid=$uiddef name
1038            fi
1039        done
1040        #
1041        echo Criando usuário zope com o uid $uiddef...
1042        niutil -create  -t localhost/local /users/$EFFECTIVE_USER
1043        if [ "$?" = "0" ]
1044        then
1045            niutil -createprop -t localhost/local /users/$EFFECTIVE_USER realname "SAPL Administrator"
1046            niutil -createprop -t localhost/local /users/$EFFECTIVE_USER uid $uiddef
1047            niutil -createprop -t localhost/local /users/$EFFECTIVE_USER gid 20
1048            niutil -createprop -t localhost/local /users/$EFFECTIVE_USER home "$INSTALL_HOME"
1049            niutil -createprop -t localhost/local /users/$EFFECTIVE_USER name $EFFECTIVE_USER
1050            niutil -createprop -t localhost/local /users/$EFFECTIVE_USER passwd '*'
1051            niutil -createprop -t localhost/local /users/$EFFECTIVE_USER shell /bin/tcsh
1052            niutil -createprop -t localhost/local /users/$EFFECTIVE_USER _writers_passwd $EFFECTIVE_USER
1053        else
1054            echo "Criação do usuário zope falhou"
1055            exit 1
1056        fi
1057    fi
1058fi
1059
1060###########################################
1061# Clean up helper scripts directory
1062cd $PKG
1063if [ -d $HSCRIPTS_DIR ]
1064then
1065    rm -rf $HSCRIPTS_DIR
1066fi
1067
1068###########################################
1069# Set appropriate ownership and permissions
1070echo -e "\033[32mColocando as propriedades e permissões apropriadas aos arquivos ...\033[m"
1071chmod -R 775 $INSTALL_HOME
1072chmod 660 "$PWFILE"
1073if [ `whoami` = root ]
1074then
1075    chown -R $EFFECTIVE_USER $INSTALL_HOME
1076fi
1077
1078# Set appropriate ownership and permissions to MySQL
1079#echo "Colocando a propriedade e a permissão para o MySQL..."
1080#chmod -R 755 $MYSQL_HOME
1081#chown -R root $MYSQL_HOME
1082#chgrp -R mysql $MYSQL_HOME
1083#chown -R mysql $MYSQL_HOME/var
1084
1085######################
1086# Import sql script to database
1087echo -e "\033[32mImportando o script do banco de dados\033[m"
1088if [ -z $senha ]; then
1089    mysql -h 127.0.0.1 -u $usuario < $PRODUCTS_HOME/$SAPL_DIR/instalacao/sapl_create.sql
1090    mysql -h 127.0.0.1 -u $usuario interlegis < $PRODUCTS_HOME/$SAPL_DIR/instalacao/sapl.sql
1091else
1092    mysql -h 127.0.0.1 -u $usuario --password=$senha < $PRODUCTS_HOME/$SAPL_DIR/instalacao/sapl_create.sql
1093    mysql -h 127.0.0.1 -u $usuario interlegis --password=$senha < $PRODUCTS_HOME/$SAPL_DIR/instalacao/sapl.sql
1094fi
1095if [ $? -gt 0 ]; then
1096    echo ""
1097    echo -e "\033[1;31mErro na importação da estrutura da base de dados!\033[m";
1098    echo -e "\033[1;31mVerifique o usuário e senha e refaça a instalação!\033[m";
1099    echo -e "\033[1;31mInstalação abortada!\033[m";
1100    echo ""
1101    exit 1
1102fi
1103
1104#######################
1105# Building the SAPL instance
1106echo -e "\033[32mConfigurando a instancia SAPL\033[m"
1107$SAPL_SHUTDOWN_SCRIPT
1108sleep 1
1109#echo "cp $PRODUCTS_HOME/$SAPL_DIR/import/* $SAPL_HOME/import/"
1110#echo "$SAPL_HOME/bin/zopectl run $PRODUCTS_HOME/$SAPL_DIR/instalacao/sapl_configurador.py"
1111cp $PRODUCTS_HOME/$SAPL_DIR/import/* $SAPL_HOME/import/
1112$SAPL_HOME/bin/zopectl run $PRODUCTS_HOME/$SAPL_DIR/instalacao/sapl_configurador.py
1113$SAPL_STARTUP_SCRIPT
1114sleep 1
1115
1116#######################
1117# Conclude installation
1118if [ -d $INSTALL_HOME ]
1119    then
1120    mkdir $RECEIPTS_HOME
1121    echo "Instalacao do SAPL 2.4-beta completada em" `date` > $RECEIPTS_HOME/installReceipt.txt
1122    echo " "
1123    echo "#####################################################################"
1124    echo "######################  Instalacao Completa  ########################"
1125    echo " "
1126    cat $INSTALL_HOME/adminPassword.txt
1127    echo " "
1128    echo "SAPL foi instalado com sucesso em $INSTALL_HOME"
1129    echo "Leia o arquivo $INSTALL_HOME/adminPassword.txt para ver a senha e instruções para inicialização"
1130    echo " "
1131    echo "Submissão de feedback e report de erros em http://colab.interlegis.gov.br/newticket"
1132    echo " "
1133    echo "Este instalador é mantido por Jean Rodrigo Ferri (jeanferri em interlegis.gov.br)"
1134    echo " "
1135else
1136    echo "Ocorreram erros durante a instalacao. Por favor leia o LEIAME.txt e tente novamente."
1137fi
Note: Veja TracBrowser para ajuda no uso do navegador do trac.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.