source: publico/ILSAPL/install/2.3-beta/install.sh @ 4576

Última Alteração nesse arquivo desde 4576 foi 4576, incluída por jeanferri, 10 anos atrás

Alterado o pacote de instalação do SAPL 2.3 beta, removida a dependência de EGGs

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