diff --git a/.directory b/.directory index aa8713d..bb1f4ba 100644 --- a/.directory +++ b/.directory @@ -1,8 +1,5 @@ [Dolphin] PreviewsShown=true -Timestamp=2016,3,23,10,50,49 +Timestamp=2016,5,13,17,48,30 Version=3 ViewMode=1 - -[Settings] -HiddenFilesShown=true diff --git a/ez_i.sh b/ez_i.sh index 2ee740c..4e27d48 100755 --- a/ez_i.sh +++ b/ez_i.sh @@ -273,8 +273,9 @@ f_pack_is_inst() { Args: PACKAGE_NM_P (str): Nome do pacote. - PACK_MANAG (str): Tipo de gerenciador de pacotes. Apenas yum é - suportado. Em caso diverso o script exibe erro e para. + PACK_MANAG (str): Tipo de gerenciador de pacotes. "yum", + "apt-get" e "zypper" são suportados. Em caso diverso o script + exibe erro e para. EXIST_MSG_P (Optional[str]): Mensagem a ser exibida se o pacote já estiver instalado. Se vazio ou não informado não será exibida mensagem. @@ -309,6 +310,30 @@ f_pack_is_inst() { else F_PACK_IS_INST_R=0 fi + elif [ "$PACK_MANAG" == "apt-get" ] ; then + if dpkg -s "$PACKAGE_NM_P" &> /dev/null; then + if [ ${SKIP_MSG_P} -eq 0 ] && [ ! -z "$EXIST_MSG_P" ] ; then + f_div_section + echo "$EXIST_MSG_P" + f_div_section + f_enter_to_cont + fi + F_PACK_IS_INST_R=1 + else + F_PACK_IS_INST_R=0 + fi + elif [ "$PACK_MANAG" == "zypper" ] ; then + if zypper se -i --match-word "$PACKAGE_NM_P" > /dev/null 2>&1; then + if [ ${SKIP_MSG_P} -eq 0 ] && [ ! -z "$EXIST_MSG_P" ] ; then + f_div_section + echo "$EXIST_MSG_P" + f_div_section + f_enter_to_cont + fi + F_PACK_IS_INST_R=1 + else + F_PACK_IS_INST_R=0 + fi else f_div_section echo "ERROR! Not implemented for \"$PACK_MANAG\"!" @@ -462,6 +487,7 @@ f_is_not_running() { CHK_INVERT=0 fi F_IS_NOT_RUNNING_R=0 + # NOTE: A verificação "grep -v grep" é para que ele não dê positivo # para o próprio comando grep! By Questor F_IS_NOT_RUNNING_R=0 @@ -484,6 +510,7 @@ f_is_not_running() { F_GET_STDERR_R="" F_GET_STDOUT_R="" +F_GET_EXIT_CODE_R=0 f_get_stderr_stdout() { : 'Executar um comando e colocar a saída de stderr e stdout nas variáveis "F_GET_STDERR_R" e "F_GET_STDOUT_R"!. @@ -499,8 +526,9 @@ f_get_stderr_stdout() { CMD_TO_EXEC=$1 F_GET_STDERR_R="" F_GET_STDOUT_R="" - unset t_std t_err - eval "$( eval "$CMD_TO_EXEC" 2> >(t_err=$(cat); typeset -p t_err) > >(t_std=$(cat); typeset -p t_std) )" + unset t_std t_err t_ret + eval "$( eval "$CMD_TO_EXEC" 2> >(t_err=$(cat); typeset -p t_err) > >(t_std=$(cat); typeset -p t_std); t_ret=$?; typeset -p t_ret )" + F_GET_EXIT_CODE_R=$t_ret F_GET_STDERR_R=$t_err F_GET_STDOUT_R=$t_std } @@ -536,7 +564,6 @@ f_ez_mv_bak() { SKIP_MSG_P=1 fi - MK_BAK=1 F_BAK_PATH_R="" F_BAK_NAME_R="" @@ -565,6 +592,8 @@ f_error_exit() { ERROR_CAUSE_P (Optional[str]): Causa do erro. ' + EZ_I_S_ON_HOLDER=$EZ_I_SKIP_ON_V + EZ_I_SKIP_ON_V=0 ERROR_CAUSE_P=$1 echo f_open_section "E R R O R !" @@ -575,9 +604,40 @@ f_error_exit() { echo "$ERROR_MSG_NOW_P" echo f_close_section + EZ_I_SKIP_ON_V=$EZ_I_S_ON_HOLDER exit 1 } +f_warning_msg() { + : '"Printa" uma mensagem de aviso. + + Args: + WARNING_P (str): aviso. + ASK_FOR_CONT_P (Optional[int]): 1 - Checa se o usuário deseja + continuar com a instalação; 0 - Solicita que pressione "enter". + Padrão 0. + ' + + EZ_I_S_ON_HOLDER=$EZ_I_SKIP_ON_V + EZ_I_SKIP_ON_V=0 + WARNING_P=$1 + ASK_FOR_CONT_P=$2 + if [ -z "$ASK_FOR_CONT_P" ] ; then + ASK_FOR_CONT_P=0 + fi + echo + f_open_section "W A R N I N G !" + echo "$WARNING_P" + echo + f_close_section + if [ ${ASK_FOR_CONT_P} -eq 0 ] ; then + f_enter_to_cont + else + f_continue + fi + EZ_I_SKIP_ON_V=$EZ_I_S_ON_HOLDER +} + f_continue() { : 'Questionar ao usuário se deseja continuar ou parar a instalação. @@ -600,8 +660,344 @@ f_continue() { fi } +F_SPLIT_R=() +f_split() { + : 'Faz "split" em uma dada string e devolve um array. -# < -------------------------------------------------------------------------- + Args: + TARGET_P (str): String alvo do "split". + DELIMITER_P (Optional[str]): Delimitador usado no "split". + Se não informado o split vai ser feito por espaços em branco. + + Returns: + F_SPLIT_R (array): Array com a string fornecida separada pelo + delimitador informado. + ' + + F_SPLIT_R=() + TARGET_P=$1 + DELIMITER_P=$2 + if [ -z "$DELIMITER_P" ] ; then + DELIMITER_P=" " + fi + + REMOVE_N=1 + if [ "$DELIMITER_P" == "\n" ] ; then + REMOVE_N=0 + fi + + if [ ${REMOVE_N} -eq 1 ] ; then + + # NOTE: Devido a limitações do bash temos alguns problemas para + # poder obter a saída de um split via awk dentro de um array e + # por isso precisamos do uso da "quebra de linha" (\n) para + # termos sucesso! Visto isso, removemos as quebras de linha + # momentaneamente depois as reintegramos! By Questor + TARGET_P=$(echo "$TARGET_P" | awk 'BEGIN {RS="dn" } {gsub("\n","£§¢¬¨") ;printf $0 }') + fi + + SPLIT_NOW=$(awk -F"$DELIMITER_P" '{for(i=1;i<=NF;i++){printf "%s\n", $i}}' <<<"${TARGET_P}") + + while IFS= read -r LINE_NOW; do + if [ ${REMOVE_N} -eq 1 ] ; then + LN_NOW_WITH_N=$(awk 'BEGIN {RS="dn"} {gsub("£§¢¬¨","\n") ;printf $0 }' <<<"${LINE_NOW}") + F_SPLIT_R+=("$LN_NOW_WITH_N") + else + F_SPLIT_R+=("$LINE_NOW") + fi + done <<< "$SPLIT_NOW" +} + +F_ABOUT_DISTRO_R=() +f_about_distro() { + : 'Obter informações sobre a distro. + + Returns: + F_ABOUT_DISTRO_R (array): Array com informações sobre a + distro na seguinte ordem: NAME, VERSION, BASED e ARCH. + ' + + F_ABOUT_DISTRO_R=() + f_get_stderr_stdout "cat /etc/*-release" + ABOUT_INFO=$F_GET_STDOUT_R + + if [[ $ABOUT_INFO == *"ID=debian"* ]] ; then + f_split "$ABOUT_INFO" "\n" + F_SPLIT_R_0=("${F_SPLIT_R[@]}") + TOTAL_0=${#F_SPLIT_R_0[*]} + for (( i=0; i<=$(( $TOTAL_0 -1 )); i++ )) ; do + f_split "${F_SPLIT_R_0[$i]}" "=" + F_SPLIT_R_1=("${F_SPLIT_R[@]}") + TOTAL_1=${#F_SPLIT_R_1[*]} + for (( o=0; o<=$(( $TOTAL_1 -1 )); o++ )) ; do + p=$[$o+1] + case "${F_SPLIT_R_1[$o]}" in + "NAME") + f_split "${F_SPLIT_R_1[$p]}" "\"" + F_SPLIT_R_2=("${F_SPLIT_R[@]}") + F_ABOUT_DISTRO_R+=("${F_SPLIT_R_2[1]}") + ;; + "VERSION_ID") + f_split "${F_SPLIT_R_1[$p]}" "\"" + F_SPLIT_R_3=("${F_SPLIT_R[@]}") + F_ABOUT_DISTRO_R+=("${F_SPLIT_R_3[1]}") + ;; + *) + + ;; + esac + done + done + F_ABOUT_DISTRO_R+=("Debian") + elif [[ $ABOUT_INFO == *"ID=\"sles\""* ]] ; then + f_split "$ABOUT_INFO" "\n" + F_SPLIT_R_0=("${F_SPLIT_R[@]}") + TOTAL_0=${#F_SPLIT_R_0[*]} + for (( i=0; i<=$(( $TOTAL_0 -1 )); i++ )) ; do + f_split "${F_SPLIT_R_0[$i]}" "=" + F_SPLIT_R_1=("${F_SPLIT_R[@]}") + TOTAL_1=${#F_SPLIT_R_1[*]} + for (( o=0; o<=$(( $TOTAL_1 -1 )); o++ )) ; do + p=$[$o+1] + case "${F_SPLIT_R_1[$o]}" in + "NAME") + f_split "${F_SPLIT_R_1[$p]}" "\"" + F_SPLIT_R_2=("${F_SPLIT_R[@]}") + F_ABOUT_DISTRO_R+=("${F_SPLIT_R_2[1]}") + ;; + "VERSION_ID") + f_split "${F_SPLIT_R_1[$p]}" "\"" + F_SPLIT_R_3=("${F_SPLIT_R[@]}") + F_ABOUT_DISTRO_R+=("${F_SPLIT_R_3[1]}") + ;; + *) + + ;; + esac + done + done + F_ABOUT_DISTRO_R+=("Suse") + elif [[ $ABOUT_INFO == *"ID=opensuse"* ]] || + [[ $ABOUT_INFO == *"ID_LIKE=\"suse\""* ]] ; then + f_split "$ABOUT_INFO" "\n" + F_SPLIT_R_0=("${F_SPLIT_R[@]}") + TOTAL_0=${#F_SPLIT_R_0[*]} + for (( i=0; i<=$(( $TOTAL_0 -1 )); i++ )) ; do + f_split "${F_SPLIT_R_0[$i]}" "=" + F_SPLIT_R_1=("${F_SPLIT_R[@]}") + TOTAL_1=${#F_SPLIT_R_1[*]} + for (( o=0; o<=$(( $TOTAL_1 -1 )); o++ )) ; do + p=$[$o+1] + case "${F_SPLIT_R_1[$o]}" in + "NAME") + F_ABOUT_DISTRO_R+=("${F_SPLIT_R_1[$p]}") + ;; + "VERSION_ID") + f_split "${F_SPLIT_R_1[$p]}" "\"" + F_SPLIT_R_3=("${F_SPLIT_R[@]}") + F_ABOUT_DISTRO_R+=("${F_SPLIT_R_3[1]}") + ;; + *) + + ;; + esac + done + done + F_ABOUT_DISTRO_R+=("Suse") + elif [[ $ABOUT_INFO == *"DISTRIB_ID=Ubuntu"* ]] || + [[ $ABOUT_INFO == *"ID_LIKE=debian"* ]] ; then + f_split "$ABOUT_INFO" "\n" + F_SPLIT_R_0=("${F_SPLIT_R[@]}") + TOTAL_0=${#F_SPLIT_R_0[*]} + for (( i=0; i<=$(( $TOTAL_0 -1 )); i++ )) ; do + f_split "${F_SPLIT_R_0[$i]}" "=" + F_SPLIT_R_1=("${F_SPLIT_R[@]}") + TOTAL_1=${#F_SPLIT_R_1[*]} + for (( o=0; o<=$(( $TOTAL_1 -1 )); o++ )) ; do + p=$[$o+1] + case "${F_SPLIT_R_1[$o]}" in + "DISTRIB_ID") + F_ABOUT_DISTRO_R+=("${F_SPLIT_R_1[$p]}") + ;; + "DISTRIB_RELEASE") + F_ABOUT_DISTRO_R+=("${F_SPLIT_R_1[$p]}") + ;; + *) + + ;; + esac + done + done + F_ABOUT_DISTRO_R+=("Debian") + elif [[ $ABOUT_INFO == *"CentOS release "* ]] ; then + f_split "$ABOUT_INFO" "\n" + F_SPLIT_R_0=("${F_SPLIT_R[1]}") + f_split "${F_SPLIT_R_0[0]}" " " + F_SPLIT_R_1=("${F_SPLIT_R[@]}") + F_ABOUT_DISTRO_R+=("${F_SPLIT_R_1[0]}") + F_ABOUT_DISTRO_R+=("${F_SPLIT_R_1[2]}") + F_ABOUT_DISTRO_R+=("RedHat") + elif [[ $ABOUT_INFO == *"Red Hat Enterprise Linux Server release "* ]] ; then + f_split "$ABOUT_INFO" "\n" + F_SPLIT_R_0=("${F_SPLIT_R[1]}") + f_split "${F_SPLIT_R_0[0]}" " " + F_SPLIT_R_1=("${F_SPLIT_R[@]}") + F_ABOUT_DISTRO_R+=("Red Hat Enterprise Linux Server") + F_ABOUT_DISTRO_R+=("${F_SPLIT_R_1[6]}") + F_ABOUT_DISTRO_R+=("RedHat") + else + F_ABOUT_DISTRO_R+=("Unknown") + F_ABOUT_DISTRO_R+=("Unknown") + F_ABOUT_DISTRO_R+=("Unknown") + fi + F_ABOUT_DISTRO_R+=($(arch)) +} + +F_IS_ROOT_R=1 +f_is_root() { + : 'Checar se o usuário é root. + + Args: + CHK_ONLY_P (Optional[int]): 1 - Apenas verifica e retorna o + resultado; 0 - Se não for root emite erro e encerra a execução. + Padrão 0. + + Returns: + F_IS_ROOT_R (int): 1 - É root; 0 - Não é root. + ' + + CHK_ONLY_P=$1 + if [ -z "$CHK_ONLY_P" ] ; then + CHK_ONLY_P=0 + fi + + F_IS_ROOT_R=1 + if [[ $EUID -ne 0 ]]; then + f_enter_to_cont "ERROR! You need to be root!" + F_IS_ROOT_R=0 + if [ ${CHK_ONLY_P} -eq 0 ] ; then + f_error_exit + fi + fi +} + +F_CHK_DISTRO_STATUS_R="" +f_chk_distro_status() { + : 'Verifica se a distro informada está subscrita e/ou registrada + e/ou ativa perante os recursos informados. + + Args: + DISTRO_NAME_P (str): Nome da distro sobre a qual será executada + verificação. + RESOURCES_ARR_P (str): Array com a lista de recursos a serem + verificados na distro alvo. + + Returns: + F_CHK_DISTRO_STATUS_R (str): Possui a saída do comando de + verificação executado. + ' + + F_CHECK_RHEL_R="" + DISTRO_NAME_P=$1 + RESOURCES_ARR_P=("${!2}") + TOTAL_2=${#RESOURCES_ARR_P[*]} + + RES_OK_ARR=() + REDHAT_ACTV=0 + + CHK_RES_CMD="" + if [ "$DISTRO_NAME_P" == "RedHat" ] ; then + CHK_RES_CMD="subscription-manager list --consumed" + f_get_stderr_stdout "$CHK_RES_CMD" + f_split "$F_GET_STDOUT_R" "Subscription Name:" + elif [ "$DISTRO_NAME_P" == "SLES" ] ; then + CHK_RES_CMD="zypper sl" + f_get_stderr_stdout "$CHK_RES_CMD" + f_split "$F_GET_STDOUT_R" "\n" + fi + + F_SPLIT_R_0=("${F_SPLIT_R[@]}") + TOTAL_0=${#F_SPLIT_R_0[*]} + for (( i=0; i<=$(( $TOTAL_0 -1 )); i++ )) ; do + if [[ "$DISTRO_NAME_P" == "RedHat" ]] ; then + f_split "${F_SPLIT_R_0[$i]}" "\n" + F_SPLIT_R_1=("${F_SPLIT_R[@]}") + TOTAL_1=${#F_SPLIT_R_1[*]} + CHK_ACTV=0 + for (( o=0; o<=$(( $TOTAL_1 -1 )); o++ )) ; do + if [[ "${F_SPLIT_R_1[$o]}" == "Provides:"* ]] ; then + CHK_ACTV=1 + fi + if [ ${CHK_ACTV} -eq 1 ] ; then + for (( w=0; w<=$(( $TOTAL_2 -1 )); w++ )) ; do + if [[ "${F_SPLIT_R_1[$o]}" == *"${RESOURCES_ARR_P[$w]}" ]] ; then + RES_OK_ARR+=($w) + break + fi + done + if [ ${REDHAT_ACTV} -eq 0 ] && + [[ "${F_SPLIT_R_1[$o]}" == "Active:"* ]] && + [[ "${F_SPLIT_R_1[$o]}" == *"True" ]] ; then + REDHAT_ACTV=1 + fi + fi + done + elif [[ "$DISTRO_NAME_P" == "SLES" ]] ; then + REDHAT_ACTV=1 + f_split "${F_SPLIT_R_0[$i]}" "|" + F_SPLIT_R_1=("${F_SPLIT_R[@]}") + for (( w=0; w<=$(( $TOTAL_2 -1 )); w++ )) ; do + if [[ "${F_SPLIT_R_1[1]}" == *"${RESOURCES_ARR_P[$w]}"* ]] ; then + if [[ "${F_SPLIT_R_1[3]}" == *"Yes"* ]] ; then + if [[ "${F_SPLIT_R_1[5]}" == *"Yes"* ]] ; then + RES_OK_ARR+=($w) + break + fi + fi + fi + done + fi + done + + WARNINGS_MSGS=() + TOTAL_3=${#RES_OK_ARR[*]} + for (( z=0; z<=$(( $TOTAL_2 -1 )); z++ )) ; do + RES_OK_NOW=1 + for (( t=0; t<=$(( $TOTAL_3 -1 )); t++ )) ; do + if (( ${RES_OK_ARR[$t]} == $z )); then + RES_OK_NOW=0 + break + fi + done + if (( $RES_OK_NOW == 1 )); then + WARNINGS_MSGS+=("$DISTRO_NAME_P does not have access to this resource: \"${RESOURCES_ARR_P[$z]}\".") + fi + done + + TOTAL_4=${#WARNINGS_MSGS[*]} + WAR_MSGS_STR="" + USE_NEWLINE="" + if [ ! $TOTAL_4 -eq 0 ] || [ $REDHAT_ACTV -eq 0 ]; then + WAR_MSGS_STR="SOME PROBLEM APPEAR TO HAVE BEEN DETECTED ON" + if [[ "$DISTRO_NAME_P" == "RedHat" ]] ; then + WAR_MSGS_STR+=" REDHAT SUBSCRIPTION! " + elif [[ "$DISTRO_NAME_P" == "SLES" ]] ; then + WAR_MSGS_STR+=" SLES REGISTRATION! " + fi + WAR_MSGS_STR+="PLEASE CHECK IT!" + for (( y=0; y<=$(( $TOTAL_4 -1 )); y++ )) ; do + if (( $y == 0 )); then + WAR_MSGS_STR+=$'\n\n' + else + USE_NEWLINE=$'\n' + fi + WAR_MSGS_STR+="$USE_NEWLINE -> ${WARNINGS_MSGS[$y]}" + done + WAR_MSGS_STR+=$'\n\n'"FOR MORE INFORMATION TRY: \"$CHK_RES_CMD\"." + f_warning_msg "$WAR_MSGS_STR" 1 + fi + F_CHK_DISTRO_STATUS_R=$F_GET_STDOUT_R +} # > -------------------------------------------------------------------------- # GRAFICO! diff --git a/install.sh b/install.sh index bf660a9..37bd140 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,17 @@ #!/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 @@ -23,17 +35,27 @@ Have fun! =D EOF read -d '' WARNINGS_F <<"EOF" -- Installer designed for CentOS 6 AMD64/RHEL 6 AMD64! +- 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... - 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! + 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" @@ -62,13 +84,18 @@ TERMS_LICEN_F="" # < -------------------------------------------------------------------------- +# > ----------------------------------------- +# Checar se o usuário é root! + +f_is_root + +# < ----------------------------------------- + # > -------------------------------------------------------------------------- # INTRUÇÕES! # -------------------------------------- read -d '' INSTRUCT_F <<"EOF" -- To run this script YOU NEED to be root! - - TO CANCEL installation at any time use Ctrl+c! EOF @@ -77,6 +104,128 @@ 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! @@ -86,7 +235,7 @@ INSTRUCT_F="" SIMPLE_INST=0 if [ ${SIMPLE_INST} -eq 0 ] ; then f_open_section - f_yes_no "Use simple install (using a default value for most of the options)?" + 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 @@ -111,85 +260,93 @@ fi # Garantir o encodamento correto para evitar problemas de # compatibilidade! -EZ_I_SKIP_ON_V=$SIMPLE_INST -f_open_section -read -d '' TITLE_F <<"EOF" -Set terminal encode? (recommended for Windows terminal clients) -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" -if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then - export LANG=pt_BR.utf8 +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 -f_close_section # < ----------------------------------------- # > ----------------------------------------- # Desabilita o SElinux! -EZ_I_SKIP_ON_V=0 -f_open_section -read -d '' TITLE_F <<"EOF" -Disable SElinux (use "y" if you never did it)? -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" -if [ ${YES_NO_R} -eq 1 ] ; then - setenforce 0 - - # NOTE: As condições abaixo visam evitar que o arquivo seja - # desnecessariamente e erroneamente modificado! By Questor - EZ_I_SKIP_ON_V=$SIMPLE_INST - f_fl_cont_str "# SELINUX=enforcing" "/etc/sysconfig/selinux" "The file \"/etc/sysconfig/selinux\" probably has already been changed! Check it!" +if [[ "$DISTRO_TYPE" == "RH" ]] ; then EZ_I_SKIP_ON_V=0 - if [ ${FL_CONT_STR_R} -eq 0 ] ; then - f_fl_cont_str "SELINUX=disabled" "/etc/sysconfig/selinux" + 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_ez_sed "SELINUX=enforcing" "# SELINUX=enforcing\nSELINUX=disabled" "/etc/sysconfig/selinux" + 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 -f_close_section # < ----------------------------------------- # > ----------------------------------------- -# Instala os componentes de base usados pela especificação LightBase! +# Atualizar a distro (repositório)! EZ_I_SKIP_ON_V=$SIMPLE_INST -f_open_section -read -d '' TITLE_F <<"EOF" -Install base components? -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" -if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then - f_pack_is_inst "gcc-c++" "yum" "\"gcc-c++\" already installed!" - if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then - yum -y install gcc-c++ +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_pack_is_inst "zlib-devel" "yum" "\"zlib-devel\" already installed!" - if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then - yum -y install zlib-devel + 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 "openssl-devel" "yum" "\"openssl-devel\" already installed!" + f_pack_is_inst "git" "yum" "\"git\" already installed!" if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then - yum -y install openssl-devel + yum -y install git fi - f_pack_is_inst "postgresql-devel" "yum" "\"postgresql-devel\" already installed!" +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 - yum -y install postgresql-devel + apt-get -y install git fi - f_pack_is_inst "git" "yum" "\"git\" already installed!" +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 - yum -y install git + zypper --non-interactive install git-core fi fi -f_close_section # < ----------------------------------------- @@ -221,19 +378,130 @@ 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 -read -d '' TITLE_F <<"EOF" -Install python3.2? -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" +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 @@ -254,15 +522,11 @@ f_close_section EZ_I_SKIP_ON_V=$SIMPLE_INST f_open_section -read -d '' TITLE_F <<"EOF" -Install virtualenv-1.11.6 on python3.2? -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" +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 @@ -282,9 +546,25 @@ f_close_section 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" @@ -297,22 +577,57 @@ 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 -read -d '' TITLE_F <<"EOF" -Install Apache (httpd)? -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" +f_yes_no "Install Apache ($HTTPD_SERV_NAME)?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then - f_pack_is_inst "httpd-devel" "yum" "Apache (httpd) already installed!" - if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then - yum -y install httpd-devel httpd - chkconfig httpd on - chown -R apache /var/www - chmod -R 755 /var/www + 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 @@ -321,48 +636,69 @@ f_close_section # > ----------------------------------------- # Abrir o firewall para o Apache (httpd)! -EZ_I_SKIP_ON_V=$SIMPLE_INST -f_open_section -read -d '' TITLE_F <<"EOF" -Open firewall for Apache (httpd) (TCP 80)? -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" -if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then - f_chk_iptables 80 "Port 80 is already open!" 0 "ACCEPT" "tcp" "NEW" - if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then - iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT - service iptables save - service iptables restart +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 -f_close_section # < ----------------------------------------- # > ----------------------------------------- # 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 -read -d '' TITLE_F <<"EOF" -Install mod_wsgi-4.3.2? -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" +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 "include ld.so.conf.d/*.conf" "include ld.so.conf.d/*.conf\n$BASE_INST_DIR_V/py32/lib" "/etc/ld.so.conf" + 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 "/usr/lib64/httpd/modules/mod_wsgi.so" "f" "mod_wsgi already installed in \"/usr/lib64/httpd/modules/mod_wsgi.so\"!" + 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)" @@ -372,7 +708,7 @@ if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then TITLE_F="" UP_MOD_WSGI=$YES_NO_R if [ ${UP_MOD_WSGI} -eq 1 ] ; then - rm -rf "/usr/lib64/httpd/modules/mod_wsgi.so" + rm -rf "$MOD_WSGI_PATH" fi fi fi @@ -381,7 +717,8 @@ if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then 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 + make + make install cd .. rm -rf ./mod_wsgi-4.3.2 fi @@ -393,30 +730,51 @@ 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 -read -d '' TITLE_F <<"EOF" -Install ElasticSearch? -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" +f_yes_no "Install $ES_NAME?" if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then - f_pack_is_inst "elasticsearch.noarch" "yum" "ElasticSearch already installed!" - if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then - f_pack_is_inst "java-1.7.0-openjdk" "yum" "java-1.7.0-openjdk already installed!" - if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then - yum -y install java-1.7.0-openjdk + 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 - rpm -Uvh elasticsearch-1.1.1.noarch.rpm - /sbin/chkconfig --add elasticsearch - f_fl_cont_str "cluster.name: lb" "/etc/elasticsearch/elasticsearch.yml" "The file \"/etc/elasticsearch/elasticsearch.yml\" probably has already been changed! Check it!" - if [ ${FL_CONT_STR_R} -eq 0 ] ; then - f_ez_sed "# cluster.name: elasticsearch" "# cluster.name: elasticsearch\ncluster.name: lb" "/etc/elasticsearch/elasticsearch.yml" - fi - service elasticsearch start + 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 @@ -426,47 +784,102 @@ f_close_section # > ----------------------------------------- # Abrir o firewall para o ElasticSearch! -EZ_I_SKIP_ON_V=$SIMPLE_INST -f_open_section -read -d '' TITLE_F <<"EOF" -Open firewall for ElasticSearch (TCP 9200)? -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" -if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then - f_chk_iptables 9200 "Port 9200 is already open!" 0 "ACCEPT" "tcp" "NEW" - if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then - iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 9200 -j ACCEPT - service iptables save - service iptables restart +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 -f_close_section # < ----------------------------------------- # > ----------------------------------------- -# Instalar o postgres 9.4! - +# 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 -read -d '' TITLE_F <<"EOF" -Install postgres 9.4? -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" +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 - f_pack_is_inst "pgdg-centos94-9.4-1.noarch" "yum" "postgres 9.4 already installed!" - if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then - yum -y localinstall pgdg-centos94-9.4-1.noarch.rpm - yum -y install postgresql94-server - service postgresql-9.4 initdb - chkconfig postgresql-9.4 on - service postgresql-9.4 start + 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 @@ -474,24 +887,78 @@ f_close_section # < ----------------------------------------- # > ----------------------------------------- -# Configurar o postgres 9.4! +# 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 -TITLE_F="Configure postgres 9.4 (use \"y\" if you never did it)?" -f_yes_no "$TITLE_F" -TITLE_F="" +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 [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then + +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 postgres 9.4 user for lightbase (LBG). + QUESTION_F="Enter the $PG_NAME user for lightbase (LBG). Use empty for \"$PG_USER_F\"!" f_get_usr_input "$QUESTION_F" 1 @@ -502,7 +969,7 @@ Use empty for \"$PG_USER_F\"!" f_div_section - QUESTION_F="Enter the postgres 9.4 password for \"$PG_USER_F\". + QUESTION_F="Enter the $PG_NAME password for \"$PG_USER_F\". Use empty for \"$PG_PWD_F\"!" f_get_usr_input "$QUESTION_F" 1 @@ -524,6 +991,8 @@ Use empty for local access only!" 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 @@ -562,77 +1031,53 @@ Use empty for local access only!" f_error_exit fi fi - cd - >/dev/null + cd - &>/dev/null else f_error_exit fi EZ_I_SKIP_ON_V=$SIMPLE_INST if [ -n "$PG_EXT_ACS_F" ] ; then - f_fl_cont_str "host all all $PG_EXT_ACS_F trust" "/var/lib/pgsql/9.4/data/pg_hba.conf" "The file \"/var/lib/pgsql/9.4/data/pg_hba.conf\" probably has already been changed for external access! Check it!" + 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" "/var/lib/pgsql/9.4/data/pg_hba.conf" + 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" "/var/lib/pgsql/9.4/data/pg_hba.conf" "The file \"/var/lib/pgsql/9.4/data/pg_hba.conf\" probably has already been changed for local access! Check it!" + 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" "/var/lib/pgsql/9.4/data/pg_hba.conf" + 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 = '*'" "/var/lib/pgsql/9.4/data/postgresql.conf" "The file \"/var/lib/pgsql/9.4/data/postgresql.conf\" probably has already been changed! Check it!" + 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 = '*'" "/var/lib/pgsql/9.4/data/postgresql.conf" + f_ez_sed "# - Connection Settings -" "# - Connection Settings -\n\nlisten_addresses = '*'" "$PG_CONF_PATH" fi - service postgresql-9.4 restart - f_enter_to_cont "The file \"/var/lib/pgsql/9.4/data/pg_hba.conf\" has settings for postgres 9.4! Check it for more details!" + 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 \"/var/lib/pgsql/9.4/data/pg_hba.conf\" has settings for postgres 9.4! Check it!" -fi -f_close_section - -# < ----------------------------------------- - -# > ----------------------------------------- -# Abrir o firewall para o postgres 9.4! - -EZ_I_SKIP_ON_V=0 -f_open_section -read -d '' TITLE_F <<"EOF" -Open firewall for postgres 9.4 (TCP 5432)? -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" -if [ ${YES_NO_R} -eq 1 ] ; then - f_chk_iptables 5432 "Port 5432 is already open!" 0 "ACCEPT" "tcp" - if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then - iptables -I INPUT 1 -m tcp -p tcp --dport 5432 -j ACCEPT - service iptables save - service iptables restart - fi + 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 postgres 9.4! +# Criar as estruturas de dados básicas do LB no postgresql! CREATE_LB_DT=0 EZ_I_SKIP_ON_V=0 f_open_section -TITLE_F="Create the basic LightBase (LBG) data structures in postgres 9.4 (use \"y\" if you never did it)?" -f_yes_no "$TITLE_F" -TITLE_F="" +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 postgres 9.4 database name for LightBase (LBG). + 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 @@ -642,6 +1087,7 @@ Use empty for \"$PG_DB_F\" (recommended)!" 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;\"" @@ -682,7 +1128,7 @@ f_close_section EZ_I_SKIP_ON_V=$SIMPLE_INST cd "$SCRIPTDIR_V" -sh py-packs-liblightbase.sh "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V" +bash py-packs-liblightbase.sh "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V" # < ----------------------------------------- @@ -720,22 +1166,23 @@ f_close_section EZ_I_SKIP_ON_V=$SIMPLE_INST cd "$SCRIPTDIR_V" -sh py-packs-LBGenerator.sh "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_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 -read -d '' TITLE_F <<"EOF" -Install the LBG - LBGenerator? -EOF - -f_yes_no "$TITLE_F" -TITLE_F="" +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\"!" @@ -750,14 +1197,10 @@ if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then cd "$BASE_INST_DIR_V/ve32/src/LBGenerator" eval "$BASE_INST_DIR_V/ve32/bin/python3.2 setup.py install" - f_enter_to_cont "Configure httpd (Apache) for LBG - LBGenerator!" + f_enter_to_cont "Configure Apache ($HTTPD_SERV_NAME) for LBG - LBGenerator!" - # NOTE: To debug! By Questor - # PG_USER_F="lbu" - # PG_PWD_F="lbu" - # PG_DB_F="lb" PG_CFG_F="postgresql://$PG_USER_F:$PG_PWD_F@127.0.0.1/$PG_DB_F" - QUESTION_F="Enter the postgres 9.4 LBG configuration. + QUESTION_F="Enter the postgresql LBG configuration. Use empty for \"$PG_CFG_F\"!" f_div_section @@ -784,22 +1227,44 @@ Use empty for \"$APP_URL_F\" (used like e.g. http:///$APP_URL_F)!" eval "cp -f \"$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini-dist\" \"$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini\"" f_ez_sed "" "$PG_CFG_F" "$BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini" 1 - f_chk_by_path_hlp "/etc/httpd/conf.d/lbg.conf" "f" "\"lbg.conf\" already created in \"/etc/httpd/conf.d/lbg.conf\"!" + 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 "/etc/httpd/conf.d/lbg.conf" "Backup old version and update? (\"y\" recommended)" + 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\" \"/etc/httpd/conf.d/lbg.conf\"" - f_ez_sed "" "$BASE_INST_DIR_V/ve32" "/etc/httpd/conf.d/lbg.conf" 1 - f_ez_sed "" "$APP_URL_F" "/etc/httpd/conf.d/lbg.conf" 1 + 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 - eval "chown -R apache $BASE_INST_DIR_V" + 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 - service httpd restart fi fi f_close_section @@ -832,13 +1297,23 @@ if [ ${SIMPLE_INST} -eq 1 ] && ([ ${CONF_PG} -eq 1 ] || [ ${CREATE_LB_DT} -eq 1 fi PERSIST_CONFIG=" - LightBase (LBG) postgres 9.4 persistence config...$CREATE_LB_DT_VL$CONF_PG_VL + LightBase (LBG) $PG_NAME persistence config...$CREATE_LB_DT_VL$CONF_PG_VL " fi USEFUL_INFO_F=" To start/stop... - service httpd start - service httpd 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 @@ -847,10 +1322,10 @@ $PERSIST_CONFIG vi $BASE_INST_DIR_V/ve32/src/LBGenerator/production.ini To configure httpd (Apache)... - vi /etc/httpd/conf.d/lbg.conf + vi $HTTPD_CONF_PATH/lbg.conf Log... - less /var/log/httpd/error_log" + less $VAR_LOG_HTTPD/error_log" f_end "$TITLE_F" "$USEFUL_INFO_F" TITLE_F="" diff --git a/other-srcs-n-apps/elasticsearch-1.1.1.noarch.rpm b/other-srcs-n-apps/elasticsearch-1.1.1.noarch.rpm deleted file mode 100755 index 2ea2af8..0000000 Binary files a/other-srcs-n-apps/elasticsearch-1.1.1.noarch.rpm and /dev/null differ diff --git a/other-srcs-n-apps/elasticsearch-1.7.5.tar.gz b/other-srcs-n-apps/elasticsearch-1.7.5.tar.gz new file mode 100755 index 0000000..bf28da0 Binary files /dev/null and b/other-srcs-n-apps/elasticsearch-1.7.5.tar.gz differ diff --git a/other-srcs-n-apps/elasticsearch-servicewrapper-master.tar.gz b/other-srcs-n-apps/elasticsearch-servicewrapper-master.tar.gz new file mode 100755 index 0000000..7a4a1f8 Binary files /dev/null and b/other-srcs-n-apps/elasticsearch-servicewrapper-master.tar.gz differ diff --git a/other-srcs-n-apps/lbg.conf.dist b/other-srcs-n-apps/lbg.conf.dist index 17ce91d..b8431d5 100755 --- a/other-srcs-n-apps/lbg.conf.dist +++ b/other-srcs-n-apps/lbg.conf.dist @@ -1,7 +1,7 @@ # Use only 1 Python sub-interpreter. Multiple sub-interpreters # play badly with C extensions. -LoadModule wsgi_module /usr/lib64/httpd/modules/mod_wsgi.so +LoadModule wsgi_module WSGISocketPrefix /var/run/wsgi @@ -10,14 +10,13 @@ ServerName 127.0.0.1 WSGIApplicationGroup %{GLOBAL} WSGIPassAuthorization On -WSGIDaemonProcess user=apache group=apache threads=8 python-path=/lib/python3.2/site-packages +WSGIDaemonProcess user= group= threads=8 python-path=/lib/python3.2/site-packages WSGIScriptAlias / /src/LBGenerator/lbgenerator.wsgi > WSGIProcessGroup - Order allow,deny - Allow from all + -ErrorLog /var/log/httpd/neo-lightbase-error.log -CustomLog /var/log/httpd/neo-lightbase-access.log combined +ErrorLog /neo-lightbase-error.log +CustomLog /neo-lightbase-access.log combined diff --git a/other-srcs-n-apps/pgdg-centos93-9.3-2.noarch.rpm b/other-srcs-n-apps/pgdg-centos93-9.3-2.noarch.rpm new file mode 100755 index 0000000..dc1ee2a Binary files /dev/null and b/other-srcs-n-apps/pgdg-centos93-9.3-2.noarch.rpm differ diff --git a/other-srcs-n-apps/pgdg-centos94-9.4-1.noarch.rpm b/other-srcs-n-apps/pgdg-centos94-9.4-1.noarch.rpm deleted file mode 100755 index 0adcbab..0000000 Binary files a/other-srcs-n-apps/pgdg-centos94-9.4-1.noarch.rpm and /dev/null differ diff --git a/other-srcs-n-apps/pgdg-redhat93-9.3-2.noarch.rpm b/other-srcs-n-apps/pgdg-redhat93-9.3-2.noarch.rpm new file mode 100755 index 0000000..d2649be Binary files /dev/null and b/other-srcs-n-apps/pgdg-redhat93-9.3-2.noarch.rpm differ -- libgit2 0.21.2