Commit e0b3ad7cad8ca7135bdf7cd56aff7ac206682a7e

Authored by Eduardo Lúcio Amorim Costa
0 parents
Exists in master

Initial commit! By Questor

Showing 41 changed files with 1536 additions and 0 deletions   Show diff stats
LBIndex.tar.gz 0 → 100755
No preview for this file type
ez_i.sh 0 → 100755
  1 +++ a/ez_i.sh
... ... @@ -0,0 +1,823 @@
  1 +#!/bin/bash
  2 +: 'Trata-se de um módulo que oferece uma série de funcionalidades para
  3 +criar um instalador usando "bash".
  4 +
  5 +Apache License
  6 +Version 2.0, January 2004
  7 +http://www.apache.org/licenses/
  8 +Copyright 2016 Eduardo Lúcio Amorim Costa
  9 +'
  10 +
  11 +# NOTE: Obtêm a pasta do script atual para que seja usado como
  12 +# caminho base/referência durante a instalação! By Questor
  13 +EZ_I_DIR_V="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  14 +
  15 +# NOTE: Quando setado faz "ez_i" desabilitar algumas funções,
  16 +# notadamente aquelas que envolvem "perguntas ao usuário" e as
  17 +# gráficas! By Questor
  18 +EZ_I_SKIP_ON_V=0
  19 +
  20 +# > --------------------------------------------------------------------------
  21 +# UTILITÁRIOS!
  22 +# --------------------------------------
  23 +
  24 +f_enter_to_cont() {
  25 + : 'Solicitar ao usuário que pressione enter para continuar.
  26 +
  27 + Args:
  28 + INFO_P (Optional[str]): Se informado apresenta uma mensagem ao
  29 + usuário.
  30 + '
  31 +
  32 + INFO_P=$1
  33 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  34 + return 0
  35 + fi
  36 +
  37 + if [ ! -z "$INFO_P" ] ; then
  38 + f_div_section
  39 + echo "$INFO_P"
  40 + f_div_section
  41 + fi
  42 +
  43 + read -p "Press enter to continue..." nothing
  44 +}
  45 +
  46 +GET_USR_INPUT_R=""
  47 +f_get_usr_input() {
  48 + : 'Obter entradas digitadas pelo usuário.
  49 +
  50 + Permite autocomplete (tab). Enter para submeter a entrada.
  51 +
  52 + Args:
  53 + QUESTION_P (str): Pergunta a ser feita ao usuário.
  54 + ALLOW_EMPTY_P (Optional[int]): 0 - Não permite valor vazio; 1 - Permite
  55 + valor vazio. Padrão 0.
  56 +
  57 + Returns:
  58 + GET_USR_INPUT_R (str): Entrada digitada pelo usuário.
  59 + '
  60 +
  61 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  62 + return 0
  63 + fi
  64 + QUESTION_P=$1
  65 + ALLOW_EMPTY_P=$2
  66 + if [ -z "$ALLOW_EMPTY_P" ] ; then
  67 + ALLOW_EMPTY_P=0
  68 + fi
  69 + GET_USR_INPUT_R=""
  70 + read -e -r -p "$QUESTION_P (use enter to confirm): " RESP_V
  71 + if [ -n "$RESP_V" ] ; then
  72 + GET_USR_INPUT_R="$RESP_V"
  73 + elif [ ${ALLOW_EMPTY_P} -eq 0 ] ; then
  74 + f_get_usr_input "$QUESTION_P" 0
  75 + fi
  76 +}
  77 +
  78 +F_EZ_SED_ECP_R=""
  79 +f_ez_sed_ecp() {
  80 + : '"Escapar" strings para o comando "sed".
  81 +
  82 + Como há muitas semelhanças entre o escape para "sed" ("f_ez_sed") e
  83 + escape para "grep" ("f_fl_cont_str") optei por colocar essa
  84 + função como utilitária para as outras duas citadas.
  85 +
  86 + Args:
  87 + VAL_TO_ECP (str): Valor a ser "escapado".
  88 + DONT_ECP_NL (Optional[int]): 0 - Não "escapa" "\n" (quebra de
  89 + linha); 1 - "Escapa" "\n". Padrão 1.
  90 + DONT_ECP_SQ (Optional[int]): 0 - Não "escapa" "'" (aspas
  91 + simples); 1 - "Escapa" "'". Padrão 0. NOTE: Usado apenas pela
  92 + função "f_fl_cont_str".
  93 +
  94 + Returns:
  95 + F_EZ_SED_ECP_R (str): Valor "escapado".
  96 + '
  97 +
  98 + VAL_TO_ECP=$1
  99 + DONT_ECP_NL=$2
  100 + if [ -z "$DONT_ECP_NL" ] ; then
  101 + DONT_ECP_NL=1
  102 + fi
  103 + DONT_ECP_SQ=$3
  104 + if [ -z "$DONT_ECP_SQ" ] ; then
  105 + DONT_ECP_SQ=0
  106 + fi
  107 + F_EZ_SED_ECP_R=$VAL_TO_ECP
  108 + if [ ${DONT_ECP_NL} -eq 1 ] ; then
  109 + F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed 's/\\n/C0673CECED2D4A8FBA90C9B92B9508A8/g')
  110 + fi
  111 + F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed 's/[]\/$*.^|[]/\\&/g')
  112 + if [ ${DONT_ECP_SQ} -eq 0 ] ; then
  113 + F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed "s/'/\\\x27/g")
  114 + fi
  115 + if [ ${DONT_ECP_NL} -eq 1 ] ; then
  116 + F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed 's/C0673CECED2D4A8FBA90C9B92B9508A8/\\n/g')
  117 + fi
  118 +}
  119 +
  120 +f_ez_sed() {
  121 + : 'Facilitar o uso da funcionalidade "sed".
  122 +
  123 + Args:
  124 + TARGET (str): Valor a ser substituído por pelo valor de REPLACE.
  125 + REPLACE (str): Valor que irá substituir TARGET.
  126 + FILE (str): Arquivo no qual será feita a substituição.
  127 + ALL_OCCUR (Optional[int]): 0 - Fazer replace apenas na primeira
  128 + ocorrência; 1 - Fazer replace em todas as ocorrências. Padrão 0.
  129 + DONT_ESCAPE (Optional[int]): 0 - Faz escape das strings em
  130 + TARGET e REPLACE; 1 - Não faz escape das strings em TARGET e
  131 + REPLACE. Padrão 0.
  132 + DONT_ECP_NL (Optional[int]): 1 - Não "escapa" "\n" (quebra de
  133 + linha); 0 - "Escapa" "\n". Padrão 1.
  134 + REMOVE_LN (Optional[int]): 1 - Remove a linha que possui o
  135 + valor em TARGET; 0 - Faz o replace convencional. Padrão 0.
  136 + '
  137 +
  138 + FILE=$3
  139 + ALL_OCCUR=$4
  140 + if [ -z "$ALL_OCCUR" ] ; then
  141 + ALL_OCCUR=0
  142 + fi
  143 + DONT_ESCAPE=$5
  144 + if [ -z "$DONT_ESCAPE" ] ; then
  145 + DONT_ESCAPE=0
  146 + fi
  147 + DONT_ECP_NL=$6
  148 + if [ -z "$DONT_ECP_NL" ] ; then
  149 + DONT_ECP_NL=1
  150 + fi
  151 + REMOVE_LN=$7
  152 + if [ -z "$REMOVE_LN" ] ; then
  153 + REMOVE_LN=0
  154 + fi
  155 + if [ ${DONT_ESCAPE} -eq 1 ] ; then
  156 + TARGET=$1
  157 + REPLACE=$2
  158 + else
  159 + f_ez_sed_ecp "$1" $DONT_ECP_NL
  160 + TARGET=$F_EZ_SED_ECP_R
  161 + f_ez_sed_ecp "$2" $DONT_ECP_NL
  162 + REPLACE=$F_EZ_SED_ECP_R
  163 + fi
  164 + if [ ${REMOVE_LN} -eq 1 ] ; then
  165 + if [ ${ALL_OCCUR} -eq 0 ] ; then
  166 + SED_RPL="'0,/$TARGET/{//d;}'"
  167 + else
  168 + SED_RPL="'/$TARGET/d'"
  169 + fi
  170 + eval "sed -i $SED_RPL $FILE"
  171 + else
  172 + if [ ${ALL_OCCUR} -eq 0 ] ; then
  173 + SED_RPL="'0,/$TARGET/s//$REPLACE/g'"
  174 + else
  175 + SED_RPL="'s/$TARGET/$REPLACE/g'"
  176 + fi
  177 + eval "sed -i $SED_RPL $FILE"
  178 + fi
  179 +}
  180 +
  181 +FL_CONT_STR_R=0
  182 +f_fl_cont_str() {
  183 + : 'Checar se um arquivo contêm determinada string.
  184 +
  185 + Args:
  186 + STR_TO_CH (str): Valor de string a ser verificado.
  187 + FILE (str): Arquivo no qual será feita a verificação.
  188 + COND_MSG_P (Optional[str]): Mensagem a ser exibida se
  189 + verdadeira a verificação. Se vazio ou não informado não será
  190 + exibida mensagem.
  191 + CHK_INVERT (Optional[int]): Inverter a lógica da checagem.
  192 + Padrão 0.
  193 + DONT_ESCAPE (Optional[int]): 0 - Faz escape da string em
  194 + STR_TO_CH; 1 - Não faz escape das strings em STR_TO_CH. Padrão 0.
  195 + DONT_ECP_NL (Optional[int]): 1 - Não "escapa" "\n" (quebra de
  196 + linha); 0 - "Escapa" "\n". Padrão 1.
  197 +
  198 + Returns:
  199 + FL_CONT_STR_R (int): 1 - Se verdadeiro para a condição
  200 + analisada; 0 - Se falso para a condição analisada.
  201 + '
  202 +
  203 + STR_TO_CH=$1
  204 + FILE=$2
  205 + COND_MSG_P=$3
  206 + CHK_INVERT=$4
  207 + DONT_ESCAPE=$5
  208 +
  209 + if [ -z "$DONT_ESCAPE" ] ; then
  210 + DONT_ESCAPE=0
  211 + fi
  212 + if [ ${DONT_ESCAPE} -eq 0 ] ; then
  213 + DONT_ECP_NL=$6
  214 + if [ -z "$DONT_ECP_NL" ] ; then
  215 + DONT_ECP_NL=1
  216 + fi
  217 + f_ez_sed_ecp "$STR_TO_CH" $DONT_ECP_NL 1
  218 + STR_TO_CH=$F_EZ_SED_ECP_R
  219 + fi
  220 +
  221 + if [ -z "$CHK_INVERT" ] ; then
  222 + CHK_INVERT=0
  223 + fi
  224 + FL_CONT_STR_R=0
  225 + if [ ${CHK_INVERT} -eq 0 ] ; then
  226 + if grep -q "$STR_TO_CH" "$FILE"; then
  227 + FL_CONT_STR_R=1
  228 + fi
  229 + else
  230 + if ! grep -q "$STR_TO_CH" "$FILE"; then
  231 + FL_CONT_STR_R=1
  232 + fi
  233 + fi
  234 + if [ ${EZ_I_SKIP_ON_V} -eq 0 ] && [ ${FL_CONT_STR_R} -eq 1 ] && [ ! -z "$COND_MSG_P" ] ; then
  235 + f_div_section
  236 + echo "$COND_MSG_P"
  237 + f_div_section
  238 + f_enter_to_cont
  239 + fi
  240 +}
  241 +
  242 +CHK_FD_FL_R=0
  243 +f_chk_fd_fl() {
  244 + : 'Verificar se determinado diretório ou arquivo existe.
  245 +
  246 + Args:
  247 + TARGET (str): Diretório ou arquivo qual se quer verificar.
  248 + CHK_TYPE (str): "d" - Checar por diretório; "f" - Checar por
  249 + arquivo.
  250 +
  251 + Returns:
  252 + CHK_FD_FL_R (int): 1 - True; 0 - False.
  253 + '
  254 +
  255 + CHK_FD_FL_R=0
  256 + TARGET=$1
  257 + CHK_TYPE=$2
  258 + if [ "$CHK_TYPE" == "f" ] ; then
  259 + if [ -f "$TARGET" ] ; then
  260 + CHK_FD_FL_R=1
  261 + fi
  262 + fi
  263 + if [ "$CHK_TYPE" == "d" ] ; then
  264 + if [ -d "$TARGET" ] ; then
  265 + CHK_FD_FL_R=1
  266 + fi
  267 + fi
  268 +}
  269 +
  270 +F_PACK_IS_INST_R=0
  271 +f_pack_is_inst() {
  272 + : 'Checar se um pacote está instalado.
  273 +
  274 + Args:
  275 + PACKAGE_NM_P (str): Nome do pacote.
  276 + PACK_MANAG (str): Tipo de gerenciador de pacotes. Apenas yum é
  277 + suportado. Em caso diverso o script exibe erro e para.
  278 + EXIST_MSG_P (Optional[str]): Mensagem a ser exibida se o
  279 + pacote já estiver instalado. Se vazio ou não informado não será
  280 + exibida mensagem.
  281 + SKIP_MSG_P (Optional[int]): Omite a mensagem. Padrão 0.
  282 +
  283 + Returns:
  284 + F_PACK_IS_INST_R (int): 1 - Instalado; 0 - Não instalado.
  285 + '
  286 +
  287 + PACKAGE_NM_P=$1
  288 + PACK_MANAG=$2
  289 + EXIST_MSG_P=$3
  290 + SKIP_MSG_P=$4
  291 +
  292 + if [ -z "$SKIP_MSG_P" ] ; then
  293 + SKIP_MSG_P=0
  294 + fi
  295 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  296 + SKIP_MSG_P=1
  297 + fi
  298 +
  299 + F_PACK_IS_INST_R=0
  300 + if [ "$PACK_MANAG" == "yum" ] ; then
  301 + if yum list installed "$PACKAGE_NM_P" >/dev/null 2>&1; then
  302 + if [ ${SKIP_MSG_P} -eq 0 ] && [ ! -z "$EXIST_MSG_P" ] ; then
  303 + f_div_section
  304 + echo "$EXIST_MSG_P"
  305 + f_div_section
  306 + f_enter_to_cont
  307 + fi
  308 + F_PACK_IS_INST_R=1
  309 + else
  310 + F_PACK_IS_INST_R=0
  311 + fi
  312 + else
  313 + f_div_section
  314 + echo "ERROR! Not implemented for \"$PACK_MANAG\"!"
  315 + f_div_section
  316 + f_enter_to_cont
  317 + fi
  318 +}
  319 +
  320 +F_CHK_BY_PATH_HLP_R=0
  321 +f_chk_by_path_hlp() {
  322 + : 'Checar se um aplicativo/pacote/arquivo está presente/instalado
  323 + verificando-o através do seu caminho físico informando.
  324 +
  325 + Args:
  326 + PATH_VER_P (str): Caminho físico para o aplicativo/pacote.
  327 + VER_TYPE_P (str): Se o caminho físico é para um diretório ("d")
  328 + ou arquivo ("f").
  329 + EXIST_MSG_P (Optional[str]): Mensagem a ser "printada" caso o
  330 + aplicativo/pacote/arquivo exista. Se não informado ou vazio não
  331 + exibe a mensagem.
  332 + SKIP_MSG_P (Optional[int]): Não exibir mensagem.
  333 +
  334 + Returns:
  335 + F_CHK_BY_PATH_HLP_R (int): 0 - Não existe; 1 - Existe
  336 + ("printa" menssagem contida em EXIST_MSG_P).
  337 + '
  338 +
  339 + PATH_VER_P=$1
  340 + VER_TYPE_P=$2
  341 + EXIST_MSG_P=$3
  342 + SKIP_MSG_P=$4
  343 + if [ -z "$SKIP_MSG_P" ] ; then
  344 + SKIP_MSG_P=0
  345 + fi
  346 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  347 + SKIP_MSG_P=1
  348 + fi
  349 +
  350 + F_CHK_BY_PATH_HLP_R=0
  351 + f_chk_fd_fl "$PATH_VER_P" "$VER_TYPE_P"
  352 + if [ ${CHK_FD_FL_R} -eq 0 ] ; then
  353 + F_CHK_BY_PATH_HLP_R=0
  354 + else
  355 + if [ ${SKIP_MSG_P} -eq 0 ] && [ ! -z "$EXIST_MSG_P" ]; then
  356 + f_div_section
  357 + echo "$EXIST_MSG_P"
  358 + f_div_section
  359 + f_enter_to_cont
  360 + fi
  361 + F_CHK_BY_PATH_HLP_R=1
  362 + fi
  363 +}
  364 +
  365 +F_CHK_IPTABLES_R=0
  366 +f_chk_iptables() {
  367 + : 'Fazer verificações usando "iptables".
  368 +
  369 + Trata-se de um utilitário para fazer verificações diversas usando o
  370 + comando "iptables" NORMALMENTE CHECAR DE DETERMINADA PORTA ESTÁ
  371 + ABERTA.
  372 +
  373 + Ex 1.: f_chk_iptables 80
  374 + Ex 2.: f_chk_iptables 80 "Já está aberta!"
  375 + Ex 3.: f_chk_iptables 80 "Já está aberta!" 0 "ACCEPT" "tcp" "NEW"
  376 + Ex 4.: f_chk_iptables 80 "Já está aberta!" 0 "ACCEPT" "tcp" "NEW" 5
  377 +
  378 + Args:
  379 + PORT_P (int): Porta a ser verificada.
  380 + MSG_P (Optional[str]): Mensagem a ser exibida em caso de
  381 + verdadeiro para a verificação (normalmente porta aberta). Se vazio
  382 + ou não informado não será exibida mensagem.
  383 + SKIP_MSG_P (Optional[int]): Não exibir mensagem.
  384 + Padrão 0.
  385 + TARGET_P (Optional[str]): Padrão "ACCEPT".
  386 + PROT_P (Optional[str]): Padrão "tcp".
  387 + STATE_P (str): Padrão "".
  388 + POS_IN_CHAIN_P (int): Padrão "".
  389 +
  390 + Returns:
  391 + F_CHK_IPTABLES_R (int): 1 - Verdadeiro para a verificação;
  392 + 0 - Falso para a verificação.
  393 + '
  394 +
  395 + PORT_P=$1
  396 + MSG_P=$2
  397 + SKIP_MSG_P=$3
  398 +
  399 + if [ -z "$SKIP_MSG_P" ] ; then
  400 + SKIP_MSG_P=0
  401 + fi
  402 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  403 + SKIP_MSG_P=1
  404 + fi
  405 +
  406 + TARGET_P=$4
  407 + if [ -z "$TARGET_P" ] ; then
  408 + TARGET_P="ACCEPT"
  409 + fi
  410 + PROT_P=$5
  411 + if [ -z "$PROT_P" ] ; then
  412 + PROT_P="tcp"
  413 + fi
  414 + STATE_P=$6
  415 + if [ -z "$STATE_P" ] ; then
  416 + STATE_P=""
  417 + else
  418 + STATE_P="state $STATE_P "
  419 + fi
  420 + POS_IN_CHAIN_P=$7
  421 + if [ -z "$POS_IN_CHAIN_P" ] ; then
  422 + POS_IN_CHAIN_P=""
  423 + else
  424 + POS_IN_CHAIN_P=$(printf "%-9s" $POS_IN_CHAIN_P)
  425 + fi
  426 + GREP_OUT=$(iptables -vnL --line-numbers | grep "$POS_IN_CHAIN_P" | grep "$TARGET_P" | grep "$PROT_P" | grep "$STATE_P$PROT_P dpt:$PORT_P")
  427 + if [ $? -eq 1 ] ; then
  428 + F_CHK_IPTABLES_R=1
  429 + else
  430 + if [ ${SKIP_MSG_P} -eq 0 ] && [ ! -z "$MSG_P" ] ; then
  431 + f_div_section
  432 + echo "$MSG_P"
  433 + f_div_section
  434 + f_enter_to_cont
  435 + fi
  436 + F_CHK_IPTABLES_R=0
  437 + fi
  438 +}
  439 +
  440 +F_IS_NOT_RUNNING_R=0
  441 +f_is_not_running() {
  442 + : 'Checar de determinado processo (pode ser um serviço) está
  443 + rodando.
  444 +
  445 + Args:
  446 + PROC_NM_P (str): Nome do processo (pode ser um serviço).
  447 + COND_MSG_P (Optional[str]): Mensagem a ser exibida se
  448 + verdadeira a verificação. Se vazio ou não informado não será
  449 + exibida mensagem.
  450 + CHK_INVERT (Optional[int]): Inverter a lógica da checagem.
  451 + Padrão 0.
  452 +
  453 + Returns:
  454 + F_IS_NOT_RUNNING_R (int): 1 - Se verdadeiro para a condição
  455 + analisada; 0 - Se falso para a condição analisada.
  456 + '
  457 +
  458 + PROC_NM_P=$1
  459 + COND_MSG_P=$2
  460 + CHK_INVERT=$3
  461 + if [ -z "$CHK_INVERT" ] ; then
  462 + CHK_INVERT=0
  463 + fi
  464 + F_IS_NOT_RUNNING_R=0
  465 + # NOTE: A verificação "grep -v grep" é para que ele não dê positivo
  466 + # para o próprio comando grep! By Questor
  467 + F_IS_NOT_RUNNING_R=0
  468 + if [ ${CHK_INVERT} -eq 0 ] ; then
  469 + if ! ps aux | grep -v "grep" | grep "$PROC_NM_P" > /dev/null ; then
  470 + F_IS_NOT_RUNNING_R=1
  471 + fi
  472 + else
  473 + if ps aux | grep -v "grep" | grep "$PROC_NM_P" > /dev/null ; then
  474 + F_IS_NOT_RUNNING_R=1
  475 + fi
  476 + fi
  477 + if [ ${EZ_I_SKIP_ON_V} -eq 0 ] && [ ${F_IS_NOT_RUNNING_R} -eq 1 ] && [ ! -z "$COND_MSG_P" ] ; then
  478 + f_div_section
  479 + echo "$COND_MSG_P"
  480 + f_div_section
  481 + f_enter_to_cont
  482 + fi
  483 +}
  484 +
  485 +F_GET_STDERR_R=""
  486 +F_GET_STDOUT_R=""
  487 +f_get_stderr_stdout() {
  488 + : 'Executar um comando e colocar a saída de stderr e stdout nas
  489 + variáveis "F_GET_STDERR_R" e "F_GET_STDOUT_R"!.
  490 +
  491 + Args:
  492 + CMD_TO_EXEC (str): Comando a ser executado.
  493 +
  494 + Returns:
  495 + F_GET_STDERR_R (str): Saída para stderr.
  496 + F_GET_STDOUT_R (str): Saída para stdout.
  497 + '
  498 +
  499 + CMD_TO_EXEC=$1
  500 + F_GET_STDERR_R=""
  501 + F_GET_STDOUT_R=""
  502 + unset t_std t_err
  503 + eval "$( eval "$CMD_TO_EXEC" 2> >(t_err=$(cat); typeset -p t_err) > >(t_std=$(cat); typeset -p t_std) )"
  504 + F_GET_STDERR_R=$t_err
  505 + F_GET_STDOUT_R=$t_std
  506 +}
  507 +
  508 +F_BAK_PATH_R=""
  509 +F_BAK_MD_R=0
  510 +f_ez_mv_bak() {
  511 + : 'Modifica o nome de um arquivo ou pasta para um nome de backup.
  512 +
  513 + Adiciona um sufixo ao nome no formato: "-D%Y-%m-%d-T%H-%M-%S.bak".
  514 +
  515 + Args:
  516 + TARGET (str): Caminho para o arquivo ou pasta alvo.
  517 + CONF_MSG_P (Optional[str]): Verificar se o usuário deseja ou
  518 + não backup. Se vazio ou não informado não será exibida mensagem.
  519 + SKIP_MSG_P (Optional[int]): Não exibir mensagem. Padrão 0.
  520 +
  521 + Returns:
  522 + F_BAK_PATH_R (str): Caminho para o arquivo ou pasta alvo com o
  523 + novo nome.
  524 + F_BAK_NAME_R (str): Nome do arquivo recém criado.
  525 + F_BAK_MD_R (int): 1 - Backup realizado; 0 - Backup não
  526 + realizado.
  527 + '
  528 +
  529 + TARGET=$1
  530 + CONF_MSG_P=$2
  531 + SKIP_MSG_P=$3
  532 + if [ -z "$SKIP_MSG_P" ] ; then
  533 + SKIP_MSG_P=0
  534 + fi
  535 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  536 + SKIP_MSG_P=1
  537 + fi
  538 +
  539 +
  540 + MK_BAK=1
  541 + F_BAK_PATH_R=""
  542 + F_BAK_NAME_R=""
  543 + F_BAK_MD_R=0
  544 +
  545 + if [ ${SKIP_MSG_P} -eq 0 ] && [ ! -z "$CONF_MSG_P" ] ; then
  546 + f_div_section
  547 + f_yes_no "$CONF_MSG_P"
  548 + f_div_section
  549 + MK_BAK=$YES_NO_R
  550 + fi
  551 + if [ ${MK_BAK} -eq 1 ] ; then
  552 + SUFFIX=$(date +"-D%Y-%m-%d-T%H-%M-%S.bak")
  553 + NEW_NAME="$TARGET$SUFFIX"
  554 + mv "$TARGET" "$NEW_NAME"
  555 + F_BAK_PATH_R=$NEW_NAME
  556 + F_BAK_NAME_R="${NEW_NAME##*/}"
  557 + F_BAK_MD_R=1
  558 + fi
  559 +}
  560 +
  561 +f_error_exit() {
  562 + : '"Printa" uma mensagem de erro e encerra o instalador.
  563 +
  564 + Args:
  565 + ERROR_CAUSE_P (Optional[str]): Causa do erro.
  566 + '
  567 +
  568 + ERROR_CAUSE_P=$1
  569 + echo
  570 + f_open_section "E R R O R !"
  571 + ERROR_MSG_NOW_P="AN ERROR OCCURRED AND THIS INSTALLER WAS CLOSED!"
  572 + if [ ! -z "$ERROR_CAUSE_P" ] ; then
  573 + ERROR_MSG_NOW_P="$ERROR_MSG_NOW_P ERROR: \"$ERROR_CAUSE_P\""
  574 + fi
  575 + echo "$ERROR_MSG_NOW_P"
  576 + echo
  577 + f_close_section
  578 + exit 1
  579 +}
  580 +
  581 +f_continue() {
  582 + : 'Questionar ao usuário se deseja continuar ou parar a instalação.
  583 +
  584 + Args:
  585 + NOTE_P (Optional[str]): Informações adicionais ao usuário.
  586 + '
  587 +
  588 + NOTE_P=$1
  589 + f_div_section
  590 + if [ -z "$NOTE_P" ] ; then
  591 + NOTE_P=""
  592 + else
  593 + NOTE_P=" (NOTE: \"$NOTE_P\")"
  594 + fi
  595 +
  596 + f_yes_no "CONTINUE? (USE \"n\" TO STOP THIS INSTALLER)$NOTE_P"
  597 + f_div_section
  598 + if [ ${YES_NO_R} -eq 0 ] ; then
  599 + exit 0
  600 + fi
  601 +}
  602 +
  603 +
  604 +# < --------------------------------------------------------------------------
  605 +
  606 +# > --------------------------------------------------------------------------
  607 +# GRAFICO!
  608 +# --------------------------------------
  609 +
  610 +f_indent() {
  611 + : 'Definir uma tabulação para uma string informada.
  612 +
  613 + Exemplo de uso: echo "<STR_VALUE>" | f_indent 4
  614 +
  615 + Args:
  616 + LEVEL_P (int): 2, 4 ou 8 espaços.
  617 + '
  618 +
  619 + LEVEL_P=$1
  620 + if [ ${LEVEL_P} -eq 2 ] ; then
  621 + sed 's/^/ /';
  622 + fi
  623 + if [ ${LEVEL_P} -eq 4 ] ; then
  624 + sed 's/^/ /';
  625 + fi
  626 + if [ ${LEVEL_P} -eq 8 ] ; then
  627 + sed 's/^/ /';
  628 + fi
  629 +}
  630 +
  631 +f_open_section() {
  632 + : 'Printar abertura de uma seção.'
  633 +
  634 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  635 + return 0
  636 + fi
  637 + TITLE_P=$1
  638 + echo "> ------------------------------------------------"
  639 + if [ -n "$TITLE_P" ] ; then
  640 + echo "$TITLE_P"
  641 + f_div_section
  642 + echo
  643 + fi
  644 +}
  645 +
  646 +f_close_section() {
  647 + : 'Printar fechamento de uma seção.'
  648 +
  649 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  650 + return 0
  651 + fi
  652 + echo "< ------------------------------------------------"
  653 + echo
  654 +}
  655 +
  656 +f_div_section() {
  657 + : 'Printar divisão em uma seção.'
  658 +
  659 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  660 + return 0
  661 + fi
  662 + echo "----------------------------------"
  663 +}
  664 +
  665 +f_sub_section() {
  666 + : 'Printar uma subseção.
  667 +
  668 + Args:
  669 + TITLE_P (str): Título da subseção.
  670 + TEXT_P (str): Texto da subseção.
  671 + '
  672 +
  673 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  674 + return 0
  675 + fi
  676 + TITLE_P=$1
  677 + TEXT_P=$2
  678 + echo "> $TITLE_P" | f_indent 2
  679 + echo
  680 + echo "$TEXT_P" | f_indent 4
  681 + echo
  682 +}
  683 +
  684 +# < --------------------------------------------------------------------------
  685 +
  686 +# > --------------------------------------------------------------------------
  687 +# APRESENTAÇÃO!
  688 +# --------------------------------------
  689 +
  690 +f_begin() {
  691 + : 'Printar uma abertura/apresentação para o instalador do produto.
  692 +
  693 + Usar no início da instalação.
  694 +
  695 + Args:
  696 + TITLE_P (str): Título.
  697 + VERSION_P (str): Versão do produto.
  698 + ABOUT_P (str): Sobre o produto.
  699 + WARNINGS_P (str): Avisos antes de continuar.
  700 + COMPANY_P (str): Informações sobre a empresa.
  701 + '
  702 +
  703 + clear
  704 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  705 + return 0
  706 + fi
  707 + TITLE_P=$1
  708 + VERSION_P=$2
  709 + ABOUT_P=$3
  710 + WARNINGS_P=$4
  711 + COMPANY_P=$5
  712 + f_open_section "$TITLE_P ($VERSION_P)"
  713 + f_sub_section "ABOUT:" "$ABOUT_P"
  714 + f_sub_section "WARNINGS:" "$WARNINGS_P"
  715 + f_div_section
  716 + echo "$COMPANY_P"
  717 + f_close_section
  718 + f_enter_to_cont
  719 + clear
  720 +}
  721 +
  722 +f_end() {
  723 + : 'Printar uma fechamento/encerramento para o instalador do produto.
  724 +
  725 + Usar no final da instalação.
  726 +
  727 + Args:
  728 + TITLE_P (str): Título.
  729 + USEFUL_INFO_P (str): Informações úteis (uso básico etc...).
  730 + '
  731 +
  732 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  733 + return 0
  734 + fi
  735 + TITLE_P=$1
  736 + USEFUL_INFO_P=$2
  737 + f_open_section "$TITLE_P"
  738 + f_sub_section "USEFUL INFORMATION:" "$USEFUL_INFO_P"
  739 + f_close_section
  740 +}
  741 +
  742 +f_terms_licen() {
  743 + : 'Printar os termos de licença/uso do produto.
  744 +
  745 + Pede que o usuário concorde com os termos.
  746 +
  747 + Args:
  748 + TERMS_LICEN_P (str): Termos de licença/uso do produto.
  749 + '
  750 +
  751 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  752 + return 0
  753 + fi
  754 + TERMS_LICEN_P=$1
  755 + f_open_section "LICENSE/TERMS:"
  756 + echo "$TERMS_LICEN_P" | f_indent 2
  757 + echo
  758 + f_div_section
  759 + TITLE_F="BY ANSWERING YES (y) YOU WILL AGREE WITH TERMS AND CONDITIONS "\
  760 +"PRESENTED! PROCEED?"
  761 + f_yes_no "$TITLE_F"
  762 + TITLE_F=""
  763 + f_close_section
  764 + sleep 1
  765 + if [ ${YES_NO_R} -eq 0 ] ; then
  766 + exit 0
  767 + fi
  768 + clear
  769 +}
  770 +
  771 +f_instruct() {
  772 + : 'Printar instruções sobre o produto.
  773 +
  774 + Args:
  775 + INSTRUCT_P (str): Instruções sobre o produto.
  776 + '
  777 +
  778 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  779 + return 0
  780 + fi
  781 + INSTRUCT_P=$1
  782 + f_open_section "INSTRUCTIONS:"
  783 + echo "$INSTRUCT_P" | f_indent 2
  784 + echo
  785 + f_close_section
  786 + f_enter_to_cont
  787 + clear
  788 +}
  789 +
  790 +# < --------------------------------------------------------------------------
  791 +
  792 +# > --------------------------------------------------------------------------
  793 +# ESQUEMAS CONDICIONAIS!
  794 +# --------------------------------------
  795 +
  796 +YES_NO_R=0
  797 +f_yes_no() {
  798 + : 'Questiona ao usuário "yes" ou "no" sobre determinado algo.
  799 +
  800 + Args:
  801 + QUESTION_P (str): Questionamento a ser feito.
  802 +
  803 + Returns:
  804 + YES_NO_R (int): 1 - Yes; 0 - No.
  805 + '
  806 +
  807 + if [ ${EZ_I_SKIP_ON_V} -eq 1 ] ; then
  808 + return 0
  809 + fi
  810 + QUESTION_P=$1
  811 + YES_NO_R=0
  812 + read -r -p "$QUESTION_P (y/n) " RESP_V
  813 + if [[ $RESP_V =~ ^([sS]|[yY])$ ]] ; then
  814 + YES_NO_R=1
  815 + elif [[ $RESP_V =~ ^([nN])$ ]] ; then
  816 + echo "NO!"
  817 + YES_NO_R=0
  818 + else
  819 + f_yes_no "$QUESTION_P"
  820 + fi
  821 +}
  822 +
  823 +# < --------------------------------------------------------------------------
