#!/bin/bash # NOTE: Evita problemas com caminhos relativos! By Questor SCRIPTDIR_V="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" . $SCRIPTDIR_V/ez_i.sh # > -------------------------------------------------------------------------- # INÍCIO! # -------------------------------------- read -d '' TITLE_F <<"EOF" LBG - LBGenerator Installer EOF read -d '' VERSION_F <<"EOF" 0.6.2.0 EOF read -d '' ABOUT_F <<"EOF" This script will install LBGenerator the LightBase data specification and model! Have fun! =D EOF read -d '' WARNINGS_F <<"EOF" - Installer designed for CentOS 6 AMD64/RHEL 6 AMD64! - We RECOMMEND you... Install all the components (answer yes to everything). Except contrary guidance! Check for previous installations! If there is previous installations consider this variant in the process! - We WARNING you... USE AT YOUR OWN RISK: WE ARE NOT RESPONSIBLE FOR ANY DAMAGE TO YOURSELF, HARDWARE, OR CO-WORKERS. EXCEPT IN CASES WHERE THERE ARE SIGNED CONTRACT THAT REGULATES THIS! EOF read -d '' COMPANY_F <<"EOF" BR Light LTDA - LightBase Consulting in Public Software/LightBase Consultoria em Software Público Free Software + Our Ideas = Best Solution!/Software Livre + Nossas Idéias = Melhor Solução! +55-61-3347-1949 - http://www.LightBase.com.br - Brasil-DF EOF f_begin "$TITLE_F" "$VERSION_F" "$ABOUT_F" "$WARNINGS_F" "$COMPANY_F" ABOUT_F="" WARNINGS_F="" # < -------------------------------------------------------------------------- # > -------------------------------------------------------------------------- # TERMOS E LICENÇA! # -------------------------------------- read -d '' TERMS_LICEN_F <<"EOF" BY USING THIS INSTALLER YOU ARE AGREEING TO THE TERMS OF USE OF ALL INVOLVED SOFTWARE! EOF f_terms_licen "$TERMS_LICEN_F" TERMS_LICEN_F="" # < -------------------------------------------------------------------------- # > -------------------------------------------------------------------------- # INTRUÇÕES! # -------------------------------------- read -d '' INSTRUCT_F <<"EOF" - To run this script YOU NEED to be root! - TO CANCEL installation at any time use Ctrl+c! EOF f_instruct "$INSTRUCT_F" INSTRUCT_F="" # < -------------------------------------------------------------------------- # > ----------------------------------------- # Dá ao usuário mais avançado a possibilideade de usar o instalador # simplificado! # NOTE: É possível forçar o processo de instalção simplificado setando # "SIMPLE_INST" com 1! By Questor SIMPLE_INST=0 if [ ${SIMPLE_INST} -eq 0 ] ; then f_open_section f_yes_no "Use simple install (using a default value for most of the options)?" if [ ${YES_NO_R} -eq 1 ] ; then # NOTE: Essa variável serve apenas para "preservar" o valor # setado pelo usuário sendo somente "leitura". A variável a # ser usada nas regras deve ser "EZ_I_SKIP_ON_V" (ez_i.sh)! Essa # estratégia serve para mudarmos o comportamento do "ez_i.sh" # de acordo com as circunstâncias! By Questor SIMPLE_INST=1 # NOTE: Essa variável é para consumo do "ez_i.sh", para que ele # não execute algumas funções e simplifique o processo de # instalação! By Questor EZ_I_SKIP_ON_V=1 fi f_close_section sleep 1 fi # < ----------------------------------------- # > ----------------------------------------- # Garantir o encodamento correto para evitar problemas de # compatibilidade! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section read -d '' TITLE_F <<"EOF" Set terminal encode? (recommended for Windows terminal clients) EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then export LANG=pt_BR.utf8 fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Desabilita o SElinux! EZ_I_SKIP_ON_V=0 f_open_section read -d '' TITLE_F <<"EOF" Disable SElinux (use "y" if you never did it)? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${YES_NO_R} -eq 1 ] ; then setenforce 0 # NOTE: As condições abaixo visam evitar que o arquivo seja # desnecessariamente e erroneamente modificado! By Questor EZ_I_SKIP_ON_V=$SIMPLE_INST f_fl_cont_str "# SELINUX=enforcing" "/etc/sysconfig/selinux" "The file \"/etc/sysconfig/selinux\" probably has already been changed! Check it!" EZ_I_SKIP_ON_V=0 if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_fl_cont_str "SELINUX=disabled" "/etc/sysconfig/selinux" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "SELINUX=enforcing" "# SELINUX=enforcing\nSELINUX=disabled" "/etc/sysconfig/selinux" fi fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Instala os componentes de base usados pela especificação LightBase! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section read -d '' TITLE_F <<"EOF" Install base components? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_pack_is_inst "gcc-c++" "yum" "\"gcc-c++\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install gcc-c++ fi f_pack_is_inst "zlib-devel" "yum" "\"zlib-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install zlib-devel fi f_pack_is_inst "openssl-devel" "yum" "\"openssl-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install openssl-devel fi f_pack_is_inst "postgresql-devel" "yum" "\"postgresql-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install postgresql-devel fi f_pack_is_inst "git" "yum" "\"git\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install git fi fi f_close_section # < ----------------------------------------- BASE_INST_DIR_V="/usr/local/lb" # > ----------------------------------------- # Criar o diretório base da instalação! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section QUESTION_F="Insert where the base installation directory (\"lb\") will be created (don't use \"/\" at the end). Use empty for \"/usr/local\"!" f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ -z "$GET_USR_INPUT_R" ] ; then f_chk_by_path_hlp "$BASE_INST_DIR_V" "d" "\"$BASE_INST_DIR_V\" directory already created!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then mkdir -p "$BASE_INST_DIR_V" fi else BASE_INST_DIR_V="$GET_USR_INPUT_R/lb" f_chk_by_path_hlp "$BASE_INST_DIR_V" "d" "\"$BASE_INST_DIR_V\" directory already created!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then mkdir -p "$BASE_INST_DIR_V" fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Instalar o python3.2! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section read -d '' TITLE_F <<"EOF" Install python3.2? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_chk_by_path_hlp "$BASE_INST_DIR_V/py32" "d" "python3.2 already installed in \"$BASE_INST_DIR_V/py32\"!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps tar -zxvf Python-3.2.2.tar.gz cd ./Python-3.2.2 eval "./configure --prefix=$BASE_INST_DIR_V/py32/ --with-threads --enable-shared LDFLAGS=-Wl,-rpath=$BASE_INST_DIR_V/py32/lib/" make && make install cd .. rm -rf ./Python-3.2.2 f_enter_to_cont "python3.2 installed in \"$BASE_INST_DIR_V/py32\"!" fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Instalar o virtualenv-1.11.6 no python3.2! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section read -d '' TITLE_F <<"EOF" Install virtualenv-1.11.6 on python3.2? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_chk_by_path_hlp "$BASE_INST_DIR_V/py32/bin/virtualenv-3.2" "f" "virtualenv-1.11.6 already installed in python3.2 (\"$BASE_INST_DIR_V/py32\")!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps tar -zxvf virtualenv-1.11.6.tar.gz cd virtualenv-1.11.6 $BASE_INST_DIR_V/py32/bin/python3.2 setup.py install cd .. rm -rf virtualenv-1.11.6 fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Criar o ambiente virtual (python3.2)! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section f_enter_to_cont "Create the virtual environment (python3.2)!" f_chk_by_path_hlp "$BASE_INST_DIR_V/ve32" "d" "Virtual environment (python3.2) already created in \"$BASE_INST_DIR_V/ve32\"!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then cd "$BASE_INST_DIR_V" $BASE_INST_DIR_V/py32/bin/virtualenv-3.2 ve32 mkdir "$BASE_INST_DIR_V/ve32/src" f_enter_to_cont "Virtual environment created in \"$BASE_INST_DIR_V/ve32\"!" fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Instalar o Apache (httpd)! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section read -d '' TITLE_F <<"EOF" Install Apache (httpd)? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_pack_is_inst "httpd-devel" "yum" "Apache (httpd) already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install httpd-devel httpd chkconfig httpd on chown -R apache /var/www chmod -R 755 /var/www fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Abrir o firewall para o Apache (httpd)! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section read -d '' TITLE_F <<"EOF" Open firewall for Apache (httpd) (TCP 80)? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_chk_iptables 80 "Port 80 is already open!" 0 "ACCEPT" "tcp" "NEW" if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT service iptables save service iptables restart fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Instalar o mod_wsgi-4.3.2! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section read -d '' TITLE_F <<"EOF" Install mod_wsgi-4.3.2? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps f_fl_cont_str "$BASE_INST_DIR_V/py32/lib" "/etc/ld.so.conf" "The file \"/etc/ld.so.conf\" probably has already been changed! Check it!" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "include ld.so.conf.d/*.conf" "include ld.so.conf.d/*.conf\n$BASE_INST_DIR_V/py32/lib" "/etc/ld.so.conf" fi UP_MOD_WSGI=1 f_chk_by_path_hlp "/usr/lib64/httpd/modules/mod_wsgi.so" "f" "mod_wsgi already installed in \"/usr/lib64/httpd/modules/mod_wsgi.so\"!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then if [ ${EZ_I_SKIP_ON_V} -eq 0 ] ; then TITLE_F="Update/reinstall mod_wsgi? (\"y\" recommended)" f_div_section f_yes_no "$TITLE_F" f_div_section TITLE_F="" UP_MOD_WSGI=$YES_NO_R if [ ${UP_MOD_WSGI} -eq 1 ] ; then rm -rf "/usr/lib64/httpd/modules/mod_wsgi.so" fi fi fi if [ ${UP_MOD_WSGI} -eq 1 ] ; then ldconfig tar -zxvf ./mod_wsgi-4.3.2.tar.gz cd ./mod_wsgi-4.3.2 eval "./configure --with-python=$BASE_INST_DIR_V/py32/bin/python3.2" make && make install cd .. rm -rf ./mod_wsgi-4.3.2 fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Instalar o ElasticSearch! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section read -d '' TITLE_F <<"EOF" Install ElasticSearch? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_pack_is_inst "elasticsearch.noarch" "yum" "ElasticSearch already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then f_pack_is_inst "java-1.7.0-openjdk" "yum" "java-1.7.0-openjdk already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install java-1.7.0-openjdk fi cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps rpm -Uvh elasticsearch-1.1.1.noarch.rpm /sbin/chkconfig --add elasticsearch f_fl_cont_str "cluster.name: lb" "/etc/elasticsearch/elasticsearch.yml" "The file \"/etc/elasticsearch/elasticsearch.yml\" probably has already been changed! Check it!" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "# cluster.name: elasticsearch" "# cluster.name: elasticsearch\ncluster.name: lb" "/etc/elasticsearch/elasticsearch.yml" fi service elasticsearch start fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Abrir o firewall para o ElasticSearch! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section read -d '' TITLE_F <<"EOF" Open firewall for ElasticSearch (TCP 9200)? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_chk_iptables 9200 "Port 9200 is already open!" 0 "ACCEPT" "tcp" "NEW" if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 9200 -j ACCEPT service iptables save service iptables restart fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Instalar o postgres 9.4! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section read -d '' TITLE_F <<"EOF" Install postgres 9.4? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps f_pack_is_inst "pgdg-centos94-9.4-1.noarch" "yum" "postgres 9.4 already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y localinstall pgdg-centos94-9.4-1.noarch.rpm yum -y install postgresql94-server service postgresql-9.4 initdb chkconfig postgresql-9.4 on service postgresql-9.4 start fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Configurar o postgres 9.4! CONF_PG=0 EZ_I_SKIP_ON_V=0 f_open_section TITLE_F="Configure postgres 9.4 (use \"y\" if you never did it)?" f_yes_no "$TITLE_F" TITLE_F="" PG_USER_F="lbu" PG_PWD_F="lbu" PG_EXT_ACS_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$SIMPLE_INST f_div_section QUESTION_F="Enter the postgres 9.4 user for lightbase (LBG). Use empty for \"$PG_USER_F\"!" f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then PG_USER_F=$GET_USR_INPUT_R fi f_div_section QUESTION_F="Enter the postgres 9.4 password for \"$PG_USER_F\". Use empty for \"$PG_PWD_F\"!" f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then PG_PWD_F=$GET_USR_INPUT_R fi f_div_section QUESTION_F="Enter one ip or ip range for external access. e.g. \"172.20.143.89/32\" for a single host or \"172.20.143.0/24\" for a small network or \"10.6.0.0/16\" for a larger one! Use empty for local access only!" f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then PG_EXT_ACS_F=$GET_USR_INPUT_R fi EZ_I_SKIP_ON_V=0 f_is_not_running "postgres" "ERROR! \"postgres\" service not running!" if [ ${F_IS_NOT_RUNNING_R} -eq 0 ] ; then cd /tmp f_get_stderr_stdout "sudo -u postgres psql -tAc \"SELECT * FROM pg_roles WHERE rolname='$PG_USER_F';\"" if [[ $F_GET_STDOUT_R == *"$PG_USER_F|"* ]]; then # NOTE: # rolname| # rolsuper| # rolinherit| # rolcreaterole| # rolcreatedb| # rolcatupdate| # rolcanlogin| # rolconnlimit| # rolpassword| # rolvaliduntil| # rolconfig| # oid # ! By Questor if [[ $F_GET_STDOUT_R != *"$PG_USER_F|t|t|t|t|t|t|f|-1|"* ]]; then f_div_section echo "The user \"$PG_USER_F\" already created, but something is apparently wrong with his roles. The expected roles are \"lbu|f|t|t|t|t|t|f|-1|...\"! DETAILS: \"$F_GET_STDOUT_R\"." f_div_section f_continue else EZ_I_SKIP_ON_V=$SIMPLE_INST f_enter_to_cont "The user \"$PG_USER_F\" already created and his roles are correct!" EZ_I_SKIP_ON_V=0 fi else if [[ $F_GET_STDERR_R == "" ]]; then sudo -u postgres psql -c "CREATE USER $PG_USER_F INHERIT SUPERUSER CREATEROLE CREATEDB;" sudo -u postgres psql -c "ALTER USER $PG_USER_F PASSWORD '$PG_PWD_F';" else f_enter_to_cont "An error occurred when creating \"$PG_USER_F\" user permissions! ERROR: \"$F_GET_STDERR_R\"." f_error_exit fi fi cd - >/dev/null else f_error_exit fi EZ_I_SKIP_ON_V=$SIMPLE_INST if [ -n "$PG_EXT_ACS_F" ] ; then f_fl_cont_str "host all all $PG_EXT_ACS_F trust" "/var/lib/pgsql/9.4/data/pg_hba.conf" "The file \"/var/lib/pgsql/9.4/data/pg_hba.conf\" probably has already been changed for external access! Check it!" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "# IPv4 local connections:" "# IPv4 local connections:\nhost all all $PG_EXT_ACS_F trust" "/var/lib/pgsql/9.4/data/pg_hba.conf" fi fi f_fl_cont_str "host all all 127.0.0.1/32 trust" "/var/lib/pgsql/9.4/data/pg_hba.conf" "The file \"/var/lib/pgsql/9.4/data/pg_hba.conf\" probably has already been changed for local access! Check it!" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "# IPv4 local connections:" "# IPv4 local connections:\nhost all all 127.0.0.1/32 trust" "/var/lib/pgsql/9.4/data/pg_hba.conf" fi f_fl_cont_str "listen_addresses = '*'" "/var/lib/pgsql/9.4/data/postgresql.conf" "The file \"/var/lib/pgsql/9.4/data/postgresql.conf\" probably has already been changed! Check it!" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "# - Connection Settings -" "# - Connection Settings -\n\nlisten_addresses = '*'" "/var/lib/pgsql/9.4/data/postgresql.conf" fi service postgresql-9.4 restart f_enter_to_cont "The file \"/var/lib/pgsql/9.4/data/pg_hba.conf\" has settings for postgres 9.4! Check it for more details!" EZ_I_SKIP_ON_V=0 CONF_PG=1 else f_enter_to_cont "The file \"/var/lib/pgsql/9.4/data/pg_hba.conf\" has settings for postgres 9.4! Check it!" fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Abrir o firewall para o postgres 9.4! EZ_I_SKIP_ON_V=0 f_open_section read -d '' TITLE_F <<"EOF" Open firewall for postgres 9.4 (TCP 5432)? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${YES_NO_R} -eq 1 ] ; then f_chk_iptables 5432 "Port 5432 is already open!" 0 "ACCEPT" "tcp" if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then iptables -I INPUT 1 -m tcp -p tcp --dport 5432 -j ACCEPT service iptables save service iptables restart fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Criar as estruturas de dados básicas do LB no postgres 9.4! CREATE_LB_DT=0 EZ_I_SKIP_ON_V=0 f_open_section TITLE_F="Create the basic LightBase (LBG) data structures in postgres 9.4 (use \"y\" if you never did it)?" f_yes_no "$TITLE_F" TITLE_F="" PG_DB_F="lb" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$SIMPLE_INST QUESTION_F="Enter the postgres 9.4 database name for LightBase (LBG). Use empty for \"$PG_DB_F\" (recommended)!" f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then PG_DB_F=$GET_USR_INPUT_R fi EZ_I_SKIP_ON_V=0 f_is_not_running "postgres" "ERROR! \"postgres\" service not running!" if [ ${F_IS_NOT_RUNNING_R} -eq 0 ] ; then cd /tmp f_get_stderr_stdout "sudo -u postgres psql -c \"CREATE DATABASE $PG_DB_F;\"" if [[ $F_GET_STDERR_R != "" ]]; then if [[ $F_GET_STDERR_R == *" already exists"* ]]; then EZ_I_SKIP_ON_V=$SIMPLE_INST f_enter_to_cont "The database \"$PG_DB_F\" already created!" EZ_I_SKIP_ON_V=0 else f_div_section echo "An error occurred when creating \"$PG_DB_F\" database! ERROR: \"$F_GET_STDERR_R\"." f_div_section f_error_exit fi else cd "$SCRIPTDIR_V" cp ./lbn-basic-dt-strt/lbn_basic_dt_strt.sql /tmp cd /tmp chmod 700 lbn_basic_dt_strt.sql chown postgres lbn_basic_dt_strt.sql chown :postgres lbn_basic_dt_strt.sql sudo -u postgres psql $PG_DB_F -f lbn_basic_dt_strt.sql rm -f lbn_basic_dt_strt.sql fi else f_error_exit fi CREATE_LB_DT=1 else f_enter_to_cont "The file \"./lbn-basic-dt-strt/lbn_basic_dt_strt.sql\" has the basic LightBase (LBG) data structures! Check it!" fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Instalar as dependências python da LIB - liblightbase! EZ_I_SKIP_ON_V=$SIMPLE_INST cd "$SCRIPTDIR_V" sh py-packs-liblightbase.sh "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V" # < ----------------------------------------- # > ----------------------------------------- # Instalar a LIB - liblightbase! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section read -d '' TITLE_F <<"EOF" Install the LIB - liblightbase? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_chk_by_path_hlp "$BASE_INST_DIR_V/ve32/src/liblightbase" "d" "\"liblightbase\" already installed in \"$BASE_INST_DIR_V/ve32/src\"!" F_BAK_MD_R=1 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then f_ez_mv_bak "$BASE_INST_DIR_V/ve32/src/liblightbase" "Backup old version and update? (\"y\" recommended)" fi if [ ${F_BAK_MD_R} -eq 1 ] ; then cd "$SCRIPTDIR_V" tar -zxvf liblightbase.tar.gz mv "$SCRIPTDIR_V/liblightbase" "$BASE_INST_DIR_V/ve32/src/" cd "$BASE_INST_DIR_V/ve32/src/liblightbase" eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Instalar e configurar o LBG - LBGenerator! EZ_I_SKIP_ON_V=$SIMPLE_INST cd "$SCRIPTDIR_V" sh py-packs-LBGenerator.sh "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V" # < ----------------------------------------- # > ----------------------------------------- # Instalar o LBG - LBGenerator! EZ_I_SKIP_ON_V=$SIMPLE_INST APP_URL_F="lbg" f_open_section read -d '' TITLE_F <<"EOF" Install the LBG - LBGenerator? EOF f_yes_no "$TITLE_F" TITLE_F="" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_chk_by_path_hlp "$BASE_INST_DIR_V/ve32/src/LBGenerator" "d" "\"LBGenerator\" already installed in \"$BASE_INST_DIR_V/ve32/src\"!" F_BAK_MD_R=1 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then f_ez_mv_bak "$BASE_INST_DIR_V/ve32/src/LBGenerator" "Backup old version and update? (\"y\" recommended)" fi if [ ${F_BAK_MD_R} -eq 1 ] ; then cd "$SCRIPTDIR_V" tar -zxvf LBGenerator.tar.gz mv "$SCRIPTDIR_V/LBGenerator" "$BASE_INST_DIR_V/ve32/src/" cd "$BASE_INST_DIR_V/ve32/src/LBGenerator" eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" f_enter_to_cont "Configure httpd (Apache) for LBG - LBGenerator!" # NOTE: To debug! By Questor # PG_USER_F="lbu" # PG_PWD_F="lbu" # PG_DB_F="lb" PG_CFG_F="postgresql://$PG_USER_F:$PG_PWD_F@127.0.0.1/$PG_DB_F" QUESTION_F="Enter the postgres 9.4 LBG configuration. Use empty for \"$PG_CFG_F\"!" f_div_section f_get_usr_input "$QUESTION_F" 1 f_div_section QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then PG_CFG_F=$GET_USR_INPUT_R fi QUESTION_F="Enter lightbase URL. Use empty for \"$APP_URL_F\" (used like e.g. http:///$APP_URL_F)!" f_div_section f_get_usr_input "$QUESTION_F" 1 f_div_section QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then APP_URL_F=$GET_USR_INPUT_R fi eval "cp -f \"$BASE_INST_DIR_V/ve32/src/LBGenerator/lbgenerator.wsgi-dist\" \"$BASE_INST_DIR_V/ve32/src/LBGenerator/lbgenerator.wsgi\"" f_ez_sed "" "$BASE_INST_DIR_V/ve32" "$BASE_INST_DIR_V/ve32/src/LBGenerator/lbgenerator.wsgi" eval "cp -f \"$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini-dist\" \"$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini\"" f_ez_sed "" "$PG_CFG_F" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1 f_chk_by_path_hlp "/etc/httpd/conf.d/lbg.conf" "f" "\"lbg.conf\" already created in \"/etc/httpd/conf.d/lbg.conf\"!" F_BAK_MD_R=1 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then f_ez_mv_bak "/etc/httpd/conf.d/lbg.conf" "Backup old version and update? (\"y\" recommended)" fi if [ ${F_BAK_MD_R} -eq 1 ] ; then eval "cp -f \"$SCRIPTDIR_V/other-srcs-n-apps/lbg.conf.dist\" \"/etc/httpd/conf.d/lbg.conf\"" f_ez_sed "" "$BASE_INST_DIR_V/ve32" "/etc/httpd/conf.d/lbg.conf" 1 f_ez_sed "" "$APP_URL_F" "/etc/httpd/conf.d/lbg.conf" 1 fi eval "chown -R apache $BASE_INST_DIR_V" eval "chmod -R 755 $BASE_INST_DIR_V" service httpd restart fi fi f_close_section # < ----------------------------------------- # > -------------------------------------------------------------------------- # FINAL! # -------------------------------------- EZ_I_SKIP_ON_V=0 read -d '' TITLE_F <<"EOF" Installer finished! Thanks! EOF # NOTE: A lógica imediatamente abaixo serve para os casos onde o # usuário optou por instalação simplificada para que ele seja informado # sobre quais foram as configurações de persistência setadas! By Questor PERSIST_CONFIG="" if [ ${SIMPLE_INST} -eq 1 ] && ([ ${CONF_PG} -eq 1 ] || [ ${CREATE_LB_DT} -eq 1 ]); then if [ ${CONF_PG} -eq 1 ] ; then CONF_PG_VL=" user ...... $PG_USER_F password .. $PG_PWD_F" fi if [ ${CREATE_LB_DT} -eq 1 ] ; then CREATE_LB_DT_VL=" database .... $PG_DB_F" fi PERSIST_CONFIG=" LightBase (LBG) postgres 9.4 persistence config...$CREATE_LB_DT_VL$CONF_PG_VL " fi USEFUL_INFO_F=" To start/stop... service httpd start service httpd stop $PERSIST_CONFIG To access... http:///$APP_URL_F To configure... vi $BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini To configure httpd (Apache)... vi /etc/httpd/conf.d/lbg.conf Log... less /var/log/httpd/error_log" f_end "$TITLE_F" "$USEFUL_INFO_F" TITLE_F="" USEFUL_INFO_F="" # < --------------------------------------------------------------------------