#!/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.bash" or "bash ./my_script.bash" or "./my_script.bash" 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.bash # > -------------------------------------------------------------------------- # INÍCIO! # -------------------------------------- read -d '' TITLE_F <<"EOF" LBG - LBGenerator Installer EOF # NOTE: Para versionamento usar "MAJOR.MINOR.REVISION.BUILDNUMBER"! # Usar a mesma versão contida no setup.py! By Questor # http://programmers.stackexchange.com/questions/24987/what-exactly-is-the-build-number-in-major-minor-buildnumber-revision read -d '' VERSION_F <<"EOF" 0.8.0.0 EOF read -d '' ABOUT_F <<"EOF" This script will install LBG - LBGenerator the LightBase data specification and model! 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) and use the default values. 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 +55-61-3347-1949/+55-61-3340-6966 - http://brlight.org/ - Brasil-DF Free software! Embrace that idea!/Software livre! Abrace essa idéia! EOF TUX=$(cat $SCRIPTDIR_V/tux.txt) f_begin "$TITLE_F" "$VERSION_F" "$ABOUT_F$TUX" "$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="" # < -------------------------------------------------------------------------- # NOTE: A razão para a existência dessas variáveis é "abistrair" o # funcionamento de "f_about_distro" que obtêm informações a partir de # dados da própria distro e portanto sujeito a variações! By Questor 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?" 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?" 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?" 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]}" != "7"* ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 7.X/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" if [ ${YES_NO_R} -eq 0 ] ; then exit 0 fi fi elif [[ "${F_ABOUT_DISTRO_R[0]}" == "CentOS Linux" ]] ; then DISTRO_NAME="CentOS" if [[ "${F_ABOUT_DISTRO_R[1]}" != "7"* ]] ; then f_div_section f_yes_no "Linux version may be incompatible with this installer (expected: 7.X/obtained: ${F_ABOUT_DISTRO_R[1]})! Continue?" 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?" 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?" 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?" 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?" 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 a possibilidade de usar o instalador no modo rápido. Bom para # conhecer/testar o sistema de forma simples sem preucupar-se com configurações! # NOTE: É possível forçar o processo de instalação no modo rápido setando # "FAST_INST" com 1! By Questor FAST_INST=0 if [ ${FAST_INST} -eq 0 ] ; then f_open_section f_div_section f_yes_no "Use fast install (use default values for most of the options)? NOTE: RECOMMENDED FOR THOSE who want to KNOW and TEST the LB system components quickly and easily. DO NOT USE FOR PRODUCTION ENVIRONMENT! If YES the installation of all LB system components MUST AND WILL BE LOCAL! Use it?" 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.bash)! Essa # estratégia serve para mudarmos o comportamento do "ez_i.bash" # de acordo com as circunstâncias! By Questor FAST_INST=1 # NOTE: Essa variável é para consumo do "ez_i.bash", para que ele # não execute algumas funções e torne o processo de # instalação mais simples! By Questor EZ_I_SKIP_ON_V=1 fi f_close_section sleep 1 fi # < ----------------------------------------- # > ----------------------------------------- # Desabilita o SElinux! if [[ "$DISTRO_TYPE" == "RH" ]] ; then EZ_I_SKIP_ON_V=0 f_open_section f_div_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=$FAST_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=$FAST_INST f_open_section 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)" 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)" 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)" 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 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 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 "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 f_pack_is_inst "autoconf" "zypper" "\"autoconf\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install autoconf 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 F_COM_PKS_INSTALLED=1 fi } # < ----------------------------------------- # > ----------------------------------------- # Passa comando para serviços conforme a distro em execução! f_svc_helper() { : 'Passa comando para serviços conforme a distro em execução. Args: SVC_HLP_NM_P (str): Nome do serviço. SVC_HLP_CMD_P (str): Comando para o serviço executar. SVC_HLP_IN_SILENCE (Optional[int]): 1 - Sem saída para o terminal; 0 - Com saída para o terminal. Padrão 0. ' SVC_HLP_NM_P=$1 SVC_HLP_CMD_P=$2 SVC_HLP_IN_SILENCE=$3 if [ -z "$SVC_HLP_IN_SILENCE" ] ; then SVC_HLP_IN_SILENCE=0 fi SVC_HLP_SILENCE_CMD="" if [ ${SVC_HLP_IN_SILENCE} -eq 1 ] ; then SVC_HLP_SILENCE_CMD=" &>/dev/null" fi if [[ "$DISTRO_TYPE" == "RH" ]] ; then eval "systemctl $SVC_HLP_CMD_P $SVC_HLP_NM_P.service$SVC_HLP_SILENCE_CMD" elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then eval "service $SVC_HLP_NM_P $SVC_HLP_CMD_P$SVC_HLP_SILENCE_CMD" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then eval "service $SVC_HLP_NM_P $SVC_HLP_CMD_P$SVC_HLP_SILENCE_CMD" fi } # < ----------------------------------------- # > ----------------------------------------- # Abrir o firewall para uma porta definida para um dado serviço f_fire_hlp() { : 'Abrir o firewall para uma porta definida para um dado serviço. Args: FIRE_SVC_NM_P (str): Nome do serviço. FIRE_PORT_P (int): Porta a ser aberta. ' FIRE_SVC_NM_P=$1 FIRE_PORT_P=$2 if [[ "$DISTRO_TYPE" == "RH" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then EZ_I_SKIP_ON_V=$FAST_INST if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_div_section f_yes_no "Open firewall for $FIRE_SVC_NM_P (TCP $FIRE_PORT_P)?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_chk_iptables $FIRE_PORT_P "Port $FIRE_PORT_P is already open!" 0 "ACCEPT" "tcp" "NEW" if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then firewall-cmd --zone=public --add-port=$FIRE_PORT_P/tcp --permanent firewall-cmd --reload fi fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_div_section f_yes_no "Open firewall for $FIRE_SVC_NM_P (TCP $FIRE_PORT_P)?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_chk_iptables $FIRE_PORT_P "Port $FIRE_PORT_P is already open!" 0 "ACCEPT" "tcp" if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then SuSEfirewall2 open EXT TCP $FIRE_PORT_P SuSEfirewall2 stop SuSEfirewall2 start fi fi fi fi } # < ----------------------------------------- # > -------------------------------------------------------------------------- # INSTALAÇÃO DO ElasticSearch! # -------------------------------------- # > ----------------------------------------- # Instalar o ElasticSearch! ES_INST=0 ES_NAME="Elasticsearch 1.7.5" ES_SERV_CMD="/etc/init.d/elasticsearch" EZ_I_SKIP_ON_V=$FAST_INST f_open_section f_div_section f_yes_no "Install $ES_NAME?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then 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 f_common_packs if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_pack_is_inst "java-1.8.0-openjdk" "yum" "\"java-1.8.0-openjdk\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install java-1.8.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 f_div_section # NOTE: [ref.: https://stackoverflow.com/questions/16432300/how-to-config-single-node-for-single-cluster-standalone-cluster-elasticsearch]! By Questor f_yes_no "Use $ES_NAME as single node (standalone server) (\"y\" highly recommended)? * It will not be accessible to others servers (nodes) and will not discover others servers (nodes); * This prevents erroneous and improper replication of your indexes." if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then f_ez_sed "#http.jsonp.enable: true" "#http.jsonp.enable: true\n\n# It will not be accessible to others server (nodes) and will not discover\n# other server (nodes).\nnode.local: true" "/usr/local/elasticsearch/config/elasticsearch.yml" fi $ES_SERV_CMD start f_fire_hlp "elasticsearch" 9200 fi ES_INST=1 fi f_close_section # < ----------------------------------------- # < -------------------------------------------------------------------------- # > -------------------------------------------------------------------------- # INSTALAÇÃO DO POSTGRESQL! # -------------------------------------- # > ----------------------------------------- # Configurar o postgresql! CONF_PG=0 PG_USER_F="lbu" PG_PWD_F="lbu" f_conf_postgresql() { EZ_I_SKIP_ON_V=0 f_div_section f_yes_no "Configure $PG_NAME (use \"y\" if you never did it)?" PG_EXT_ACS_F="" if [[ "$DISTRO_TYPE" == "RH" ]] ; then PG_HBA_PATH="/var/lib/pgsql/9.4/data/pg_hba.conf" PG_CONF_PATH="/var/lib/pgsql/9.4/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=$FAST_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 QUESTION_F="Enter the $PG_NAME user for LBG - LBGenerator. Use empty for \"$PG_USER_F\"!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then PG_USER_F=$GET_USR_INPUT_R fi QUESTION_F="Enter the $PG_NAME password for \"$PG_USER_F\". Use empty for \"$PG_PWD_F\"!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then PG_PWD_F=$GET_USR_INPUT_R fi QUESTION_F="Enter one ip or ip range for external access. Use empty for local access only! * 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!" f_div_section 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 QUESTION_F="Enter the maximum number of $PG_NAME connections (numbers only, integers only). Use empty for $PG_CONNECTIONS connections (default)!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then PG_CONNECTIONS=$GET_USR_INPUT_R fi EZ_I_SKIP_ON_V=0 f_svc_helper "$PG_SERV_NAME" "start" 1 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=$FAST_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=$FAST_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 f_fl_cont_str "#max_connections = 100" "$PG_CONF_PATH" "The file \"$PG_CONF_PATH\" probably has already been changed to set \"maximum number connections\"! Check it!" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "max_connections = 100" "#max_connections = 100\nmax_connections = $PG_CONNECTIONS" "$PG_CONF_PATH" fi f_svc_helper "$PG_SERV_NAME" "restart" f_enter_to_cont "The files \"$PG_HBA_PATH\" and \"$PG_CONF_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 files \"$PG_HBA_PATH\" and \"$PG_CONF_PATH\" has settings for $PG_NAME! Check it for more details!" fi } # < ----------------------------------------- # > ----------------------------------------- # Instalar o postgresql! PG_INST=0 PG_NAME="" PG_SERV_NAME="" PG_PACK_NAME="" PG_CONNECTIONS=100 if [[ "$DISTRO_TYPE" == "RH" ]] ; then PG_NAME="PostgreSQL 9.4" PG_SERV_NAME="postgresql-9.4" if [[ "$DISTRO_NAME" == "RedHat" ]] ; then PG_PACK_NAME="pgdg-redhat94-9.4-3.noarch.rpm" else PG_PACK_NAME="pgdg-centos94-9.4-3.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=$FAST_INST f_open_section f_div_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 "postgresql94-server" "yum" "\"postgresql94-server\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y localinstall $PG_PACK_NAME yum -y install postgresql94-server /usr/pgsql-9.4/bin/postgresql94-setup initdb f_svc_helper "$PG_SERV_NAME" "enable" 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 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 fi fi f_svc_helper "$PG_SERV_NAME" "start" f_conf_postgresql f_fire_hlp "$PG_NAME" 5432 PG_INST=1 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 PG_DB_F="lb" f_open_section f_div_section f_yes_no "Create the basic LBG - LBGenerator data structures in $PG_NAME (use \"y\" if you never did it)?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$FAST_INST QUESTION_F="Enter the $PG_NAME database name for LBG - LBGenerator. Use empty for \"$PG_DB_F\" (recommended)!" f_div_section 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_R_HOLDER_0="" LINE_BREAKS_0="" EZ_I_SKIP_ON_V=$FAST_INST # NOTE: Define o "LC_COLLATE" e o "LC_CTYPE" para a database criada. # Não é necessário, mas se u usuário quiser, tem a opção! By Questor LC_C_PG="$LANG" f_div_section f_get_usr_input "Enter the \"LC_COLLATE\"/\"LC_CTYPE\" for \"$PG_DB_F\" database (E.g. en_US.UTF-8, pt_BR.UTF-8...). Use empty for \"$LANG\" (system default)!" 1 if [ -n "$GET_USR_INPUT_R" ] ; then LC_C_PG=$GET_USR_INPUT_R fi f_get_stderr_stdout "sudo -u postgres psql -c \"CREATE DATABASE $PG_DB_F WITH ENCODING = 'UTF8' TABLESPACE = pg_default LC_COLLATE = '$LC_C_PG' LC_CTYPE = '$LC_C_PG' CONNECTION LIMIT = -1;\"" F_GET_STDERR_R_HOLDER_0=$F_GET_STDERR_R_HOLDER_0$F_GET_STDERR_R f_get_stderr_stdout "sudo -u postgres psql -c \"ALTER DATABASE $PG_DB_F SET DateStyle = 'iso, dmy';\"" if [[ $F_GET_STDERR_R_HOLDER_0 != "" ]]; then LINE_BREAKS_0="\n\n" fi F_GET_STDERR_R_HOLDER_0=$F_GET_STDERR_R_HOLDER_0$LINE_BREAKS_0$F_GET_STDERR_R if [[ $F_GET_STDERR_R_HOLDER_0 != "" ]]; then if [[ $F_GET_STDERR_R_HOLDER_0 == *" already exists"* ]]; then EZ_I_SKIP_ON_V=$FAST_INST f_enter_to_cont "The database \"$PG_DB_F\" already created!" EZ_I_SKIP_ON_V=0 else EZ_I_SKIP_ON_V=0 f_div_section echo "Error when creating \"$PG_DB_F\" database! ERROR: \"$F_GET_STDERR_R_HOLDER_0\"." f_div_section f_error_exit fi else cd "$SCRIPTDIR_V" cp ./lbn-basic-dt-strt/lb_basic_dt_strt.sql /tmp cd /tmp chmod 700 lb_basic_dt_strt.sql chown postgres lb_basic_dt_strt.sql chown :postgres lb_basic_dt_strt.sql sudo -u postgres psql $PG_DB_F -f lb_basic_dt_strt.sql rm -f lb_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/lb_basic_dt_strt.sql\" has the basic LBG - LBGenerator data structures! Check it!" fi f_close_section # < ----------------------------------------- # < -------------------------------------------------------------------------- # > -------------------------------------------------------------------------- # INSTALAÇÃO DO LBG - LBGenerator! # -------------------------------------- BASE_INST_DIR_V="/usr/local/lb" # > ----------------------------------------- # Criar o diretório base da instalação! f_create_base_dir() { f_chk_by_path_hlp "$BASE_INST_DIR_V" "d" if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then mkdir -p "$BASE_INST_DIR_V" fi } # < ----------------------------------------- # > ----------------------------------------- # Instalar o python3.2! f_inst_py32() { : 'Instala a Python3.2! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST f_div_section fi f_yes_no "Install python3.2?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$FAST_INST 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 fi fi EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Instalar o virtualenv-1.11.6 no python3.2! f_inst_ve_py32() { : 'Instala o virtualenv-1.11.6 no python3.2! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST f_div_section fi 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 EZ_I_SKIP_ON_V=$FAST_INST 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 EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Criar o ambiente virtual (python3.2)! f_create_ve32() { : 'Cria o ambiente virtual (python3.2)! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja criar. Padrão 0. VE_NAME (str): Nome do virtualenv a ser criado. ' DONT_PROMPT_TO_INST=$1 VE_NAME=$2 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST fi f_enter_to_cont "Create the virtual environment (python3.2)!" EZ_I_SKIP_ON_V=$FAST_INST f_chk_by_path_hlp "$BASE_INST_DIR_V/$VE_NAME" "d" "Virtual environment (python3.2) already created in \"$BASE_INST_DIR_V/$VE_NAME\"!" 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 $VE_NAME mkdir "$BASE_INST_DIR_V/$VE_NAME/src" fi EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Determine an appropriate amount of processes! NPROCESSES=0 f_num_for_procs() { : 'Determine an appropriate amount of processes.' if (( NPROCESSES == 0 )) ; then f_get_stderr_stdout "nproc" if [[ $F_GET_STDERR_R == "" ]]; then # NOTE: Esse é o cálculo recomendado segundo algumas fontes. Eu # preferi fazer pelo dobro da quantidade de "cores" obtidas! # By Questor # (2 Workers * CPU Cores) + 1 # --------------------------- # Para 1 core -> (2*1)+1 = 3 # Para 2 cores -> (2*2)+1 = 5 # Para 4 cores -> (2*4)+1 = 9 NPROCESSES=$(( F_GET_STDOUT_R * 2 )) f_div_section f_get_usr_input "The recommended amount of processes to use on this server is \"$NPROCESSES\". Use empty for \"$NPROCESSES\" (recommended)!" 1 if [ -n "$GET_USR_INPUT_R" ] ; then NPROCESSES=$GET_USR_INPUT_R fi else f_enter_to_cont "An error occurred when trying to determine an appropriate amount of processes to use on this server! ERROR: \"$F_GET_STDERR_R$F_GET_STDOUT_R\"." f_error_exit fi fi } # < ----------------------------------------- # > ----------------------------------------- # Instalar o NGINX (nginx)! NGINX_INST=0 f_inst_nginx() { : 'Instala o Nginx e seta uma porta diferente se esse for o caso! Args: NGINX_PORT (Optional[int]): Porta a ser configurada para o Nginx. Padrão 8008. DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' NGINX_PORT=$1 if [ -z "$NGINX_PORT" ] ; then NGINX_PORT=8008 fi DONT_PROMPT_TO_INST=$2 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST f_div_section fi f_yes_no "Install NGINX as load balancer (\"y\" highly recommended)?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$FAST_INST f_common_packs if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_pack_is_inst "pcre-devel" "yum" "\"pcre-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then yum -y install pcre-devel fi elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_pack_is_inst "libpcre3-dev" "apt-get" "\"libpcre3-dev\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then apt-get -y install libpcre3-dev fi elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_pack_is_inst "pcre-devel" "zypper" "\"pcre-devel\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then zypper --non-interactive install pcre-devel fi fi cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps UP_NGINX=1 f_chk_by_path_hlp "/usr/sbin/nginx" "f" "\"NGINX\" already installed in \"/etc/nginx\"!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then f_div_section f_yes_no "Update/reinstall \"NGINX\"? (\"y\" recommended)" UP_NGINX=$YES_NO_R fi if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${UP_NGINX} -eq 1 ] ; then tar -zxvf nginx-1.8.1.tar.gz cd ./nginx-1.8.1 ./configure \ --user=nginx \ --group=nginx \ --prefix=/etc/nginx \ --sbin-path=/usr/sbin/nginx \ --conf-path=/etc/nginx/nginx.conf \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/run/nginx.lock \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-pcre \ --with-file-aio \ --with-http_realip_module make -j 4 && make install cd .. if [[ "$DISTRO_TYPE" == "DEB" ]] ; then mkdir "$NGINX_CONF_PATH" &>/dev/null mkdir "$NGINX_CONF_PATH_E" &>/dev/null elif [[ "$DISTRO_TYPE" == "RH" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then mkdir "$NGINX_CONF_PATH" &>/dev/null fi rm -rf ./nginx-1.8.1 fi # NOTE: Criar o usuário "nginx" caso não exista! By Questor if [ -z "`grep nginx /etc/passwd`" ]; then useradd -M -s /sbin/nologin nginx groupadd nginx &>/dev/null fi f_ez_mv_bak "/etc/nginx/nginx.conf" if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST fi f_enter_to_cont "Backup of \"/etc/nginx/nginx.conf\" original file on \"$F_BAK_PATH_R\"!" EZ_I_SKIP_ON_V=$FAST_INST \cp "$SCRIPTDIR_V/other-srcs-n-apps/nginx.conf-dist" "/etc/nginx/nginx.conf" # NOTE: Determinar um número adequado de processos! By Questor f_procs_qtt 2 f_ez_sed "" "$F_PROCS_QTT_R" "/etc/nginx/nginx.conf" f_ez_sed "" "$NGINX_PORT" "/etc/nginx/nginx.conf" if [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_ez_sed "" "\n include /etc/nginx/sites-enabled/*;" "/etc/nginx/nginx.conf" else f_ez_sed "" "" "/etc/nginx/nginx.conf" fi rm -rf "/etc/init.d/nginx" if [[ "$DISTRO_TYPE" == "RH" ]] ; then \cp "$SCRIPTDIR_V/other-srcs-n-apps/nginx-RHEL-dist" "/etc/init.d/nginx" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then \cp "$SCRIPTDIR_V/other-srcs-n-apps/nginx-DEB-dist" "/etc/init.d/nginx" elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then \cp "$SCRIPTDIR_V/other-srcs-n-apps/nginx-SLES-dist" "/etc/init.d/nginx" fi cd /etc/init.d/ if [[ "$DISTRO_TYPE" == "RH" ]] ; then chmod 755 nginx chkconfig --add nginx &>/dev/null chkconfig --level 345 nginx on elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then # TODO: A linha logo abaixo é realmente necessária? Rever p/ os outros instaladores tb! By Questor chmod 755 nginx chkconfig --add nginx &>/dev/null chkconfig --level 345 nginx on elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then update-rc.d -f nginx remove &>/dev/null chmod +x ./nginx update-rc.d nginx defaults fi f_svc_helper "nginx" "restart" 1 NGINX_INST=1 fi EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Instalar o Apache (httpd)! HTTPD_SERV_NAME="" HTTPD_USR="" HTTPD_GRP="" HTTPD_DEF_DOC_ROOT="" APACHE_INST=0 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 f_inst_apache() { : 'Instala o Apache e seta uma porta diferente se esse for o caso! Args: APACHE_PORT (Optional[int]): Porta a ser configurada para o Apache. Padrão 80. DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' APACHE_PORT=$1 if [ -z "$APACHE_PORT" ] ; then APACHE_PORT=80 fi DONT_PROMPT_TO_INST=$2 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST f_div_section fi f_yes_no "Install Apache ($HTTPD_SERV_NAME)?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$FAST_INST 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 f_svc_helper "$HTTPD_SERV_NAME" "enable" if (( $APACHE_PORT != 80 )); then f_fl_cont_str "# Listen 80" "$HTTPD_CONF_PATH_MAIN/httpd.conf" "The file \"$HTTPD_CONF_PATH_MAIN/httpd.conf\" probably has already been changed! Check it!" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "Listen 80" "# Listen 80\nListen $APACHE_PORT" "$HTTPD_CONF_PATH_MAIN/httpd.conf" fi fi 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 if (( $APACHE_PORT != 80 )); then f_fl_cont_str "# Listen 80" "$HTTPD_CONF_PATH_MAIN/ports.conf" "The file \"$HTTPD_CONF_PATH_MAIN/ports.conf\" probably has already been changed! Check it!" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "Listen 80" "# Listen 80\nListen $APACHE_PORT" "$HTTPD_CONF_PATH_MAIN/ports.conf" fi f_fl_cont_str "# " "$HTTPD_CONF_PATH/000-default.conf" "The file \"$HTTPD_CONF_PATH/000-default.conf\" probably has already been changed! Check it!" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "" "# \n" "$HTTPD_CONF_PATH/000-default.conf" rm -f "$HTTPD_CONF_PATH_E/000-default.conf" &>/dev/null ln -s "$HTTPD_CONF_PATH/000-default.conf" "$HTTPD_CONF_PATH_E/000-default.conf" &>/dev/null fi fi 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 if (( $APACHE_PORT != 80 )); then f_fl_cont_str "# Listen 80" "$HTTPD_CONF_PATH_MAIN/listen.conf" "The file \"$HTTPD_CONF_PATH_MAIN/listen.conf\" probably has already been changed! Check it!" if [ ${FL_CONT_STR_R} -eq 0 ] ; then f_ez_sed "Listen 80" "# Listen 80\nListen $APACHE_PORT" "$HTTPD_CONF_PATH_MAIN/listen.conf" 0 0 1 0 1 fi fi 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" f_svc_helper "$HTTPD_SERV_NAME" "restart" 1 APACHE_INST=1 fi EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Instalar o mod_wsgi-4.3.2! MOD_WSGI_PATH="" f_inst_mod_wsgi() { : 'Instala o mod_wsgi! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi 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 if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST f_div_section fi f_yes_no "Install mod_wsgi-4.3.2?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$FAST_INST 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" 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 EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Instalar as dependências python da LIB - liblightbase! f_inst_lib_py_packs() { : 'Instala a liblightbase! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST fi cd "$SCRIPTDIR_V" bash py-packs-liblightbase.bash "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V" EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Instalar as dependências python do uWSGI! f_inst_uwsgi_py_packs() { : 'Instala as dependências do uwsgi! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST fi cd "$SCRIPTDIR_V" bash py-packs-uwsgi.bash "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V" EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- UWSGI_INST=0 # > ----------------------------------------- # Instalar e configurar o uWSGI! f_inst_uwsgi() { : 'Instala o uWSGI! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST f_div_section fi f_yes_no "Install the uWSGI?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$FAST_INST f_inst_uwsgi_py_packs 1 rm -f "/etc/init.d/uwsgi" if [[ "$DISTRO_TYPE" == "RH" ]] ; then \cp "$SCRIPTDIR_V/other-srcs-n-apps/uwsgi-RHEL-dist" "/etc/init.d/uwsgi" elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then \cp "$SCRIPTDIR_V/other-srcs-n-apps/uwsgi-SLES-dist" "/etc/init.d/uwsgi" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then \cp "$SCRIPTDIR_V/other-srcs-n-apps/uwsgi-DEB-dist" "/etc/init.d/uwsgi" fi f_ez_sed "" "$BASE_INST_DIR_V/uwsgi_ve32" "/etc/init.d/uwsgi" 1 # NOTE: Criar o usuário "uwsgi" caso não exista! By Questor if [ -z "`grep uwsgi /etc/passwd`" ]; then useradd -M -s /sbin/nologin uwsgi groupadd uwsgi &>/dev/null fi cd /etc/init.d/ # NOTE: Cria configurações e diretórios para que o uWSGI opere no modo # "emperor"! By Questor mkdir -p "$BASE_INST_DIR_V/uwsgi_ve32/src/uWSGI/vassals" \cp "$SCRIPTDIR_V/other-srcs-n-apps/production.ini.uwsgi.srv-dist" "$BASE_INST_DIR_V/uwsgi_ve32/src/uWSGI/production.ini" f_ez_sed "" "$BASE_INST_DIR_V/uwsgi_ve32" "$BASE_INST_DIR_V/uwsgi_ve32/src/uWSGI/production.ini" if [[ "$DISTRO_TYPE" == "RH" ]] ; then chmod 755 uwsgi chkconfig --add uwsgi &>/dev/null chkconfig --level 345 uwsgi on elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then # TODO: A linha logo abaixo é realmente necessária? Rever p/ os outros instaladores tb! By Questor chmod 755 uwsgi chkconfig --add uwsgi &>/dev/null chkconfig --level 345 uwsgi on elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then update-rc.d -f uwsgi remove &>/dev/null chmod +x ./uwsgi update-rc.d uwsgi defaults fi f_svc_helper "uwsgi" "restart" 1 UWSGI_INST=1 fi EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Instalar a LIB - liblightbase! f_inst_lib() { : 'Instala a liblightbase! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST f_div_section fi f_yes_no "Install the LIB - liblightbase?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$FAST_INST f_chk_by_path_hlp "$BASE_INST_DIR_V/lbg_ve32/src/liblightbase" "d" "\"liblightbase\" already installed in \"$BASE_INST_DIR_V/lbg_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/lbg_ve32/src/liblightbase" "Backup old version and update? (\"y\" recommended)" fi if [ ${F_BAK_MD_R} -eq 1 ] ; then f_inst_lib_py_packs 1 cd "$SCRIPTDIR_V" tar -zxvf liblightbase.tar.gz mv "$SCRIPTDIR_V/liblightbase" "$BASE_INST_DIR_V/lbg_ve32/src/" cd "$BASE_INST_DIR_V/lbg_ve32/src/liblightbase" eval "$BASE_INST_DIR_V/lbg_ve32/bin/python3.2 setup.py install" fi fi EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Instalar as dependências python do LBG - LBGenerator! f_inst_lbg_py_packs() { : 'Instala as dependências do LBG - LBGenerator! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST fi cd "$SCRIPTDIR_V" bash py-packs-LBGenerator.bash "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V" EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > -------------------------------------------------------------------------- # Instalar o supervisor! # ----------------------------------------- # > ----------------------------------------- # Instalar o virtualenv-1.11.6 no python2.X! PYTHON_2_X="" VE_2_X="" f_inst_ve_py2X() { : 'Instala a virtualenv no Python2.X! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [[ "$DISTRO_TYPE" == "RH" ]] ; then PYTHON_2_X="2.7" VE_2_X="supervisor_ve27" elif [[ "$DISTRO_TYPE" == "DEB" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then PYTHON_2_X="2.7" VE_2_X="supervisor_ve27" fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST f_div_section fi f_yes_no "Install virtualenv-1.11.6 on python$PYTHON_2_X?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$FAST_INST if [[ "$DISTRO_TYPE" == "RH" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]] ; then f_chk_by_path_hlp "/usr/bin/virtualenv-$PYTHON_2_X" "f" "virtualenv-1.11.6 already installed!" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then f_chk_by_path_hlp "/usr/local/bin/virtualenv-$PYTHON_2_X" "f" "virtualenv-1.11.6 already installed!" fi 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 # >>>>>>>>>>>>> * Para "zypper --non-interactive install python-setuptools", se o problema abaixo aparecer... # Problem: python-setuptools-5.4.1-2.1.4.noarch requires python, but this requirement cannot be provided # uninstallable providers: python-2.7.8-1.1.x86_64[openSUSE-13.2-0] # python3-3.4.1-4.2.1.x86_64[openSUSE-13.2-0] # python-2.7.8-1.1.i586[repo-oss] # python3-3.4.1-4.2.1.i586[repo-oss] # python-2.7.8-1.1.x86_64[repo-oss] # python3-3.4.1-4.2.1.x86_64[repo-oss] # Solution 1: deinstallation of patterns-openSUSE-minimal_base-conflicts-20141007-2.1.x86_64 # Solution 2: do not install python-setuptools-5.4.1-2.1.4.noarch # Solution 3: do not install python-setuptools-5.4.1-2.1.4.noarch # Solution 4: break python-setuptools-5.4.1-2.1.4.noarch by ignoring some of its dependencies # Choose from above solutions by number or cancel [1/2/3/4/c] (c): # <<<<<<<<<<<<< # >>>>>>>>>>>>> * Usar 1 e y... # Choose from above solutions by number or cancel [1/2/3/4/c] (c): 1 # Resolving dependencies... # Resolving package dependencies... # The following 4 NEW packages are going to be installed: # libsqlite3-0 python python-setuptools python-xml # The following package is going to be REMOVED: # patterns-openSUSE-minimal_base-conflicts # The following pattern is going to be REMOVED: # minimal_base-conflicts # 4 new packages to install, 1 to remove. # Overall download size: 1.1 MiB. Already cached: 0 B After the operation, additional 4.2 MiB will be used. # Continue? [y/n/? shows all options] (y): # <<<<<<<<<<<<< # 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 # zypper --non-interactive install python-devel # fi f_pack_is_inst "python-setuptools" "zypper" "\"python-setuptools\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then f_get_stderr_stdout "zypper --non-interactive install python-setuptools" if [[ $F_GET_STDERR_R$F_GET_STDOUT_R == *"Problem: python-setuptools-"* ]] && [[ $F_GET_STDERR_R$F_GET_STDOUT_R == *".noarch requires python, but this requirement cannot be provided"* ]] ; then EZ_I_SKIP_ON_V=0 f_enter_to_cont "The package management \"zypper\" WILL ASK YOU FOR ADDITIONAL OPTIONS! We highly recommended you answer \"1\" and \"y\", respectively!" EZ_I_SKIP_ON_V=$FAST_INST zypper install python-setuptools zypper --non-interactive install python-devel else echo "$F_GET_STDERR_R$F_GET_STDOUT_R" fi fi fi f_common_packs cd "$SCRIPTDIR_V" cd ./other-srcs-n-apps tar -zxvf virtualenv-1.11.6.tar.gz cd virtualenv-1.11.6 python$PYTHON_2_X setup.py install cd .. rm -rf virtualenv-1.11.6 fi fi EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Criar o ambiente virtual (python2.X)! f_create_ve2X() { : 'Cria o ambiente virtual (python2.X)! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja criar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST fi f_enter_to_cont "Create the virtual environment (python$PYTHON_2_X)!" EZ_I_SKIP_ON_V=$FAST_INST f_chk_by_path_hlp "$BASE_INST_DIR_V/$VE_2_X" "d" "Virtual environment (python$PYTHON_2_X) already created in \"$BASE_INST_DIR_V/$VE_2_X\"!" if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then f_common_packs cd "$BASE_INST_DIR_V" virtualenv-$PYTHON_2_X $VE_2_X mkdir "$BASE_INST_DIR_V/$VE_2_X/src" fi EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- # > ----------------------------------------- # Instalar as dependências python do supervisor! f_inst_supervisor_py_packs() { : 'Instala as dependências do supervisor! Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST fi cd "$SCRIPTDIR_V" bash py-packs-supervisor.bash "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V" "$PYTHON_2_X" "$VE_2_X" EZ_I_SKIP_ON_V=$FAST_INST } # < ----------------------------------------- SVISOR_PORT=9001 SVISOR_USER="lbu" SVISOR_PWD="lbu" SVISOR_INST=0 PROC_MAX_MEM_PERC=60 # > ----------------------------------------- # Instalar e configurar o supervisor! f_inst_supervisor(){ : 'Instalar e configurar o supervisor. Args: DONT_PROMPT_TO_INST (Optional[int]): Não questiona o usuário se deseja instalar. Padrão 0. ' DONT_PROMPT_TO_INST=$1 if [ -z "$DONT_PROMPT_TO_INST" ] ; then DONT_PROMPT_TO_INST=0 fi if [ ${DONT_PROMPT_TO_INST} -eq 1 ] || [ ${FAST_INST} -eq 1 ] ; then EZ_I_SKIP_ON_V=1 else EZ_I_SKIP_ON_V=$FAST_INST f_div_section fi f_yes_no "Install supervisor?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then EZ_I_SKIP_ON_V=$FAST_INST f_inst_ve_py2X 1 f_create_ve2X 1 f_chk_by_path_hlp "$BASE_INST_DIR_V/$VE_2_X/src/supervisor" "d" "\"supervisor\" already installed in \"$BASE_INST_DIR_V/$VE_2_X/src/supervisor\"!" UP_SUPERVISOR=1 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then f_div_section f_yes_no "Update/reinstall \"supervisor\"? (\"y\" recommended)" UP_SUPERVISOR=$YES_NO_R fi if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${UP_SUPERVISOR} -eq 1 ] ; then f_inst_supervisor_py_packs 1 # NOTE: Configurar a aplicação supervisor! By Questor mkdir -p "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/apps" &>/dev/null f_ez_mv_bak "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/supervisord.conf" "" 1 0 1 f_ez_mv_bak "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/apps/lbg.conf" "" 1 0 1 \cp "$SCRIPTDIR_V/other-srcs-n-apps/supervisord.conf-dist" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/supervisord.conf" \cp "$SCRIPTDIR_V/other-srcs-n-apps/lbg.conf-supervisord-dist" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/apps/lbg.conf" f_ez_sed "" "$BASE_INST_DIR_V/lbg_ve32" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/apps/lbg.conf" 1 # NOTE: Determinar um número adequado de processos! By Questor f_procs_qtt 2 f_ez_sed "" "$F_PROCS_QTT_R" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/apps/lbg.conf" QUESTION_F="Enter the port number for Supervisor service. Use empty for \"$SVISOR_PORT\" (recommended)!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then SVISOR_PORT=$GET_USR_INPUT_R fi f_ez_sed "" "$SVISOR_PORT" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/supervisord.conf" QUESTION_F="Enter the Supervisor user. Use empty for \"$SVISOR_USER\"!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then SVISOR_USER=$GET_USR_INPUT_R fi QUESTION_F="Enter the Supervisor password for \"$SVISOR_USER\". Use empty for \"$SVISOR_PWD\"!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then SVISOR_PWD=$GET_USR_INPUT_R fi f_ez_sed "" "$SVISOR_USER" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/supervisord.conf" f_ez_sed "" "$SVISOR_PWD" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/supervisord.conf" f_ez_sed "" "$BASE_INST_DIR_V/$VE_2_X" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/supervisord.conf" 1 # NOTE: Calcula o máximo de memória que o LBG - LBGenerator pode usar do # servidor! By Questor f_div_section f_get_usr_input "Enter the LBG - LBGenerator MAXIMUM PERCENT server RAM memory usage (numbers only, integers only). Use empty for \"$PROC_MAX_MEM_PERC\" (good for most cases)! * Higher values will cause server instability, crash and other unexpected results; * Lower values will cause LBG - LBGenerator service instability, crash and other unexpected results." 1 if [ -n "$GET_USR_INPUT_R" ] ; then PROC_MAX_MEM_PERC=$GET_USR_INPUT_R fi f_srv_memory f_get_percent_from "$F_SRV_MEMORY_R" "$PROC_MAX_MEM_PERC" PROC_MAX_MEM=$F_GET_PERCENT_FROM_R f_ez_sed "" "$PROC_MAX_MEM" "$BASE_INST_DIR_V/$VE_2_X/src/supervisor/supervisord.conf" rm -f "/etc/init.d/supervisord" if [[ "$DISTRO_TYPE" == "RH" ]] ; then \cp "$SCRIPTDIR_V/other-srcs-n-apps/supervisord-RHEL-dist" "/etc/init.d/supervisord" elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then \cp "$SCRIPTDIR_V/other-srcs-n-apps/supervisord-SLES-dist" "/etc/init.d/supervisord" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then \cp "$SCRIPTDIR_V/other-srcs-n-apps/supervisord-DEB-dist" "/etc/init.d/supervisord" fi f_ez_sed "" "$BASE_INST_DIR_V/$VE_2_X" "/etc/init.d/supervisord" 1 # NOTE: Criar o usuário "supervisord" caso não exista! By Questor if [ -z "`grep supervisord /etc/passwd`" ]; then useradd -M -s /sbin/nologin supervisord groupadd supervisord &>/dev/null fi cd /etc/init.d/ if [[ "$DISTRO_TYPE" == "RH" ]] ; then chmod 755 supervisord chkconfig --add supervisord &>/dev/null chkconfig --level 345 supervisord on elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then # TODO: A linha logo abaixo é realmente necessária? Rever p/ os outros instaladores tb! By Questor chmod 755 supervisord chkconfig --add supervisord &>/dev/null chkconfig --level 345 supervisord on elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then update-rc.d -f supervisord remove &>/dev/null chmod +x ./supervisord update-rc.d supervisord defaults fi f_svc_helper "supervisord" "restart" # NOTE: Abrir firewall p/ o supervisor! By Questor f_fire_hlp "supervisor" $SVISOR_PORT SVISOR_INST=1 f_close_main_section fi fi } # < ----------------------------------------- # < -------------------------------------------------------------------------- # > ----------------------------------------- # Instalar o LBG - LBGenerator! VAR_LOG_HTTPD="" 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 ERROR_LOG_FL="" if [[ "$DISTRO_TYPE" == "RH" ]] || [[ "$DISTRO_TYPE" == "SUSE" ]]; then ERROR_LOG_FL="error_log" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then ERROR_LOG_FL="error.log" fi LBG_INST=0 HTTPD_CONF_PATH="" EZ_I_SKIP_ON_V=$FAST_INST APP_ROOT_F="lbg" HTTP_SRV_WSGI="" HTTP_PORT_W=0 HTTP_PORT_A=0 NGINX_CONF_PATH="" HTTPD_CONF_PATH_MAIN="" HTTPD_CONF_PATH_E="" f_open_main_section f_div_section f_yes_no "Install the LBG - LBGenerator?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then # NOTE: As funções abaixo provêm recursos necessários ao # LBG - LBGenerator! By Questor f_create_base_dir f_inst_py32 1 f_inst_ve_py32 1 f_create_ve32 1 "lbg_ve32" if [[ "$DISTRO_TYPE" == "DEB" ]] ; then NGINX_CONF_PATH="/etc/nginx/sites-available" NGINX_CONF_PATH_E="/etc/nginx/sites-enabled" else NGINX_CONF_PATH="/etc/nginx/conf.d" fi if [[ "$DISTRO_TYPE" == "RH" ]] ; then HTTPD_CONF_PATH="/etc/httpd/conf.d" HTTPD_CONF_PATH_MAIN="/etc/httpd/conf" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then HTTPD_CONF_PATH="/etc/apache2/sites-available" HTTPD_CONF_PATH_E="/etc/apache2/sites-enabled" HTTPD_CONF_PATH_MAIN="/etc/apache2" elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then HTTPD_CONF_PATH="/etc/apache2/conf.d" HTTPD_CONF_PATH_MAIN="/etc/apache2" fi OPT_ARR=("u" "NGINX and uWSGI" "p" "NGINX and pserver" "a" "Apache (httpd) and mod_wsgi") f_div_section f_get_usr_input_mult "Environment with (u) NGINX and uWSGI (highly recommended) or with (p) NGINX and pserver or with (a) Apache (httpd) and mod_wsgi? (use \"u\" or empty for NGINX and uWSGI)" OPT_ARR[@] 1 HTTP_SRV_WSGI="$GET_USR_INPUT_MULT_R" if [ -z "$GET_USR_INPUT_MULT_R" ] || [ ${FAST_INST} -eq 1 ] ; then HTTP_SRV_WSGI="u" fi case "$HTTP_SRV_WSGI" in u) QUESTION_F="Enter the port number for NGINX service. Use empty for \"$HTTP_PORT_W\" (recommended)!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then HTTP_PORT_W=$GET_USR_INPUT_R fi f_inst_nginx $HTTP_PORT_W 1 f_fire_hlp "NGINX" $HTTP_PORT_W ;; p) QUESTION_F="Enter the port number for NGINX service. Use empty for \"$HTTP_PORT_W\" (recommended)!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then HTTP_PORT_W=$GET_USR_INPUT_R fi f_inst_nginx $HTTP_PORT_W 1 f_fire_hlp "NGINX" $HTTP_PORT_W ;; a) QUESTION_F="Enter the port number for Apache (httpd) service. Use empty for \"$HTTP_PORT_W\" (recommended)!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then HTTP_PORT_W=$GET_USR_INPUT_R fi f_inst_apache $HTTP_PORT_W 1 f_inst_mod_wsgi 1 # NOTE: Este pequeno ajuste é necessário para que o "python3.2" funcione # no "CentOS 7"! By Questor if [[ "$DISTRO_TYPE" == "RH" ]] ; then f_fl_cont_str " g³" "/etc/mime.types" if [ ${FL_CONT_STR_R} -eq 1 ] ; then f_ez_sed " g³" "" "/etc/mime.types" fi fi f_fire_hlp "Apache (httpd)" $HTTP_PORT_W ;; esac f_inst_lib 1 f_inst_lbg_py_packs 1 f_chk_by_path_hlp "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator" "d" "\"LBGenerator\" already installed in \"$BASE_INST_DIR_V/lbg_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/lbg_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/lbg_ve32/src/" cd "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator" eval "$BASE_INST_DIR_V/lbg_ve32/bin/python3.2 setup.py install" PG_CFG_F="postgresql://$PG_USER_F:$PG_PWD_F@127.0.0.1/$PG_DB_F" QUESTION_F="Enter the postgresql LBG - LBGenerator configuration. Use empty for \"$PG_CFG_F\"!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then PG_CFG_F=$GET_USR_INPUT_R fi QUESTION_F="Enter the port number for LBG - LBGenerator service. Use empty for \"$HTTP_PORT_A\" (recommended)!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then HTTP_PORT_A=$GET_USR_INPUT_R fi f_fire_hlp "LBG - LBGenerator" $HTTP_PORT_A QUESTION_F="Enter the LBG - LBGenerator base URL. Use empty for \"$APP_ROOT_F\" (will result in http://:$HTTP_PORT_A/$APP_ROOT_F)!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then APP_ROOT_F=$GET_USR_INPUT_R fi SQLA_POOL_SIZE=0 SQLA_POOL_SIZE_MAX_OVERFLOW=0 f_get_percent_from "$PG_CONNECTIONS" "48" SQLA_POOL_SIZE=$F_GET_PERCENT_FROM_R SQLA_POOL_SIZE_MAX_OVERFLOW=$SQLA_POOL_SIZE # NOTE: Seta uma quantidade de threads adequada para o pool do # sqlalchemy! By Questor f_div_section f_get_usr_input "Enter the LBG - LBGenerator SQLALCHEMY POOL SIZE (numbers only, integers only). Use empty for \"$SQLA_POOL_SIZE\" (good for most cases)! * Use at most 48% of the number of PostgreSQL connections; * Decrease the value if you have other applications using PostgreSQL; * Higher values will cause LBG - LBGenerator and PostgreSQL services instability, crash and other unexpected results." 1 if [ -n "$GET_USR_INPUT_R" ] ; then SQLA_POOL_SIZE=$GET_USR_INPUT_R SQLA_POOL_SIZE_MAX_OVERFLOW=$SQLA_POOL_SIZE fi LBI_LBINDEX_URL="http://127.0.0.1:6543/" QUESTION_F="Enter the LBI - LBIndex http service URL. Use empty for \"$LBI_LBINDEX_URL\"!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then LBI_LBINDEX_URL=$GET_USR_INPUT_R fi ES_ESDEF_URL="http://127.0.0.1:9200" QUESTION_F="Enter the ES - ElasticSearch http service URL (don't use \"/\" at the end). Use empty for \"$ES_ESDEF_URL\"!" f_div_section f_get_usr_input "$QUESTION_F" 1 QUESTION_F="" if [ -n "$GET_USR_INPUT_R" ] ; then ES_ESDEF_URL=$GET_USR_INPUT_R fi if [[ "$HTTP_SRV_WSGI" == "u" ]] ; then eval "cp -f \"$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini.uwsgi-dist\" \"$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini\"" f_ez_sed "" "$SQLA_POOL_SIZE" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" 1 f_ez_sed "" "$SQLA_POOL_SIZE" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" 1 f_ez_sed "" "$LBI_LBINDEX_URL" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_ez_sed "" "$ES_ESDEF_URL" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_ez_sed "" "$PG_CFG_F" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" 1 f_ez_sed "" "$BASE_INST_DIR_V/lbg_ve32" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" 1 f_ez_sed "" "$APP_ROOT_F" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_procs_qtt 4 f_ez_sed "" "$F_PROCS_QTT_R" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" REQ_TIMEOUT=0 f_srv_memory f_bytes_n_units "$F_SRV_MEMORY_R" "KB" "MB" F_SRV_MEMORY_R_IN_MB=$F_BYTES_N_UNITS_R f_get_percent_from "$F_SRV_MEMORY_R_IN_MB" "44" REQ_TIMEOUT=$F_GET_PERCENT_FROM_R TOO_LOW_REQ_TIMEOUT=" (good for most cases)!" if (( ${REQ_TIMEOUT} < 400 )) ; then TOO_LOW_REQ_TIMEOUT=". * WARNING: THE INSTALLER HAS CALCULATED A TOO LOW TIMEOUT VALUE FOR THIS SERVER. TIMEOUTS BELOW 400 SECONDS ARE CONSIDERED TOO LOW. CONSIDER USING A SERVER WITH MORE RAM! " fi # NOTE: Calcula um valor de timeout conforme a quantidade de # memória RAM! By Questor f_div_section f_get_usr_input "Enter the HTTP REQUEST TIMEOUT in seconds (numbers only, integers only). Use empty for \"$REQ_TIMEOUT\"$TOO_LOW_REQ_TIMEOUT * Use a numeric value equivalent at most 44% of your server RAM in MB; * Decrease the value if you have other applications using your server; * Higher values will cause LBG - LBGenerator and PostgreSQL services instability, crash and other unexpected results." 1 if [ -n "$GET_USR_INPUT_R" ] ; then REQ_TIMEOUT=$GET_USR_INPUT_R fi f_ez_sed "" "$REQ_TIMEOUT" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" 1 f_get_percent_from "$F_SRV_MEMORY_R_IN_MB" "150" UWSGI_POST_BUFFERING=$F_GET_PERCENT_FROM_R f_ez_sed "" "$UWSGI_POST_BUFFERING" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_get_percent_from "$F_SRV_MEMORY_R_IN_MB" "70" UWSGI_RELOAD_ON_AS=$F_GET_PERCENT_FROM_R f_ez_sed "" "$UWSGI_RELOAD_ON_AS" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_get_percent_from "$F_SRV_MEMORY_R_IN_MB" "65" UWSGI_RELOAD_ON_RSS=$F_GET_PERCENT_FROM_R f_ez_sed "" "$UWSGI_RELOAD_ON_RSS" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_get_percent_from "$F_SRV_MEMORY_R_IN_MB" "85" UWSGI_EVIL_RELOAD_ON_AS=$F_GET_PERCENT_FROM_R f_ez_sed "" "$UWSGI_EVIL_RELOAD_ON_AS" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_get_percent_from "$F_SRV_MEMORY_R_IN_MB" "75" UWSGI_EVIL_RELOAD_ON_RSS=$F_GET_PERCENT_FROM_R f_ez_sed "" "$UWSGI_EVIL_RELOAD_ON_RSS" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_chk_by_path_hlp "$NGINX_CONF_PATH/lbg.conf" "f" "\"lbg.conf\" already created in \"$NGINX_CONF_PATH/lbg.conf\"!" F_BAK_MD_R=1 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then f_ez_mv_bak "$NGINX_CONF_PATH/lbg.conf" "Backup old version and update? (\"y\" recommended)" fi if [ ${F_BAK_MD_R} -eq 1 ] ; then \cp "$SCRIPTDIR_V/other-srcs-n-apps/lbg.conf-ngix-uwsgi-dist" "$NGINX_CONF_PATH/lbg.conf" f_ez_sed "" "$HTTP_PORT_A" "$NGINX_CONF_PATH/lbg.conf" f_ez_sed "" "$APP_ROOT_F" "$NGINX_CONF_PATH/lbg.conf" f_ez_sed "" "$BASE_INST_DIR_V/lbg_ve32" "$NGINX_CONF_PATH/lbg.conf" if [[ "$DISTRO_TYPE" == "DEB" ]] ; then ln -s "$NGINX_CONF_PATH/lbg.conf" "$NGINX_CONF_PATH_E/lbg.conf" &>/dev/null fi fi # NOTE: Cria um "virtualenv" exclusivo para o "uWSGI"! By Questor f_create_ve32 1 "uwsgi_ve32" f_inst_uwsgi 1 ln -nsf "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" "$BASE_INST_DIR_V/uwsgi_ve32/src/uWSGI/vassals/lbg.ini" f_svc_helper "nginx" "restart" 1 # TODO: Por alguma razão que eu não consegui entender de jeito # nenhum, o sistema só funciona corretamente se o "uwsgi" for # reiniciado duas vêzes! Tá tosco no último =[ ... Mas, não # consegui outra solução. Creio que a solução definitiva para o # problema e ajustar os esquemas de inicialização dos serviços ao # formato "systemctl", mas isso é bastante trabalhoso e vamos # deixar isso para uma outra etapa! By Questor f_svc_helper "uwsgi" "restart" 1 f_svc_helper "uwsgi" "restart" 1 elif [[ "$HTTP_SRV_WSGI" == "p" ]] ; then # TODO: E para pserver para lbg e lba juntos? Como está sendo # tratado? By Questor eval "cp -f \"$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini.pserver-dist\" \"$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini\"" f_ez_sed "" "$SQLA_POOL_SIZE" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" 1 f_ez_sed "" "$SQLA_POOL_SIZE" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" 1 f_ez_sed "" "$LBI_LBINDEX_URL" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_ez_sed "" "$ES_ESDEF_URL" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_ez_sed "" "$PG_CFG_F" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" 1 f_ez_sed "" "$APP_ROOT_F" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_chk_by_path_hlp "$NGINX_CONF_PATH/lbg.conf" "f" "\"lbg.conf\" already created in \"$NGINX_CONF_PATH/lbg.conf\"!" F_BAK_MD_R=1 if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then f_ez_mv_bak "$NGINX_CONF_PATH/lbg.conf" "Backup old version and update? (\"y\" recommended)" fi if [ ${F_BAK_MD_R} -eq 1 ] ; then \cp "$SCRIPTDIR_V/other-srcs-n-apps/lbg.conf-ngix-pserve-dist" "$NGINX_CONF_PATH/lbg.conf" # NOTE: Determinar um número adequado de processos! By Questor f_procs_qtt 2 UPSTREAM_LBG="" for (( i=0; i < F_PROCS_QTT_R; i++ )) ; do UPSTREAM_LBG=$UPSTREAM_LBG" server 127.0.0.1:500$i;\n" done f_ez_sed "" "$UPSTREAM_LBG" "$NGINX_CONF_PATH/lbg.conf" f_ez_sed "" "$APP_ROOT_F" "$NGINX_CONF_PATH/lbg.conf" f_ez_sed "" "$HTTP_PORT_A" "$NGINX_CONF_PATH/lbg.conf" if [[ "$DISTRO_TYPE" == "DEB" ]] ; then ln -s "$NGINX_CONF_PATH/lbg.conf" "$NGINX_CONF_PATH_E/lbg.conf" &>/dev/null fi fi f_svc_helper "nginx" "restart" 1 f_inst_supervisor 1 elif [[ "$HTTP_SRV_WSGI" == "a" ]] ; then eval "cp -f \"$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/lbgenerator.wsgi-dist\" \"$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/lbgenerator.wsgi\"" f_ez_sed "" "$BASE_INST_DIR_V/lbg_ve32" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/lbgenerator.wsgi" eval "cp -f \"$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini.apache-dist\" \"$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini\"" f_ez_sed "" "$SQLA_POOL_SIZE" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" 1 f_ez_sed "" "$SQLA_POOL_SIZE" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" 1 f_ez_sed "" "$LBI_LBINDEX_URL" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_ez_sed "" "$ES_ESDEF_URL" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" f_ez_sed "" "$PG_CFG_F" "$BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini" 1 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-apache-mod_wsgi-dist\" \"$HTTPD_CONF_PATH/lbg.conf\"" f_ez_sed "" "$HTTP_PORT_A" "$HTTPD_CONF_PATH/lbg.conf" f_ez_sed "" "$MOD_WSGI_PATH" "$HTTPD_CONF_PATH/lbg.conf" f_ez_sed "" "$BASE_INST_DIR_V/lbg_ve32" "$HTTPD_CONF_PATH/lbg.conf" 1 f_ez_sed "" "$APP_ROOT_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" f_ez_sed "" "AllowOverride None\n Require all granted" "$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" "$HTTPD_CONF_PATH_E/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" f_svc_helper "$HTTPD_SERV_NAME" "restart" 1 fi fi LBG_INST=1 fi f_close_main_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 o usuário seja # informado sobre quais foram as configurações de persistência setadas! # By Questor PERSIST_CONFIG="" if [ ${CONF_PG} -eq 1 ] || [ ${CREATE_LB_DT} -eq 1 ] ; then CREATE_LB_DT_VL="" if [ ${CREATE_LB_DT} -eq 1 ] ; then CREATE_LB_DT_VL=" database .. $PG_DB_F" fi CONF_PG_VL="" if [ ${CONF_PG} -eq 1 ] ; then CONF_PG_VL=" user ...... $PG_USER_F password .. $PG_PWD_F" fi if [ -n "$CONF_PG_VL$CREATE_LB_DT_VL" ] ; then PERSIST_CONFIG=" LBG - LBGenerator $PG_NAME persistence config...$CREATE_LB_DT_VL$CONF_PG_VL" fi fi PG_SVC_INFO="" if [ ${PG_INST} -eq 1 ] ; then if [[ "$DISTRO_TYPE" == "RH" ]] ; then PG_SVC_INFO=" $PG_NAME To start/stop... systemctl start $PG_SERV_NAME.service systemctl stop $PG_SERV_NAME.service" else PG_SVC_INFO=" $PG_NAME To start/stop... service $PG_SERV_NAME start service $PG_SERV_NAME stop" fi fi ES_SVC_INFO="" if [ ${ES_INST} -eq 1 ] ; then ES_SVC_INFO=" $ES_NAME To start/stop... $ES_SERV_CMD start $ES_SERV_CMD stop" fi UWSGI_SVC_INFO="" if [ ${UWSGI_INST} -eq 1 ] ; then UWSGI_SVC_SYNTAX="" if [[ "$DISTRO_TYPE" == "RH" ]] ; then UWSGI_SVC_SYNTAX="systemctl start uwsgi.service systemctl stop uwsgi.service" else UWSGI_SVC_SYNTAX="service uwsgi start service uwsgi stop" fi UWSGI_SVC_INFO=" uWSGI To start/stop... $UWSGI_SVC_SYNTAX To configure uWSGI... vi $BASE_INST_DIR_V/uwsgi_ve32/src/uWSGI/production.ini Log... less /var/log/uwsgi.log" fi SVISOR_SVC_INFO="" if [ ${SVISOR_INST} -eq 1 ] ; then SVISOR_SVC_SYNTAX="" if [[ "$DISTRO_TYPE" == "RH" ]] ; then SVISOR_SVC_SYNTAX="systemctl start supervisord.service systemctl stop supervisord.service" else SVISOR_SVC_SYNTAX="service supervisord start service supervisord stop" fi SVISOR_SVC_INFO=" Supervisor To start/stop... $SVISOR_SVC_SYNTAX To access... http://:$SVISOR_PORT user ...... $SVISOR_USER password .. $SVISOR_PWD To configure Supervisor... vi $BASE_INST_DIR_V/$VE_2_X/src/supervisor/supervisord.conf NOTE: The LBG - LBGenerator is set to use a maximum of $PROC_MAX_MEM_PERC% of server memory. For more details see section \"[eventlistener:memmon]\" in supervisord.conf! python$PYTHON_2_X virtual environment path... $BASE_INST_DIR_V/$VE_2_X" fi APACHE_SVC_INFO="" APACHE_SVC_INFO_DISTRO="" if [[ "$DISTRO_TYPE" == "RH" ]] ; then APACHE_SVC_INFO_DISTRO="vi $HTTPD_CONF_PATH_MAIN/httpd.conf" elif [[ "$DISTRO_TYPE" == "DEB" ]] ; then APACHE_SVC_INFO_DISTRO="vi $HTTPD_CONF_PATH_MAIN/ports.conf vi $HTTPD_CONF_PATH/000-default.conf" elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then APACHE_SVC_INFO_DISTRO="vi $HTTPD_CONF_PATH_MAIN/listen.conf" fi if [ ${APACHE_INST} -eq 1 ] ; then APACHE_SVC_SYNTAX="" if [[ "$DISTRO_TYPE" == "RH" ]] ; then APACHE_SVC_SYNTAX="systemctl start $HTTPD_SERV_NAME.service systemctl stop $HTTPD_SERV_NAME.service" else APACHE_SVC_SYNTAX="service $HTTPD_SERV_NAME start service $HTTPD_SERV_NAME stop" fi APACHE_SVC_INFO=" Apache ($HTTPD_SERV_NAME) To start/stop... $APACHE_SVC_SYNTAX To configure Apache ($HTTPD_SERV_NAME)... $APACHE_SVC_INFO_DISTRO To configure LBG on Apache ($HTTPD_SERV_NAME)... vi $HTTPD_CONF_PATH/lbg.conf Log... less $VAR_LOG_HTTPD/$ERROR_LOG_FL" fi NGINX_SVC_INFO="" if [ ${NGINX_INST} -eq 1 ] ; then NGINX_SVC_SYNTAX="" if [[ "$DISTRO_TYPE" == "RH" ]] ; then NGINX_SVC_SYNTAX="systemctl start nginx.service systemctl stop nginx.service" else NGINX_SVC_SYNTAX="service nginx start service nginx stop" fi NGINX_SVC_INFO=" NGINX To start/stop... $NGINX_SVC_SYNTAX To configure NGINX... vi /etc/nginx/nginx.conf To configure LBG on NGINX... vi $NGINX_CONF_PATH/lbg.conf Log... less /var/log/nginx/error.log" fi LBG_SVC_INFO="" if [ ${LBG_INST} -eq 1 ] ; then HTTP_URL_PORT="" if (( $HTTP_PORT_A != 80 )); then HTTP_URL_PORT=":$HTTP_PORT_A" fi LBG_LOG="" if [ ${APACHE_INST} -eq 1 ] ; then LBG_LOG=" Log... less /var/log/httpd/lbg-error.log" elif [ ${NGINX_INST} -eq 1 ] ; then LBG_LOG=" Log... less /var/log/lbg.log" fi LBG_SVC_INFO=" LBG To access... http://$HTTP_URL_PORT/$APP_ROOT_F To configure LBG... vi $BASE_INST_DIR_V/lbg_ve32/src/LBGenerator/production.ini$LBG_LOG python3.2 path... $BASE_INST_DIR_V/py32 python3.2 virtual environment path... $BASE_INST_DIR_V/lbg_ve32" fi if [ -n "$PG_SVC_INFO$ES_SVC_INFO$SVISOR_SVC_INFO$APACHE_SVC_INFO$NGINX_SVC_INFO$LBG_SVC_INFO" ] ; then # NOTE: First item! By Questor USEFUL_INFO_F="$PG_SVC_INFO" # TODO: Inserir a flag "-e" em todos "echos" de funcionalidades que # "printam" mensagens para o usuário no "ez_i.bash"? By Questor # NOTE: There is no way to represent a literal (\n in case) for "echo" # without using the "-e" flag! By Questor USEFUL_INFO_NEW_LINES=" " if [ -n "$USEFUL_INFO_F" ] && [ -n "$PERSIST_CONFIG" ] ; then USEFUL_INFO_F="$USEFUL_INFO_F$USEFUL_INFO_NEW_LINES" fi USEFUL_INFO_F="$USEFUL_INFO_F$PERSIST_CONFIG" if [ -n "$USEFUL_INFO_F" ] && [ -n "$ES_SVC_INFO" ] ; then USEFUL_INFO_F="$USEFUL_INFO_F$USEFUL_INFO_NEW_LINES" fi USEFUL_INFO_F="$USEFUL_INFO_F$ES_SVC_INFO" if [ -n "$USEFUL_INFO_F" ] && [ -n "$SVISOR_SVC_INFO" ] ; then USEFUL_INFO_F="$USEFUL_INFO_F$USEFUL_INFO_NEW_LINES" fi USEFUL_INFO_F="$USEFUL_INFO_F$SVISOR_SVC_INFO" if [ -n "$USEFUL_INFO_F" ] && [ -n "$UWSGI_SVC_INFO" ] ; then USEFUL_INFO_F="$USEFUL_INFO_F$USEFUL_INFO_NEW_LINES" fi USEFUL_INFO_F="$USEFUL_INFO_F$UWSGI_SVC_INFO" if [ -n "$USEFUL_INFO_F" ] && [ -n "$APACHE_SVC_INFO" ] ; then USEFUL_INFO_F="$USEFUL_INFO_F$USEFUL_INFO_NEW_LINES" fi USEFUL_INFO_F="$USEFUL_INFO_F$APACHE_SVC_INFO" if [ -n "$USEFUL_INFO_F" ] && [ -n "$NGINX_SVC_INFO" ] ; then USEFUL_INFO_F="$USEFUL_INFO_F$USEFUL_INFO_NEW_LINES" fi USEFUL_INFO_F="$USEFUL_INFO_F$NGINX_SVC_INFO" if [ -n "$USEFUL_INFO_F" ] && [ -n "$LBG_SVC_INFO" ] ; then USEFUL_INFO_F="$USEFUL_INFO_F$USEFUL_INFO_NEW_LINES" fi USEFUL_INFO_F="$USEFUL_INFO_F$LBG_SVC_INFO" else USEFUL_INFO_F=" Nothing was installed!" fi f_end "$TITLE_F" "$USEFUL_INFO_F" TITLE_F="" USEFUL_INFO_F="" # < --------------------------------------------------------------------------