... ...
install.sh 0 → 100755
  1 +++ a/install.sh
... ... @@ -0,0 +1,419 @@
  1 +#!/bin/bash
  2 +
  3 +# NOTE: Evita problemas com caminhos relativos! By Questor
  4 +SCRIPTDIR_V="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  5 +. $SCRIPTDIR_V/ez_i.sh
  6 +
  7 +# > --------------------------------------------------------------------------
  8 +# INÍCIO!
  9 +# --------------------------------------
  10 +
  11 +read -d '' TITLE_F <<"EOF"
  12 +LBI - LBIndex Installer
  13 +EOF
  14 +
  15 +read -d '' VERSION_F <<"EOF"
  16 +0.1.1.0
  17 +EOF
  18 +
  19 +read -d '' ABOUT_F <<"EOF"
  20 +This script will install LBI - LBIndex the LightBase indexing component!
  21 +
  22 +Have fun! =D
  23 +EOF
  24 +
  25 +read -d '' WARNINGS_F <<"EOF"
  26 +- Installer designed for CentOS 6 AMD64/RHEL 6 AMD64!
  27 +
  28 +- We RECOMMEND you...
  29 + Install all the components (answer yes to everything). Except
  30 + contrary guidance!
  31 + Check for previous installations! If there is previous
  32 + installations consider this variant in the process!
  33 +- We WARNING you...
  34 + USE AT YOUR OWN RISK: WE ARE NOT RESPONSIBLE FOR ANY DAMAGE TO
  35 +YOURSELF, HARDWARE, OR CO-WORKERS. EXCEPT IN CASES WHERE THERE ARE
  36 +SIGNED CONTRACT THAT REGULATES THIS!
  37 +EOF
  38 +
  39 +read -d '' COMPANY_F <<"EOF"
  40 +BR Light LTDA - LightBase Consulting in Public Software/LightBase Consultoria em Software Público
  41 +Free Software + Our Ideas = Best Solution!/Software Livre + Nossas Idéias = Melhor Solução!
  42 ++55-61-3347-1949 - http://www.LightBase.com.br - Brasil-DF
  43 +EOF
  44 +
  45 +f_begin "$TITLE_F" "$VERSION_F" "$ABOUT_F" "$WARNINGS_F" "$COMPANY_F"
  46 +ABOUT_F=""
  47 +WARNINGS_F=""
  48 +
  49 +# < --------------------------------------------------------------------------
  50 +
  51 +# > --------------------------------------------------------------------------
  52 +# TERMOS E LICENÇA!
  53 +# --------------------------------------
  54 +
  55 +read -d '' TERMS_LICEN_F <<"EOF"
  56 +BY USING THIS INSTALLER YOU ARE AGREEING TO THE TERMS OF USE OF ALL INVOLVED SOFTWARE!
  57 +EOF
  58 +
  59 +f_terms_licen "$TERMS_LICEN_F"
  60 +TERMS_LICEN_F=""
  61 +
  62 +# < --------------------------------------------------------------------------
  63 +
  64 +# > --------------------------------------------------------------------------
  65 +# INTRUÇÕES!
  66 +# --------------------------------------
  67 +
  68 +read -d '' INSTRUCT_F <<"EOF"
  69 +- To run this script YOU NEED to be root!
  70 +
  71 +- TO CANCEL installation at any time use Ctrl+c!
  72 +EOF
  73 +
  74 +f_instruct "$INSTRUCT_F"
  75 +INSTRUCT_F=""
  76 +
  77 +# < --------------------------------------------------------------------------
  78 +
  79 +# > -----------------------------------------
  80 +# Dá ao usuário mais avançado a possibilideade de usar o instalador
  81 +# simplificado!
  82 +
  83 +# NOTE: É possível forçar o processo de instalção simplificado setando
  84 +# "SIMPLE_INST" com 1! By Questor
  85 +SIMPLE_INST=0
  86 +if [ ${SIMPLE_INST} -eq 0 ] ; then
  87 + f_open_section
  88 + f_yes_no "Use simple install (using a default value for most of the options)?"
  89 + if [ ${YES_NO_R} -eq 1 ] ; then
  90 +
  91 + # NOTE: Essa variável serve apenas para "preservar" o valor
  92 + # setado pelo usuário sendo somente "leitura". A variável a
  93 + # ser usada nas regras deve ser "EZ_I_SKIP_ON_V" (ez_i.sh)! Essa
  94 + # estratégia serve para mudarmos o comportamento do "ez_i.sh"
  95 + # de acordo com as circunstâncias! By Questor
  96 + SIMPLE_INST=1
  97 +
  98 + # NOTE: Essa variável é para consumo do "ez_i.sh", para que ele
  99 + # não execute algumas funções e simplifique o processo de
  100 + # instalação! By Questor
  101 + EZ_I_SKIP_ON_V=1
  102 + fi
  103 + f_close_section
  104 + sleep 1
  105 +fi
  106 +
  107 +# < -----------------------------------------
  108 +
  109 +# > -----------------------------------------
  110 +# Garantir o encodamento correto para evitar problemas de
  111 +# compatibilidade!
  112 +
  113 +EZ_I_SKIP_ON_V=$SIMPLE_INST
  114 +f_open_section
  115 +read -d '' TITLE_F <<"EOF"
  116 +Set terminal encode? (recommended for Windows terminal clients)
  117 +EOF
  118 +
  119 +f_yes_no "$TITLE_F"
  120 +TITLE_F=""
  121 +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then
  122 + export LANG=pt_BR.utf8
  123 +fi
  124 +f_close_section
  125 +
  126 +# < -----------------------------------------
  127 +
  128 +# > -----------------------------------------
  129 +# Desabilita o SElinux!
  130 +
  131 +EZ_I_SKIP_ON_V=0
  132 +f_open_section
  133 +read -d '' TITLE_F <<"EOF"
  134 +Disable SElinux (use "y" if you never did it)?
  135 +EOF
  136 +
  137 +f_yes_no "$TITLE_F"
  138 +TITLE_F=""
  139 +if [ ${YES_NO_R} -eq 1 ] ; then
  140 + setenforce 0
  141 +
  142 + # NOTE: As condições abaixo visam evitar que o arquivo seja
  143 + # desnecessariamente e erroneamente modificado! By Questor
  144 + EZ_I_SKIP_ON_V=$SIMPLE_INST
  145 + f_fl_cont_str "# SELINUX=enforcing" "/etc/sysconfig/selinux" "The file \"/etc/sysconfig/selinux\" probably has already been changed! Check it!"
  146 + EZ_I_SKIP_ON_V=0
  147 + if [ ${FL_CONT_STR_R} -eq 0 ] ; then
  148 + f_fl_cont_str "SELINUX=disabled" "/etc/sysconfig/selinux"
  149 + if [ ${FL_CONT_STR_R} -eq 0 ] ; then
  150 + f_ez_sed "SELINUX=enforcing" "# SELINUX=enforcing\nSELINUX=disabled" "/etc/sysconfig/selinux"
  151 + fi
  152 + fi
  153 +fi
  154 +f_close_section
  155 +
  156 +# < -----------------------------------------
  157 +
  158 +# > -----------------------------------------
  159 +# Instala os componentes de base usados pelo LBI - LBIndex!
  160 +
  161 +EZ_I_SKIP_ON_V=$SIMPLE_INST
  162 +f_open_section
  163 +read -d '' TITLE_F <<"EOF"
  164 +Install base components?
  165 +EOF
  166 +
  167 +f_yes_no "$TITLE_F"
  168 +TITLE_F=""
  169 +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then
  170 + f_pack_is_inst "gcc-c++" "yum" "\"gcc-c++\" already installed!"
  171 + if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then
  172 + yum -y install gcc-c++
  173 + fi
  174 + f_pack_is_inst "postgresql-devel" "yum" "\"postgresql-devel\" already installed!"
  175 + if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then
  176 + yum -y install postgresql-devel
  177 + fi
  178 + f_pack_is_inst "git" "yum" "\"git\" already installed!"
  179 + if [ ${F_PACK_IS_INST_R} -eq 0 ] ; then
  180 + yum -y install git
  181 + fi
  182 +fi
  183 +f_close_section
  184 +
  185 +# < -----------------------------------------
  186 +
  187 +BASE_INST_DIR_V="/usr/local/lb"
  188 +# > -----------------------------------------
  189 +# Criar o diretório base da instalação!
  190 +
  191 +EZ_I_SKIP_ON_V=$SIMPLE_INST
  192 +f_open_section
  193 +QUESTION_F="Insert where the base installation directory (\"lb\") will be created (don't use \"/\" at the end).
  194 +Use empty for \"/usr/local\"!"
  195 +
  196 +f_get_usr_input "$QUESTION_F" 1
  197 +QUESTION_F=""
  198 +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ -z "$GET_USR_INPUT_R" ] ; then
  199 + f_chk_by_path_hlp "$BASE_INST_DIR_V" "d" "\"$BASE_INST_DIR_V\" directory already created!"
  200 + if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then
  201 + mkdir -p "$BASE_INST_DIR_V"
  202 + fi
  203 +else
  204 + BASE_INST_DIR_V="$GET_USR_INPUT_R/lb"
  205 + f_chk_by_path_hlp "$BASE_INST_DIR_V" "d" "\"$BASE_INST_DIR_V\" directory already created!"
  206 + if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then
  207 + mkdir -p "$BASE_INST_DIR_V"
  208 + fi
  209 +fi
  210 +f_close_section
  211 +
  212 +# < -----------------------------------------
  213 +
  214 +# > -----------------------------------------
  215 +# Instalar o virtualenv-1.11.6 no python2.6!
  216 +
  217 +EZ_I_SKIP_ON_V=$SIMPLE_INST
  218 +f_open_section
  219 +read -d '' TITLE_F <<"EOF"
  220 +Install virtualenv-1.11.6 on python2.6?
  221 +EOF
  222 +
  223 +f_yes_no "$TITLE_F"
  224 +TITLE_F=""
  225 +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then
  226 + f_chk_by_path_hlp "/usr/bin/virtualenv-2.6" "f" "virtualenv-1.11.6 already installed!"
  227 + if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then
  228 + cd "$SCRIPTDIR_V"
  229 + cd ./other-srcs-n-apps
  230 + tar -zxvf virtualenv-1.11.6.tar.gz
  231 + cd virtualenv-1.11.6
  232 + python2.6 setup.py install
  233 + cd ..
  234 + rm -rf virtualenv-1.11.6
  235 + fi
  236 +fi
  237 +f_close_section
  238 +
  239 +# < -----------------------------------------
  240 +
  241 +# > -----------------------------------------
  242 +# Criar o ambiente virtual (python2.6)!
  243 +
  244 +EZ_I_SKIP_ON_V=$SIMPLE_INST
  245 +f_open_section
  246 +f_enter_to_cont "Create the virtual environment (python2.6)!"
  247 +
  248 +f_chk_by_path_hlp "$BASE_INST_DIR_V/ve26" "d" "Virtual environment (python2.6) already created in \"$BASE_INST_DIR_V/ve26\"!"
  249 +if [ ${F_CHK_BY_PATH_HLP_R} -eq 0 ] ; then
  250 + cd "$BASE_INST_DIR_V"
  251 + virtualenv-2.6 ve26
  252 + mkdir "$BASE_INST_DIR_V/ve26/src"
  253 + f_enter_to_cont "Virtual environment created in \"$BASE_INST_DIR_V/ve26\"!"
  254 +fi
  255 +f_close_section
  256 +
  257 +# < -----------------------------------------
  258 +
  259 +# > -----------------------------------------
  260 +# Instalar as dependências python2.6 da LIB - liblightbase!
  261 +
  262 +EZ_I_SKIP_ON_V=$SIMPLE_INST
  263 +cd "$SCRIPTDIR_V"
  264 +sh py-packs-liblightbase.sh "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V"
  265 +
  266 +# < -----------------------------------------
  267 +
  268 +# > -----------------------------------------
  269 +# Instalar a LIB - liblightbase!
  270 +
  271 +EZ_I_SKIP_ON_V=$SIMPLE_INST
  272 +f_open_section
  273 +read -d '' TITLE_F <<"EOF"
  274 +Install the LIB - liblightbase?
  275 +EOF
  276 +
  277 +f_yes_no "$TITLE_F"
  278 +TITLE_F=""
  279 +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then
  280 + f_chk_by_path_hlp "$BASE_INST_DIR_V/ve26/src/liblightbase" "d" "\"liblightbase\" already installed in \"$BASE_INST_DIR_V/ve26/src\"!"
  281 + F_BAK_MD_R=1
  282 + if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then
  283 + f_ez_mv_bak "$BASE_INST_DIR_V/ve26/src/liblightbase" "Backup old version and update? (\"y\" recommended)"
  284 + fi
  285 + if [ ${F_BAK_MD_R} -eq 1 ] ; then
  286 + cd "$SCRIPTDIR_V"
  287 + tar -zxvf liblightbase.tar.gz
  288 + mv "$SCRIPTDIR_V/liblightbase" "$BASE_INST_DIR_V/ve26/src/"
  289 + cd "$BASE_INST_DIR_V/ve26/src/liblightbase"
  290 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  291 + fi
  292 +fi
  293 +f_close_section
  294 +
  295 +# < -----------------------------------------
  296 +
  297 +# > -----------------------------------------
  298 +# Instalar as dependências python do LBI - LBIndex!
  299 +
  300 +EZ_I_SKIP_ON_V=$SIMPLE_INST
  301 +cd "$SCRIPTDIR_V"
  302 +sh py-packs-LBIndex.sh "$EZ_I_SKIP_ON_V" "$BASE_INST_DIR_V"
  303 +
  304 +# < -----------------------------------------
  305 +
  306 +HTTP_PORT_F=6543
  307 +# > -----------------------------------------
  308 +# Instalar e configurar o LBI - LBIndex!
  309 +
  310 +EZ_I_SKIP_ON_V=$SIMPLE_INST
  311 +f_open_section
  312 +read -d '' TITLE_F <<"EOF"
  313 +Install the LBI - LBIndex?
  314 +EOF
  315 +
  316 +f_yes_no "$TITLE_F"
  317 +TITLE_F=""
  318 +if [ ${EZ_I_SKIP_ON_V} -eq 1 ] || [ ${YES_NO_R} -eq 1 ] ; then
  319 +
  320 + f_chk_by_path_hlp "$BASE_INST_DIR_V/ve26/src/LBIndex" "d" "\"LBIndex\" already installed in \"$BASE_INST_DIR_V/ve26/src\"!"
  321 + F_BAK_MD_R=1
  322 + if [ ${F_CHK_BY_PATH_HLP_R} -eq 1 ] ; then
  323 + f_ez_mv_bak "$BASE_INST_DIR_V/ve26/src/LBIndex" "Backup old version and update? (\"y\" recommended)"
  324 + fi
  325 + if [ ${F_BAK_MD_R} -eq 1 ] ; then
  326 + cd "$SCRIPTDIR_V"
  327 + tar -zxvf LBIndex.tar.gz
  328 + mv "$SCRIPTDIR_V/LBIndex" "$BASE_INST_DIR_V/ve26/src/"
  329 + cd "$BASE_INST_DIR_V/ve26/src/LBIndex"
  330 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  331 +
  332 + f_enter_to_cont "Configure LBI - LBIndex!"
  333 + \cp "$BASE_INST_DIR_V/ve26/src/LBIndex/lbindex-dist" "$BASE_INST_DIR_V/ve26/src/LBIndex/lbindex-prov"
  334 + f_ez_sed "<LBINDEXMG_PATH>" "$BASE_INST_DIR_V/ve26/src/LBIndex/lbindexmg" "$BASE_INST_DIR_V/ve26/src/LBIndex/lbindex-prov"
  335 + rm -rf "/etc/init.d/lbindex"
  336 + mv "$BASE_INST_DIR_V/ve26/src/LBIndex/lbindex-prov" "/etc/init.d/lbindex"
  337 +
  338 + chmod 755 -R /etc/init.d/
  339 + cd /etc/init.d/
  340 + chkconfig --level 2345 lbindex on
  341 +
  342 + \cp "$BASE_INST_DIR_V/ve26/src/LBIndex/lbindexmg-dist" "$BASE_INST_DIR_V/ve26/src/LBIndex/lbindexmg"
  343 + f_ez_sed "<VIRTUALENV_PATH>" "$BASE_INST_DIR_V/ve26" "$BASE_INST_DIR_V/ve26/src/LBIndex/lbindexmg"
  344 +
  345 + LBG_URL_F="http://127.0.0.1/lbg"
  346 + QUESTION_F="Enter the LBG - LBGenerator URL.
  347 +Use empty for \"$LBG_URL_F\" (LOCALHOST)!"
  348 +
  349 + f_get_usr_input "$QUESTION_F" 1
  350 + QUESTION_F=""
  351 + if [ -n "$GET_USR_INPUT_R" ] ; then
  352 + LBG_URL_F=$GET_USR_INPUT_R
  353 + fi
  354 +
  355 + QUESTION_F="Enter the port number for http service.
  356 +Use empty for \"6543\" (recommended)!"
  357 +
  358 + f_get_usr_input "$QUESTION_F" 1
  359 + QUESTION_F=""
  360 + if [ -n "$GET_USR_INPUT_R" ] ; then
  361 + HTTP_PORT_F=$GET_USR_INPUT_R
  362 + fi
  363 +
  364 + \cp "$BASE_INST_DIR_V/ve26/src/LBIndex/production.ini-dist" "$BASE_INST_DIR_V/ve26/src/LBIndex/production.ini"
  365 + f_ez_sed "<HTTP_SERVICE_PORT_NUM>" "$HTTP_PORT_F" "$BASE_INST_DIR_V/ve26/src/LBIndex/production.ini"
  366 + f_ez_sed "<MACHINE_IP_OR_NAME>" "$LBG_URL_F" "$BASE_INST_DIR_V/ve26/src/LBIndex/production.ini"
  367 +
  368 + service lbindex restart
  369 + fi
  370 +fi
  371 +f_close_section
  372 +
  373 +# < -----------------------------------------
  374 +
  375 +# > -----------------------------------------
  376 +# Abrir o firewall para o http service!
  377 +
  378 +EZ_I_SKIP_ON_V=0
  379 +f_open_section
  380 +TITLE_F="Open firewall for http service (TCP $HTTP_PORT_F)?"
  381 +
  382 +f_yes_no "$TITLE_F"
  383 +TITLE_F=""
  384 +if [ ${YES_NO_R} -eq 1 ]; then
  385 + f_chk_iptables ${HTTP_PORT_F} "Port $HTTP_PORT_F is already open!" 0 "ACCEPT" "tcp" "NEW"
  386 + if [ ${F_CHK_IPTABLES_R} -eq 1 ] ; then
  387 + iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport ${HTTP_PORT_F} -j ACCEPT
  388 + service iptables save
  389 + service iptables restart
  390 + fi
  391 +fi
  392 +f_close_section
  393 +
  394 +# < -----------------------------------------
  395 +
  396 +# > --------------------------------------------------------------------------
  397 +# FINAL!
  398 +# --------------------------------------
  399 +
  400 +EZ_I_SKIP_ON_V=0
  401 +read -d '' TITLE_F <<"EOF"
  402 +Installer finished! Thanks!
  403 +EOF
  404 +
  405 +USEFUL_INFO_F="To configure...
  406 + vi $BASE_INST_DIR_V/ve26/src/LBIndex/production.ini
  407 +
  408 +To start/stop...
  409 + service lbindex start
  410 + service lbindex stop
  411 +
  412 +Log...
  413 + less /var/log/lbindex.log"
  414 +
  415 +f_end "$TITLE_F" "$USEFUL_INFO_F"
  416 +TITLE_F=""
  417 +USEFUL_INFO_F=""
  418 +
  419 +# < --------------------------------------------------------------------------
