Commit 3794ad62ae5447087f371b26ad25f8c9102c3123
1 parent
720ed0a4
Exists in
master
Atualização da versão! Melhorias e correções no processo de instalação! By Questor
Showing
5 changed files
with
57 additions
and
16 deletions
Show diff stats
.directory
LBIndex.tar.gz
No preview for this file type
ez_i.bash
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | : 'Trata-se de um módulo que oferece uma série de funcionalidades para | 2 | : 'Trata-se de um módulo que oferece uma série de funcionalidades para |
3 | criar um instalador usando "bash". | 3 | criar um instalador usando "bash". |
4 | 4 | ||
5 | -Version 1.1.0b | 5 | +Version 1.2.0b |
6 | 6 | ||
7 | Apache License | 7 | Apache License |
8 | Version 2.0, January 2004 | 8 | Version 2.0, January 2004 |
@@ -146,8 +146,8 @@ f_ez_sed_ecp() { | @@ -146,8 +146,8 @@ f_ez_sed_ecp() { | ||
146 | : '"Escapar" strings para o comando "sed". | 146 | : '"Escapar" strings para o comando "sed". |
147 | 147 | ||
148 | Como há muitas semelhanças entre o escape para "sed" ("f_ez_sed") e | 148 | Como há muitas semelhanças entre o escape para "sed" ("f_ez_sed") e |
149 | - escape para "grep" ("f_fl_cont_str") optei por colocar essa | ||
150 | - função como utilitária para as outras duas citadas. | 149 | + escape para "grep" ("f_fl_cont_str") optei por colocar essa função |
150 | + como utilitária para as outras duas. | ||
151 | 151 | ||
152 | Args: | 152 | Args: |
153 | VAL_TO_ECP (str): Valor a ser "escapado". | 153 | VAL_TO_ECP (str): Valor a ser "escapado". |
@@ -171,10 +171,23 @@ f_ez_sed_ecp() { | @@ -171,10 +171,23 @@ f_ez_sed_ecp() { | ||
171 | DONT_ECP_SQ=0 | 171 | DONT_ECP_SQ=0 |
172 | fi | 172 | fi |
173 | F_EZ_SED_ECP_R=$VAL_TO_ECP | 173 | F_EZ_SED_ECP_R=$VAL_TO_ECP |
174 | + | ||
175 | + # NOTE: Com essa intervenção conseguimos passar argumentos para um comando | ||
176 | + # "sed" mesmo que o texto tenha quebras de linha! By Questor | ||
177 | + F_EZ_SED_ECP_R=$(echo -n "$F_EZ_SED_ECP_R" | awk 'BEGIN {RS="dn"} {gsub("\n","\\n"); printf $0}') | ||
178 | + | ||
179 | + # NOTE: Para os casos onde "\n" faz parte dos argumentos. Nesses casos | ||
180 | + # os argumentos possuem "\n" em vez de quebras de linha efetivamente. Se | ||
181 | + # desabilitado "\n" será tratado como texto e não será convertido para | ||
182 | + # quebras! By Questor | ||
174 | if [ ${DONT_ECP_NL} -eq 1 ] ; then | 183 | if [ ${DONT_ECP_NL} -eq 1 ] ; then |
175 | F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed 's/\\n/C0673CECED2D4A8FBA90C9B92B9508A8/g') | 184 | F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed 's/\\n/C0673CECED2D4A8FBA90C9B92B9508A8/g') |
176 | fi | 185 | fi |
186 | + | ||
187 | + # NOTE: Escapa valores, principalmente, para serem aplicados como | ||
188 | + # argumentos em um comando de replace no "sed"! By Questor | ||
177 | F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed 's/[]\/$*.^|[]/\\&/g') | 189 | F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed 's/[]\/$*.^|[]/\\&/g') |
190 | + | ||
178 | if [ ${DONT_ECP_SQ} -eq 0 ] ; then | 191 | if [ ${DONT_ECP_SQ} -eq 0 ] ; then |
179 | F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed "s/'/\\\x27/g") | 192 | F_EZ_SED_ECP_R=$(echo "$F_EZ_SED_ECP_R" | sed "s/'/\\\x27/g") |
180 | fi | 193 | fi |
@@ -197,10 +210,15 @@ f_ez_sed() { | @@ -197,10 +210,15 @@ f_ez_sed() { | ||
197 | REPLACE. Padrão 0. | 210 | REPLACE. Padrão 0. |
198 | DONT_ECP_NL (Optional[int]): 1 - Não "escapa" "\n" (quebra de | 211 | DONT_ECP_NL (Optional[int]): 1 - Não "escapa" "\n" (quebra de |
199 | linha); 0 - "Escapa" "\n". Padrão 1. | 212 | linha); 0 - "Escapa" "\n". Padrão 1. |
213 | + NOTE: Para os casos onde "\n" faz parte dos argumentos. Nesses casos | ||
214 | + os argumentos possuem "\n" em vez de quebras de linha efetivamente. Se | ||
215 | + desabilitado "\n" será tratado como texto e não será convertido para | ||
216 | + quebras; | ||
200 | REMOVE_LN (Optional[int]): 1 - Remove a linha que possui o | 217 | REMOVE_LN (Optional[int]): 1 - Remove a linha que possui o |
201 | valor em TARGET; 0 - Faz o replace convencional. Padrão 0. | 218 | valor em TARGET; 0 - Faz o replace convencional. Padrão 0. |
202 | NTH_OCCUR (Optional[int]): Executará a operação escolhida | 219 | NTH_OCCUR (Optional[int]): Executará a operação escolhida |
203 | - apenas sobre a ocorrência indicada; Se -1, não executa. Padrão -1. | 220 | + apenas sobre a ocorrência indicada (utilize 2 para fazer replace apenas |
221 | + na 2 ocorrencia, por exemplo); Se -1, não executa. Padrão -1. | ||
204 | ' | 222 | ' |
205 | 223 | ||
206 | FILE=$3 | 224 | FILE=$3 |
@@ -602,8 +620,8 @@ F_GET_STDERR_R="" | @@ -602,8 +620,8 @@ F_GET_STDERR_R="" | ||
602 | F_GET_STDOUT_R="" | 620 | F_GET_STDOUT_R="" |
603 | F_GET_EXIT_CODE_R=0 | 621 | F_GET_EXIT_CODE_R=0 |
604 | f_get_stderr_stdout() { | 622 | f_get_stderr_stdout() { |
605 | - : 'Executar um comando e colocar a saída de stderr e stdout nas | ||
606 | - variáveis "F_GET_STDERR_R" e "F_GET_STDOUT_R"!. | 623 | + : 'Executar um comando e capturar a saída de stderr, stdout e |
624 | + o "exit code". | ||
607 | 625 | ||
608 | Args: | 626 | Args: |
609 | CMD_TO_EXEC (str): Comando a ser executado. | 627 | CMD_TO_EXEC (str): Comando a ser executado. |
@@ -611,6 +629,7 @@ f_get_stderr_stdout() { | @@ -611,6 +629,7 @@ f_get_stderr_stdout() { | ||
611 | Returns: | 629 | Returns: |
612 | F_GET_STDERR_R (str): Saída para stderr. | 630 | F_GET_STDERR_R (str): Saída para stderr. |
613 | F_GET_STDOUT_R (str): Saída para stdout. | 631 | F_GET_STDOUT_R (str): Saída para stdout. |
632 | + F_GET_EXIT_CODE_R (int): Código de saída. | ||
614 | ' | 633 | ' |
615 | 634 | ||
616 | CMD_TO_EXEC=$1 | 635 | CMD_TO_EXEC=$1 |
@@ -618,9 +637,9 @@ f_get_stderr_stdout() { | @@ -618,9 +637,9 @@ f_get_stderr_stdout() { | ||
618 | F_GET_STDOUT_R="" | 637 | F_GET_STDOUT_R="" |
619 | unset t_std t_err t_ret | 638 | unset t_std t_err t_ret |
620 | 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 )" | 639 | 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 )" |
621 | - F_GET_EXIT_CODE_R=$t_ret | ||
622 | F_GET_STDERR_R=$t_err | 640 | F_GET_STDERR_R=$t_err |
623 | F_GET_STDOUT_R=$t_std | 641 | F_GET_STDOUT_R=$t_std |
642 | + F_GET_EXIT_CODE_R=$t_ret | ||
624 | } | 643 | } |
625 | 644 | ||
626 | YES_NO_R=0 | 645 | YES_NO_R=0 |
@@ -883,6 +902,8 @@ f_split() { | @@ -883,6 +902,8 @@ f_split() { | ||
883 | TARGET_P=$(echo "$TARGET_P" | awk 'BEGIN {RS="dn" } {gsub("\n","£§¢¬¨") ;printf $0 }') | 902 | TARGET_P=$(echo "$TARGET_P" | awk 'BEGIN {RS="dn" } {gsub("\n","£§¢¬¨") ;printf $0 }') |
884 | fi | 903 | fi |
885 | 904 | ||
905 | + # TODO: Talvez se remover as aspas do "${TARGET_P}" logo abaixo resolva o | ||
906 | + # problema da necessidade de usar o workaround "£§¢¬¨"! By Questor | ||
886 | SPLIT_NOW=$(awk -F"$DELIMITER_P" '{for(i=1;i<=NF;i++){printf "%s\n", $i}}' <<<"${TARGET_P}") | 907 | SPLIT_NOW=$(awk -F"$DELIMITER_P" '{for(i=1;i<=NF;i++){printf "%s\n", $i}}' <<<"${TARGET_P}") |
887 | 908 | ||
888 | while IFS= read -r LINE_NOW; do | 909 | while IFS= read -r LINE_NOW; do |
@@ -1496,6 +1517,28 @@ f_procs_qtt() { | @@ -1496,6 +1517,28 @@ f_procs_qtt() { | ||
1496 | fi | 1517 | fi |
1497 | } | 1518 | } |
1498 | 1519 | ||
1520 | +F_GET_UUID_R="" | ||
1521 | +f_get_uuid() { | ||
1522 | + : 'Gerar e retornar um UUID. | ||
1523 | + | ||
1524 | + Args: | ||
1525 | + REM_DASH_P (Optional[int]): 0 - Não remove os "-" (traços); 1 - | ||
1526 | + Remove os "-" (traços). Padrão 0. | ||
1527 | + | ||
1528 | + Returns: | ||
1529 | + F_GET_UUID_R (str): UUID gerado. | ||
1530 | + ' | ||
1531 | + | ||
1532 | + REM_DASH_P=$1 | ||
1533 | + if [ -z "$REM_DASH_P" ] ; then | ||
1534 | + REM_DASH_P=0 | ||
1535 | + fi | ||
1536 | + F_GET_UUID_R=$(cat /proc/sys/kernel/random/uuid) | ||
1537 | + if [ ${REM_DASH_P} -eq 1 ] ; then | ||
1538 | + F_GET_UUID_R="${F_GET_UUID_R//-}" | ||
1539 | + fi | ||
1540 | +} | ||
1541 | + | ||
1499 | # < -------------------------------------------------------------------------- | 1542 | # < -------------------------------------------------------------------------- |
1500 | 1543 | ||
1501 | # > -------------------------------------------------------------------------- | 1544 | # > -------------------------------------------------------------------------- |
install.bash
@@ -107,8 +107,12 @@ INSTRUCT_F="" | @@ -107,8 +107,12 @@ INSTRUCT_F="" | ||
107 | 107 | ||
108 | # < -------------------------------------------------------------------------- | 108 | # < -------------------------------------------------------------------------- |
109 | 109 | ||
110 | +# NOTE: A razão para a existência dessas variáveis é "abistrair" o | ||
111 | +# funcionamento de "f_about_distro" que obtêm informações a partir de | ||
112 | +# dados da própria distro e portanto sujeito a variações! By Questor | ||
110 | DISTRO_TYPE="" | 113 | DISTRO_TYPE="" |
111 | DISTRO_NAME="" | 114 | DISTRO_NAME="" |
115 | + | ||
112 | # > ----------------------------------------- | 116 | # > ----------------------------------------- |
113 | # Checar se a distro é compatível! | 117 | # Checar se a distro é compatível! |
114 | 118 | ||
@@ -264,11 +268,11 @@ if [[ "$DISTRO_TYPE" == "RH" ]] ; then | @@ -264,11 +268,11 @@ if [[ "$DISTRO_TYPE" == "RH" ]] ; then | ||
264 | EZ_I_SKIP_ON_V=0 | 268 | EZ_I_SKIP_ON_V=0 |
265 | f_open_section | 269 | f_open_section |
266 | f_div_section | 270 | f_div_section |
267 | - f_yes_no "Disable SElinux (use "y" if you never did it)?" | 271 | + f_yes_no "Disable SElinux (use \"y\" if you never did it)?" |
268 | if [ ${YES_NO_R} -eq 1 ] ; then | 272 | if [ ${YES_NO_R} -eq 1 ] ; then |
269 | setenforce 0 | 273 | setenforce 0 |
270 | 274 | ||
271 | - # NOTE: As condições abaixo visam evitar que o arquivo seja | 275 | + # NOTE: As condições abaixo visam evitar que o arquivo seja |
272 | # desnecessariamente e erroneamente modificado! By Questor | 276 | # desnecessariamente e erroneamente modificado! By Questor |
273 | EZ_I_SKIP_ON_V=$FAST_INST | 277 | EZ_I_SKIP_ON_V=$FAST_INST |
274 | f_fl_cont_str "# SELINUX=enforcing" "/etc/sysconfig/selinux" "The file \"/etc/sysconfig/selinux\" probably has already been changed! Check it!" | 278 | f_fl_cont_str "# SELINUX=enforcing" "/etc/sysconfig/selinux" "The file \"/etc/sysconfig/selinux\" probably has already been changed! Check it!" |
@@ -443,18 +447,16 @@ f_svc_helper() { | @@ -443,18 +447,16 @@ f_svc_helper() { | ||
443 | SVC_HLP_IN_SILENCE (Optional[int]): 1 - Sem saída para o terminal; | 447 | SVC_HLP_IN_SILENCE (Optional[int]): 1 - Sem saída para o terminal; |
444 | 0 - Com saída para o terminal. Padrão 0. | 448 | 0 - Com saída para o terminal. Padrão 0. |
445 | ' | 449 | ' |
446 | - | ||
447 | SVC_HLP_NM_P=$1 | 450 | SVC_HLP_NM_P=$1 |
448 | SVC_HLP_CMD_P=$2 | 451 | SVC_HLP_CMD_P=$2 |
449 | - | ||
450 | SVC_HLP_IN_SILENCE=$3 | 452 | SVC_HLP_IN_SILENCE=$3 |
451 | if [ -z "$SVC_HLP_IN_SILENCE" ] ; then | 453 | if [ -z "$SVC_HLP_IN_SILENCE" ] ; then |
452 | SVC_HLP_IN_SILENCE=0 | 454 | SVC_HLP_IN_SILENCE=0 |
453 | fi | 455 | fi |
456 | + SVC_HLP_SILENCE_CMD="" | ||
454 | if [ ${SVC_HLP_IN_SILENCE} -eq 1 ] ; then | 457 | if [ ${SVC_HLP_IN_SILENCE} -eq 1 ] ; then |
455 | SVC_HLP_SILENCE_CMD=" &>/dev/null" | 458 | SVC_HLP_SILENCE_CMD=" &>/dev/null" |
456 | fi | 459 | fi |
457 | - | ||
458 | if [[ "$DISTRO_TYPE" == "RH" ]] ; then | 460 | if [[ "$DISTRO_TYPE" == "RH" ]] ; then |
459 | eval "systemctl $SVC_HLP_CMD_P $SVC_HLP_NM_P.service$SVC_HLP_SILENCE_CMD" | 461 | eval "systemctl $SVC_HLP_CMD_P $SVC_HLP_NM_P.service$SVC_HLP_SILENCE_CMD" |
460 | elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then | 462 | elif [[ "$DISTRO_TYPE" == "SUSE" ]] ; then |
liblightbase.tar.gz
No preview for this file type