#!/bin/bash # > ----------------------------------------- # Run that script with bash even if the user use sh/dash or any sh like # interpreter. This way it correctly works with either: # "sh ./my_script.sh" or "bash ./my_script.sh" or "./my_script.sh" if [ -z "$BASH_VERSION" ] then exec bash "$0" "$@" fi # < ----------------------------------------- # 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" - This installer is compatible with RHEL, SUSE, Debian or distributions based on these. - 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! Although this is not mandatory, do the installation process in an exclusive machine for this. - We NOTICE you... This installer assumes that the target distribution has a "standard setup". This may include components such as firewall, SELinux and others. - We WARNING you... THIS INSTALLER AND RESULTING PRODUCTS COMES WITH ABSOLUTELY NO WARRANTY! 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="" # < -------------------------------------------------------------------------- # > ----------------------------------------- # Checar se o usuário é root! f_is_root # < ----------------------------------------- # > -------------------------------------------------------------------------- # INTRUÇÕES! # -------------------------------------- read -d '' INSTRUCT_F <<"EOF" - TO CANCEL installation at any time use Ctrl+c! EOF f_instruct "$INSTRUCT_F" INSTRUCT_F="" # < -------------------------------------------------------------------------- DISTRO_TYPE="" DISTRO_NAME="" # > ----------------------------------------- # Checar se a distro é compatível! f_open_section f_about_distro f_div_section echo "DISTRO INFORMATION:" f_div_section echo "NAME: .... ${F_ABOUT_DISTRO_R[0]}" echo "VERSION: . ${F_ABOUT_DISTRO_R[1]}" echo "BASED: ... ${F_ABOUT_DISTRO_R[2]}" echo "ARCH: .... ${F_ABOUT_DISTRO_R[3]}" f_div_section if [[ "${F_ABOUT_DISTRO_R[2]}" == "Debian" ]] || [[ "${F_ABOUT_DISTRO_R[2]}" == "RedHat" ]] || [[ "${F_ABOUT_DISTRO_R[2]}" == "Suse" ]] ; then if [[ "${F_ABOUT_DISTRO_R[2]}" == "Debian" ]] ; then DISTRO_TYPE="DEB" if [[ "${F_ABOUT_DISTRO_R[0]}" == "Ubuntu" ]] ; then DISTRO_NAME="Ubuntu" if [[ "${F_ABOUT_DISTRO_R[1]}" != "14.04" ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 14.04/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" f_div_section if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi elif [[ "${F_ABOUT_DISTRO_R[0]}" == "Debian GNU/Linux" ]] ; then DISTRO_NAME="Debian" if [[ "${F_ABOUT_DISTRO_R[1]}" != "8" ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 8/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" f_div_section if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi else f_div_section f_yes_no "Linux distro may be incompatible with this installer (expected: Ubuntu or Debian/obtained: ${F_ABOUT_DISTRO_R[0]})! Continue?" f_div_section if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi elif [[ "${F_ABOUT_DISTRO_R[2]}" == "RedHat" ]] ; then DISTRO_TYPE="RH" if [[ "${F_ABOUT_DISTRO_R[0]}" == "Red Hat Enterprise Linux Server" ]] ; then DISTRO_NAME="RedHat" if [[ "${F_ABOUT_DISTRO_R[1]}" != "6."* ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 6.X/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" f_div_section if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi elif [[ "${F_ABOUT_DISTRO_R[0]}" == "CentOS" ]] ; then DISTRO_NAME="CentOS" if [[ "${F_ABOUT_DISTRO_R[1]}" != "6."* ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 6.X/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" f_div_section if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi else f_div_section f_yes_no "Linux distro may be incompatible with this installer (expected: CentOS or Red Hat Enterprise Linux Server/obtained: ${F_ABOUT_DISTRO_R[0]})! Continue?" f_div_section if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi elif [[ "${F_ABOUT_DISTRO_R[2]}" == "Suse" ]] ; then DISTRO_TYPE="SUSE" if [[ "${F_ABOUT_DISTRO_R[0]}" == "openSUSE" ]] ; then DISTRO_NAME="openSUSE" if [[ "${F_ABOUT_DISTRO_R[1]}" != "13."* ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 13.X/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" f_div_section if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi elif [[ "${F_ABOUT_DISTRO_R[0]}" == "SLES" ]] ; then DISTRO_NAME="SLES" if [[ "${F_ABOUT_DISTRO_R[1]}" != "12."* ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 12.X/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" f_div_section if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi else f_div_section f_yes_no "Linux distro may be incompatible with this installer (expected: openSUSE or SUSE Linux Enterprise Server/obtained: ${F_ABOUT_DISTRO_R[0]})! Continue?" f_div_section if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi fi if [[ "${F_ABOUT_DISTRO_R[3]}" != "x86_64" ]] ; then f_enter_to_cont "Linux architecture completely incompatible with this installer (expected: x86_64/obtained: ${F_ABOUT_DISTRO_R[3]})!" exit 0 fi else f_enter_to_cont "Linux distro completely incompatible with this installer (expected: Debian(or based) or RedHat(or based) or SUSE(or based)/obtained: ${F_ABOUT_DISTRO_R[2]})!" exit 0 fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # 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 (use default values 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! if [ ${SIMPLE_INST} -eq 0 ] ; then EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section f_yes_no "Set terminal encode? (in some cases recommended for Windows ssh clients)" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then export LANG=pt_BR.utf8 fi f_close_section fi # < ----------------------------------------- # > ----------------------------------------- # Desabilita o SElinux! if [[ "$DISTRO_TYPE" == "RH" ]] ; then EZ_I_SKIP_ON_V=0 f_open_section f_yes_no "Disable SElinux (use "y" if you never did it)?" 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 fi # < ----------------------------------------- # > ----------------------------------------- # Atualizar a distro (repositório)! EZ_I_SKIP_ON_V=$SIMPLE_INST if [[ "$DISTRO_TYPE" == "RH" ]] ; then if [[ "$DISTRO_NAME" == "RedHat" ]] ; then RESOURCES_ARR_P=("Red Hat Enterprise Linux Server") f_chk_distro_status "$DISTRO_NAME" RESOURCES_ARR_P[@] fi f_div_section f_yes_no "Update your distro? (\"y\" highly recommended)" f_div_section if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then yum -y update fi f_pack_is_inst "git" "yum" "\"git\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install git fi elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_div_section f_yes_no "Update your distro? (\"y\" highly recommended)" f_div_section if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then apt-get -y update fi f_pack_is_inst "git" "apt-get" "\"git\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install git fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then if [[ "$DISTRO_NAME" == "SLES" ]] ; then RESOURCES_ARR_P=("SUSE_Linux_Enterprise_Server_12_SP1_x86_64" "SUSE_Linux_Enterprise_Software_Development_Kit_12_SP1_x86_64" "Web_and_Scripting_Module_12_x86_64") f_chk_distro_status "SLES" RESOURCES_ARR_P[@] fi f_div_section f_yes_no "Update your distro? (\"y\" highly recommended)" f_div_section if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then zypper --non-interactive update fi f_pack_is_inst "git-core" "zypper" "\"git-core\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install git-core fi fi # < ----------------------------------------- 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 pacotes que são comuns a determinados componentes! F_COM_PKS_INSTALLED=0 f_common_packs() { : 'Instalar pacotes que são comuns a determinados componentes.' if [ ${F_COM_PKS_INSTALLED} -eq 0 ] ; then f_pack_is_inst "build-essential" "apt-get" "\"build-essential\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then if [[ "$DISTRO_TYPE" == "RH" ]] ; 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 "autoconf" "yum" "\"autoconf\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install autoconf fi f_pack_is_inst "automake" "yum" "\"automake\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install automake fi f_pack_is_inst "libtool" "yum" "\"libtool\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install libtool 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 elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_pack_is_inst "g++" "apt-get" "\"g++\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install g++ fi f_pack_is_inst "autoconf" "apt-get" "\"autoconf\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install autoconf fi f_pack_is_inst "make" "apt-get" "\"make\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install make fi f_pack_is_inst "libtool" "apt-get" "\"libtool\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install libtool fi f_pack_is_inst "zlib1g-dev" "apt-get" "\"zlib1g-dev\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install zlib1g-dev fi f_pack_is_inst "libssl-dev" "apt-get" "\"libssl-dev\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install libssl-dev fi f_pack_is_inst "dh-exec" "apt-get" "\"dh-exec\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install dh-exec fi f_pack_is_inst "libpq-dev" "apt-get" "\"libpq-dev\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install libpq-dev fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_pack_is_inst "gcc-c++" "zypper" "\"gcc-c++\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install gcc-c++ fi if [[ "$DISTRO_NAME" != "SLES" ]] ; then f_pack_is_inst "autoconf" "zypper" "\"autoconf\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install autoconf fi f_pack_is_inst "automake" "zypper" "\"automake\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install automake fi f_pack_is_inst "make" "zypper" "\"make\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install make fi f_pack_is_inst "libtool" "zypper" "\"libtool\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install libtool fi fi f_pack_is_inst "zlib-devel" "zypper" "\"zlib-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install zlib-devel fi f_pack_is_inst "libopenssl-devel" "zypper" "\"libopenssl-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install libopenssl-devel fi f_pack_is_inst "postgresql-devel" "zypper" "\"postgresql-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install postgresql-devel fi fi fi F_COM_PKS_INSTALLED=1 fi } # < ----------------------------------------- # > ----------------------------------------- # Instalar o python3.2! EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section f_yes_no "Install python3.2?" 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 f_common_packs 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 f_yes_no "Install virtualenv-1.11.6 on python3.2?" 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 f_common_packs 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 if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_pack_is_inst "python-setuptools" "yum" "\"python-setuptools\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install python-setuptools fi elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_pack_is_inst "python-setuptools" "apt-get" "\"python-setuptools\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install python-setuptools fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_pack_is_inst "python-setuptools" "zypper" "\"python-setuptools\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install python-setuptools fi fi f_common_packs 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)! HTTPD_SERV_NAME="" HTTPD_USR="" HTTPD_GRP="" HTTPD_DEF_DOC_ROOT="" if [[ "$DISTRO_TYPE" == "RH" ]] ; then HTTPD_SERV_NAME="httpd" HTTPD_USR="apache" HTTPD_GRP="apache" HTTPD_DEF_DOC_ROOT="/var/www" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then HTTPD_SERV_NAME="apache2" HTTPD_USR="www-data" HTTPD_GRP="www-data" HTTPD_DEF_DOC_ROOT="/var/www" elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then HTTPD_SERV_NAME="apache2" HTTPD_USR="wwwrun" HTTPD_GRP="www" HTTPD_DEF_DOC_ROOT="/srv/www" fi EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section f_yes_no "Install Apache ($HTTPD_SERV_NAME)?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_common_packs if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_pack_is_inst "httpd-devel" "yum" "Apache ($HTTPD_SERV_NAME) already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install httpd-devel httpd chkconfig httpd on fi elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_pack_is_inst "apache2-dev" "apt-get" "Apache ($HTTPD_SERV_NAME) already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install apache2-dev apache2 update-rc.d -f $HTTPD_SERV_NAME remove update-rc.d $HTTPD_SERV_NAME defaults fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_pack_is_inst "apache2-devel" "zypper" "Apache ($HTTPD_SERV_NAME) already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install apache2-devel apache2 chkconfig apache2 on fi fi eval "chown -R $HTTPD_USR $HTTPD_DEF_DOC_ROOT" eval "chown -R :$HTTPD_GRP $HTTPD_DEF_DOC_ROOT" eval "chmod -R 755 $HTTPD_DEF_DOC_ROOT" eval "service $HTTPD_SERV_NAME restart" &>/dev/null fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Abrir o firewall para o Apache (httpd)! if [[ "$DISTRO_TYPE" == "RH" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_yes_no "Open firewall for Apache ($HTTPD_SERV_NAME) (TCP 80)?" 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 elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_yes_no "Open firewall for Apache ($HTTPD_SERV_NAME) (TCP 80)?" 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" if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then SuSEfirewall2 open EXT TCP 80 SuSEfirewall2 stop SuSEfirewall2 start fi fi fi f_close_section fi # < ----------------------------------------- # > ----------------------------------------- # Instalar o mod_wsgi-4.3.2! if [[ "$DISTRO_TYPE" == "RH" ]] ; then MOD_WSGI_PATH="/usr/lib64/httpd/modules/mod_wsgi.so" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then MOD_WSGI_PATH="/usr/lib/apache2/modules/mod_wsgi.so" elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then MOD_WSGI_PATH="/usr/lib64/apache2/mod_wsgi.so" fi EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section f_yes_no "Install mod_wsgi-4.3.2?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_common_packs cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps if [[ "$DISTRO_TYPE" == "RH" ]] ; then REPLACE_REF="include ld.so.conf.d/*.conf" elif [[ "$DISTRO_TYPE" == "DEB" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then REPLACE_REF="include /etc/ld.so.conf.d/*.conf" fi 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 "$REPLACE_REF" "$REPLACE_REF\n$BASE_INST_DIR_V/py32/lib" "/etc/ld.so.conf" fi UP_MOD_WSGI=1 f_chk_by_path_hlp "$MOD_WSGI_PATH" "f" "mod_wsgi already installed in \"$MOD_WSGI_PATH\"!" 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 "$MOD_WSGI_PATH" 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! ES_NAME="Elasticsearch 1.7.5" ES_SERV_CMD="/etc/init.d/elasticsearch" EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section f_yes_no "Install $ES_NAME?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_common_packs f_chk_by_path_hlp "/usr/local/elasticsearch" "d" "\"elasticsearch-1.7.5.tar.gz\" already installed in \"/usr/local/elasticsearch\"!" F_BAK_MD_R=1 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then f_ez_mv_bak "/usr/local/elasticsearch" "Backup old version and update/reinstall? (\"y\" recommended)" if [ ${F_BAK_MD_R} -eq 1 ] ; then $ES_SERV_CMD stop &>/dev/null cd "$F_BAK_PATH_R" cd .. tar -cvvzf "$F_BAK_NAME_R.tar.gz" "./$F_BAK_NAME_R" rm -rf "$F_BAK_PATH_R" fi fi if [ ${F_BAK_MD_R} -eq 1 ] ; then if [[ "$DISTRO_TYPE" == "RH" ]] ; 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 elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_pack_is_inst "openjdk-7-jdk" "apt-get" "\"openjdk-7-jdk\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install openjdk-7-jdk fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_pack_is_inst "java-1_7_0-openjdk" "zypper" "\"java-1_7_0-openjdk\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install java-1_7_0-openjdk fi fi cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps tar -zxvf elasticsearch-1.7.5.tar.gz mv elasticsearch-1.7.5 /usr/local/elasticsearch tar -zxvf elasticsearch-servicewrapper-master.tar.gz mv elasticsearch-servicewrapper-master/service /usr/local/elasticsearch/bin/ rm -rf elasticsearch-servicewrapper-master /usr/local/elasticsearch/bin/service/elasticsearch install $ES_SERV_CMD start fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Abrir o firewall para o ElasticSearch! if [[ "$DISTRO_TYPE" == "RH" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_yes_no "Open firewall for $ES_NAME? (TCP 9200)?" 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 elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_yes_no "Open firewall for $ES_NAME? (TCP 9200)?" 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" if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then SuSEfirewall2 open EXT TCP 9200 SuSEfirewall2 stop SuSEfirewall2 start fi fi fi f_close_section fi # < ----------------------------------------- # > ----------------------------------------- # Instalar o postgresql! PG_NAME="" PG_SERV_NAME="" PG_PACK_NAME="" if [[ "$DISTRO_TYPE" == "RH" ]] ; then PG_NAME="PostgreSQL 9.3" PG_SERV_NAME="postgresql-9.3" if [[ "$DISTRO_NAME" == "RedHat" ]] ; then PG_PACK_NAME="pgdg-redhat93-9.3-2.noarch.rpm" else PG_PACK_NAME="pgdg-centos93-9.3-2.noarch.rpm" fi elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then if [[ "$DISTRO_NAME" == "Debian" ]] ; then PG_NAME="PostgreSQL 9.4" PG_SERV_NAME="postgresql" PG_PACK_NAME="postgresql-9.4" else PG_NAME="PostgreSQL 9.3" PG_SERV_NAME="postgresql" PG_PACK_NAME="postgresql-9.3" fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then if [[ "$DISTRO_NAME" == "SLES" ]] ; then PG_NAME="PostgreSQL 9.4" PG_SERV_NAME="postgresql" PG_PACK_NAME="postgresql94-server" else PG_NAME="PostgreSQL 9.3" PG_SERV_NAME="postgresql" PG_PACK_NAME="postgresql93-server" fi fi EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section f_yes_no "Install $PG_NAME?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_common_packs cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_pack_is_inst "postgresql93-server" "yum" "\"postgresql93-server\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y localinstall $PG_PACK_NAME yum -y install postgresql93-server service $PG_SERV_NAME initdb chkconfig $PG_SERV_NAME on service $PG_SERV_NAME start fi elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_pack_is_inst "$PG_PACK_NAME" "apt-get" "\"$PG_PACK_NAME\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install $PG_PACK_NAME update-rc.d -f $PG_SERV_NAME remove update-rc.d $PG_SERV_NAME defaults service $PG_SERV_NAME start fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_pack_is_inst "$PG_PACK_NAME" "zypper" "\"$PG_PACK_NAME\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install $PG_PACK_NAME chkconfig $PG_SERV_NAME on service $PG_SERV_NAME start fi fi fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Abrir o firewall para o postgresql! if [[ "$DISTRO_TYPE" == "RH" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_yes_no "Open firewall for $PG_NAME (TCP 5432)?" 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 elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_yes_no "Open firewall for $PG_NAME (TCP 5432)?" 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 SuSEfirewall2 open EXT TCP 5432 SuSEfirewall2 stop SuSEfirewall2 start fi fi fi f_close_section fi # < ----------------------------------------- # > ----------------------------------------- # Configurar o postgresql! CONF_PG=0 EZ_I_SKIP_ON_V=0 f_open_section f_yes_no "Configure $PG_NAME (use \"y\" if you never did it)?" PG_USER_F="lbu" PG_PWD_F="lbu" PG_EXT_ACS_F="" if [[ "$DISTRO_TYPE" == "RH" ]] ; then PG_HBA_PATH="/var/lib/pgsql/9.3/data/pg_hba.conf" PG_CONF_PATH="/var/lib/pgsql/9.3/data/postgresql.conf" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then if [[ "$DISTRO_NAME" == "Debian" ]] ; then PG_HBA_PATH="/etc/postgresql/9.4/main/pg_hba.conf" PG_CONF_PATH="/etc/postgresql/9.4/main/postgresql.conf" else PG_HBA_PATH="/etc/postgresql/9.3/main/pg_hba.conf" PG_CONF_PATH="/etc/postgresql/9.3/main/postgresql.conf" fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then PG_HBA_PATH="/var/lib/pgsql/data/pg_hba.conf" PG_CONF_PATH="/var/lib/pgsql/data/postgresql.conf" fi if [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$SIMPLE_INST if [[ "$DISTRO_TYPE" == "DEB" ]] && [[ "$DISTRO_NAME" == "Debian" ]] ; then f_pack_is_inst "sudo" "apt-get" "\"sudo\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install sudo fi fi f_div_section QUESTION_F="Enter the $PG_NAME 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 $PG_NAME 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 service $PG_SERV_NAME start &>/dev/null 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" "$PG_HBA_PATH" "The file \"$PG_HBA_PATH\" probably has already been changed to enable 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" "$PG_HBA_PATH" fi fi f_fl_cont_str "host all all 127.0.0.1/32 trust" "$PG_HBA_PATH" "The file \"$PG_HBA_PATH\" probably has already been changed to enable 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" "$PG_HBA_PATH" fi f_fl_cont_str "listen_addresses = '*'" "$PG_CONF_PATH" "The file \"$PG_CONF_PATH\" probably has already been changed to set \"listen addresses\"! Check it!" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "# - Connection Settings -" "# - Connection Settings -\n\nlisten_addresses = '*'" "$PG_CONF_PATH" fi service $PG_SERV_NAME restart f_enter_to_cont "The file \"$PG_HBA_PATH\" has settings for $PG_NAME! Check it for more details!" EZ_I_SKIP_ON_V=0 CONF_PG=1 else f_enter_to_cont "The file \"$PG_HBA_PATH\" has settings for $PG_NAME! Check it!" fi f_close_section # < ----------------------------------------- # > ----------------------------------------- # Criar as estruturas de dados básicas do LB no postgresql! CREATE_LB_DT=0 EZ_I_SKIP_ON_V=0 f_open_section f_yes_no "Create the basic LightBase (LBG) data structures in $PG_NAME (use \"y\" if you never did it)?" 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 $PG_NAME 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" bash 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" bash py-packs-LBGenerator.sh "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V" # < ----------------------------------------- # > ----------------------------------------- # Instalar o LBG - LBGenerator! if [[ "$DISTRO_TYPE" == "RH" ]] ; then VAR_LOG_HTTPD="/var/log/httpd" elif [[ "$DISTRO_TYPE" == "DEB" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then VAR_LOG_HTTPD="/var/log/apache2" fi EZ_I_SKIP_ON_V=$SIMPLE_INST APP_URL_F="lbg" f_open_section f_yes_no "Install the LBG - LBGenerator?" 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 Apache ($HTTPD_SERV_NAME) for LBG - LBGenerator!" PG_CFG_F="postgresql://$PG_USER_F:$PG_PWD_F@127.0.0.1/$PG_DB_F" QUESTION_F="Enter the postgresql 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 if [[ "$DISTRO_TYPE" == "RH" ]] ; then HTTPD_CONF_PATH="/etc/httpd/conf.d" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then HTTPD_CONF_PATH="/etc/apache2/sites-available" elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then HTTPD_CONF_PATH="/etc/apache2/conf.d" fi f_chk_by_path_hlp "$HTTPD_CONF_PATH/lbg.conf" "f" "\"lbg.conf\" already created in \"$HTTPD_CONF_PATH/lbg.conf\"!" F_BAK_MD_R=1 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then f_ez_mv_bak "$HTTPD_CONF_PATH/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\" \"$HTTPD_CONF_PATH/lbg.conf\"" f_ez_sed "" "$MOD_WSGI_PATH" "$HTTPD_CONF_PATH/lbg.conf" f_ez_sed "" "$BASE_INST_DIR_V/ve32" "$HTTPD_CONF_PATH/lbg.conf" 1 f_ez_sed "" "$APP_URL_F" "$HTTPD_CONF_PATH/lbg.conf" 1 f_ez_sed "" "$VAR_LOG_HTTPD" "$HTTPD_CONF_PATH/lbg.conf" 1 f_ez_sed "" "$HTTPD_USR" "$HTTPD_CONF_PATH/lbg.conf" 1 f_ez_sed "" "$HTTPD_GRP" "$HTTPD_CONF_PATH/lbg.conf" 1 if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_ez_sed "" "Order allow,deny\n Allow from all" "$HTTPD_CONF_PATH/lbg.conf" elif [[ "$DISTRO_TYPE" == "DEB" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_ez_sed "" "AllowOverride None\n Require all granted " "$HTTPD_CONF_PATH/lbg.conf" fi fi if [[ "$DISTRO_TYPE" == "DEB" ]] ; then ln -s "$HTTPD_CONF_PATH/lbg.conf" "/etc/apache2/sites-enabled/lbg.conf" &>/dev/null fi eval "chown -R $HTTPD_USR $BASE_INST_DIR_V" eval "chown -R :$HTTPD_GRP $BASE_INST_DIR_V" eval "chmod -R 755 $BASE_INST_DIR_V" eval "service $HTTPD_SERV_NAME restart" &>/dev/null 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) $PG_NAME persistence config...$CREATE_LB_DT_VL$CONF_PG_VL " fi USEFUL_INFO_F=" To start/stop... Apache ($HTTPD_SERV_NAME) service $HTTPD_SERV_NAME start service $HTTPD_SERV_NAME stop $PG_NAME service $PG_SERV_NAME start service $PG_SERV_NAME stop $ES_NAME $ES_SERV_CMD start $ES_SERV_CMD 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 $HTTPD_CONF_PATH/lbg.conf Log... less $VAR_LOG_HTTPD/error_log" f_end "$TITLE_F" "$USEFUL_INFO_F" TITLE_F="" USEFUL_INFO_F="" # < --------------------------------------------------------------------------