... ...
liblightbase.tar.gz 0 → 100755
No preview for this file type
other-srcs-n-apps/.directory 0 → 100755
  1 +++ a/other-srcs-n-apps/.directory
... ... @@ -0,0 +1,5 @@
  1 +[Dolphin]
  2 +PreviewsShown=true
  3 +Timestamp=2015,5,12,11,49,12
  4 +Version=3
  5 +ViewMode=1
... ...
other-srcs-n-apps/virtualenv-1.11.6.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex.sh 0 → 100755
  1 +++ a/py-packs-LBIndex.sh
... ... @@ -0,0 +1,196 @@
  1 +#!/bin/bash
  2 +
  3 +# Instalação das dependências do LBI - LBIndex no python2.6!
  4 +
  5 +. ./ez_i.sh
  6 +
  7 +SKIP_ON_V=$1
  8 +if [ -z "$SKIP_ON_V" ] ; then
  9 + SKIP_ON_V=0
  10 +fi
  11 +
  12 +BASE_INST_DIR_V=$2
  13 +
  14 +# > -----------------------------------------
  15 +# Informar o diretório base da instalação!
  16 +
  17 +if [ -z "$BASE_INST_DIR_V" ] ; then
  18 + f_open_section
  19 + BASE_INST_DIR_V="/usr/local/lb"
  20 +
  21 + QUESTION_F="Enter the installation directory.
  22 + Use empty for \"$BASE_INST_DIR_V\"!"
  23 +
  24 + f_get_usr_input "$QUESTION_F" 1
  25 + QUESTION_F=""
  26 + if [ -n "$GET_USR_INPUT_R" ] ; then
  27 + BASE_INST_DIR_V="$GET_USR_INPUT_R/lb"
  28 + fi
  29 + f_close_section
  30 +fi
  31 +
  32 +# < -----------------------------------------
  33 +
  34 +f_open_section
  35 +
  36 +TITLE_F="Install LBI - LBIndex dependencies for python2.6?"
  37 +
  38 +f_yes_no "$TITLE_F"
  39 +TITLE_F=""
  40 +
  41 +if [ ${YES_NO_R} -eq 1 ] || [ ${SKIP_ON_V} -eq 1 ] ; then
  42 +
  43 + cd "$SCRIPTDIR_V"
  44 + cd ./py-packs-LBIndex
  45 +
  46 + tar -zxvf ./argparse-1.3.0.tar.gz
  47 + cd ./argparse-1.3.0
  48 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  49 + cd ..
  50 + rm -rf ./argparse-1.3.0
  51 +
  52 + tar -zxvf ./ordereddict-1.1.tar.gz
  53 + cd ./ordereddict-1.1
  54 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  55 + cd ..
  56 + rm -rf ./ordereddict-1.1
  57 +
  58 + tar -zxvf ./pbr-0.10.0.tar.gz
  59 + cd ./pbr-0.10.0
  60 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  61 + cd ..
  62 + rm -rf ./pbr-0.10.0
  63 +
  64 + tar -zxvf ./linecache2-1.0.0.tar.gz
  65 + cd ./linecache2-1.0.0
  66 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  67 + cd ..
  68 + rm -rf ./linecache2-1.0.0
  69 +
  70 + tar -zxvf ./configparser-3.3.0r2.tar.gz
  71 + cd ./configparser-3.3.0r2
  72 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  73 + cd ..
  74 + rm -rf ./configparser-3.3.0r2
  75 +
  76 + tar -zxvf ./traceback2-1.4.0.tar.gz
  77 + cd ./traceback2-1.4.0
  78 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  79 + cd ..
  80 + rm -rf ./traceback2-1.4.0
  81 +
  82 + tar -zxvf ./unittest2-1.0.1.tar.gz
  83 + cd ./unittest2-1.0.1
  84 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  85 + cd ..
  86 + rm -rf ./unittest2-1.0.1
  87 +
  88 + tar -zxvf ./urllib3-1.10.4.tar.gz
  89 + cd ./urllib3-1.10.4
  90 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  91 + cd ..
  92 + rm -rf ./urllib3-1.10.4
  93 +
  94 + tar -zxvf ./elasticsearch-1.4.0.tar.gz
  95 + cd ./elasticsearch-1.4.0
  96 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  97 + cd ..
  98 + rm -rf ./elasticsearch-1.4.0
  99 +
  100 + tar -zxvf ./simplejson-3.5.3.tar.gz
  101 + cd ./simplejson-3.5.3
  102 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  103 + cd ..
  104 + rm -rf ./simplejson-3.5.3
  105 +
  106 + tar -zxvf ./certifi-2015.11.20.1.tar.gz
  107 + cd ./certifi-2015.11.20.1
  108 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  109 + cd ..
  110 + rm -rf ./certifi-2015.11.20.1
  111 +
  112 + tar -zxvf ./pyelasticsearch-1.4.tar.gz
  113 + cd ./pyelasticsearch-1.4
  114 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  115 + cd ..
  116 + rm -rf ./pyelasticsearch-1.4
  117 +
  118 + tar -zxvf ./requests-2.3.0.tar.gz
  119 + cd ./requests-2.3.0
  120 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  121 + cd ..
  122 + rm -rf ./requests-2.3.0
  123 +
  124 + tar -zxvf ./six-1.7.2.tar.gz
  125 + cd ./six-1.7.2
  126 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  127 + cd ..
  128 + rm -rf ./six-1.7.2
  129 +
  130 + tar -zxvf ./PasteDeploy-1.5.2.tar.gz
  131 + cd ./PasteDeploy-1.5.2
  132 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  133 + cd ..
  134 + rm -rf ./PasteDeploy-1.5.2
  135 +
  136 + tar -zxvf ./venusian-1.0.tar.gz
  137 + cd ./venusian-1.0
  138 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  139 + cd ..
  140 + rm -rf ./venusian-1.0
  141 +
  142 + tar -zxvf ./translationstring-1.3.tar.gz
  143 + cd ./translationstring-1.3
  144 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  145 + cd ..
  146 + rm -rf ./translationstring-1.3
  147 +
  148 + tar -zxvf ./zope.deprecation-4.1.2.tar.gz
  149 + cd ./zope.deprecation-4.1.2
  150 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  151 + cd ..
  152 + rm -rf ./zope.deprecation-4.1.2
  153 +
  154 + tar -zxvf ./zope.interface-4.1.3.tar.gz
  155 + cd ./zope.interface-4.1.3
  156 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  157 + cd ..
  158 + rm -rf ./zope.interface-4.1.3
  159 +
  160 + tar -zxvf ./repoze.lru-0.6.tar.gz
  161 + cd ./repoze.lru-0.6
  162 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  163 + cd ..
  164 + rm -rf ./repoze.lru-0.6
  165 +
  166 + tar -zxvf ./WebOb-1.5.1.tar.gz
  167 + cd ./WebOb-1.5.1
  168 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  169 + cd ..
  170 + rm -rf ./WebOb-1.5.1
  171 +
  172 + tar -zxvf ./pyramid-1.6b2.tar.gz
  173 + cd ./pyramid-1.6b2
  174 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  175 + cd ..
  176 + rm -rf ./pyramid-1.6b2
  177 +
  178 + tar -zxvf ./Chameleon-2.24.tar.gz
  179 + cd ./Chameleon-2.24
  180 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  181 + cd ..
  182 + rm -rf ./Chameleon-2.24
  183 +
  184 + tar -zxvf ./pyramid_chameleon-0.3.tar.gz
  185 + cd ./pyramid_chameleon-0.3
  186 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  187 + cd ..
  188 + rm -rf ./pyramid_chameleon-0.3
  189 +
  190 + tar -zxvf ./waitress-0.8.10.tar.gz
  191 + cd ./waitress-0.8.10
  192 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  193 + cd ..
  194 + rm -rf ./waitress-0.8.10
  195 +
  196 +fi
... ...
py-packs-LBIndex/.directory 0 → 100755
  1 +++ a/py-packs-LBIndex/.directory
... ... @@ -0,0 +1,5 @@
  1 +[Dolphin]
  2 +PreviewsShown=true
  3 +Timestamp=2016,3,18,12,56,36
  4 +Version=3
  5 +ViewMode=1
... ...
py-packs-LBIndex/Chameleon-2.24.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/PasteDeploy-1.5.2.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/WebOb-1.5.1.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/argparse-1.3.0.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/certifi-2015.11.20.1.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/configparser-3.3.0r2.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/elasticsearch-1.4.0.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/linecache2-1.0.0.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/ordereddict-1.1.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/pbr-0.10.0.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/pyelasticsearch-1.4.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/pyramid-1.6b2.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/pyramid_chameleon-0.3.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/repoze.lru-0.6.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/requests-2.3.0.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/simplejson-3.5.3.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/six-1.7.2.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/traceback2-1.4.0.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/translationstring-1.3.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/unittest2-1.0.1.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/urllib3-1.10.4.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/venusian-1.0.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/waitress-0.8.10.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/zope.deprecation-4.1.2.tar.gz 0 → 100755
No preview for this file type
py-packs-LBIndex/zope.interface-4.1.3.tar.gz 0 → 100755
No preview for this file type
py-packs-liblightbase.sh 0 → 100755
  1 +++ a/py-packs-liblightbase.sh
... ... @@ -0,0 +1,88 @@
  1 +#!/bin/bash
  2 +
  3 +# Instalação das dependências da LIB - liblightbase no python2.6!
  4 +
  5 +. ./ez_i.sh
  6 +
  7 +SKIP_ON_V=$1
  8 +if [ -z "$SKIP_ON_V" ] ; then
  9 + SKIP_ON_V=0
  10 +fi
  11 +
  12 +BASE_INST_DIR_V=$2
  13 +
  14 +# > -----------------------------------------
  15 +# Informar o diretório base da instalação!
  16 +
  17 +if [ -z "$BASE_INST_DIR_V" ] ; then
  18 + f_open_section
  19 + BASE_INST_DIR_V="/usr/local/lb"
  20 +
  21 + QUESTION_F="Enter the installation directory.
  22 + Use empty for \"$BASE_INST_DIR_V\"!"
  23 +
  24 + f_get_usr_input "$QUESTION_F" 1
  25 + QUESTION_F=""
  26 + if [ -n "$GET_USR_INPUT_R" ] ; then
  27 + BASE_INST_DIR_V="$GET_USR_INPUT_R/lb"
  28 + fi
  29 + f_close_section
  30 +fi
  31 +
  32 +# < -----------------------------------------
  33 +
  34 +f_open_section
  35 +
  36 +TITLE_F="Install liblightbase dependencies for python2.6?"
  37 +
  38 +f_yes_no "$TITLE_F"
  39 +TITLE_F=""
  40 +
  41 +if [ ${YES_NO_R} -eq 1 ] || [ ${SKIP_ON_V} -eq 1 ] ; then
  42 +
  43 + cd "$SCRIPTDIR_V"
  44 + cd ./py-packs-liblightbase
  45 +
  46 + tar -zxvf ./decorator-3.4.0.tar.gz
  47 + cd ./decorator-3.4.0
  48 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  49 + cd ..
  50 + rm -rf ./decorator-3.4.0
  51 +
  52 + tar -zxvf ./six-1.7.2.tar.gz
  53 + cd ./six-1.7.2
  54 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  55 + cd ..
  56 + rm -rf ./six-1.7.2
  57 +
  58 + tar -zxvf ./ply-3.4.tar.gz
  59 + cd ./ply-3.4
  60 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  61 + cd ..
  62 + rm -rf ./ply-3.4
  63 +
  64 + tar -zxvf ./jsonpath-rw-1.3.0.tar.gz
  65 + cd ./jsonpath-rw-1.3.0
  66 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  67 + cd ..
  68 + rm -rf ./jsonpath-rw-1.3.0
  69 +
  70 + tar -zxvf ./python-dateutil-2.2.tar.gz
  71 + cd ./python-dateutil-2.2
  72 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  73 + cd ..
  74 + rm -rf ./python-dateutil-2.2
  75 +
  76 + tar -zxvf ./requests-2.3.0.tar.gz
  77 + cd ./requests-2.3.0
  78 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  79 + cd ..
  80 + rm -rf ./requests-2.3.0
  81 +
  82 + tar -zxvf ./voluptuous-0.8.7.tar.gz
  83 + cd ./voluptuous-0.8.7
  84 + eval "$BASE_INST_DIR_V/ve26/bin/python2.6 setup.py install"
  85 + cd ..
  86 + rm -rf ./voluptuous-0.8.7
  87 +
  88 +fi
... ...
py-packs-liblightbase/decorator-3.4.0.tar.gz 0 → 100755
No preview for this file type
py-packs-liblightbase/jsonpath-rw-1.3.0.tar.gz 0 → 100755
No preview for this file type
py-packs-liblightbase/ply-3.4.tar.gz 0 → 100755
No preview for this file type
py-packs-liblightbase/python-dateutil-2.2.tar.gz 0 → 100755
No preview for this file type
py-packs-liblightbase/requests-2.3.0.tar.gz 0 → 100755
No preview for this file type
py-packs-liblightbase/six-1.7.2.tar.gz 0 → 100755
No preview for this file type
py-packs-liblightbase/voluptuous-0.8.7.tar.gz 0 → 100755
No preview for this file type