3 Commits

Author SHA1 Message Date
Christian Tosta
e2bc795380 Merge branch 'main' of https://git.sigsolucoes.net.br/sigsolucoes/sig-installer 2025-06-11 14:50:37 -03:00
Christian Tosta
51f9ac3c36 Adicionado .gitignore 2025-06-11 14:48:19 -03:00
Christian Tosta
b4089ab2f4 Retira caracteres inválidos da senha 2025-06-09 15:32:38 -03:00
3 changed files with 135 additions and 223 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
*\.old *\.old
builtin/cli.bash.gz.b64
snippets/ snippets/
tools/ tools/

View File

@@ -3,7 +3,7 @@
set -euo pipefail set -euo pipefail
self=$(basename ${0}) self=$(basename ${0})
self=${self/.*bash} self=${self/.*bash}
version=2507.1 version=2506.3
# == Funções Gerais ============================================================================== # # == Funções Gerais ============================================================================== #
@@ -21,6 +21,7 @@ function self.check_essential {
openssh-server:sshd \ openssh-server:sshd \
sudo:sudo \ sudo:sudo \
unzip:unzip \ unzip:unzip \
tzdata:tzconfig \
" "
local _not_found= local _not_found=
@@ -41,7 +42,7 @@ function self.check_essential {
read -p \ read -p \
$"Aperte ENTER para instalar os pacotes agora [CTRL+C para cancelar]: " $"Aperte ENTER para instalar os pacotes agora [CTRL+C para cancelar]: "
apt-get update apt-get update
apt-get install -yq ${_pkgs} tzdata apt-get install -yq ${_pkgs}
fi fi
} }
self.check_essential self.check_essential
@@ -253,7 +254,7 @@ function system.install_postgres {
local _pg_version=${1:-17} local _pg_version=${1:-17}
local _citus_version=${2} local _citus_version=${2}
local POSTGRES_PACKAGES=" local POSTRES_PACKAGES="
libjemalloc2 \ libjemalloc2 \
postgresql-${_pg_version} \ postgresql-${_pg_version} \
" "
@@ -275,7 +276,7 @@ function system.install_postgres {
${ui}.color none ${ui}.color none
local _pg_shared_preload= local _pg_shared_preload=
if [[ ! -z "${_citus_version:-}" ]]; then if [[ ! -z "${_citus_version}" ]]; then
${ui}.status info $"Habilitando repositório: PostgreSQL-Citus ..." ${ui}.status info $"Habilitando repositório: PostgreSQL-Citus ..."
if [[ ! -f "/etc/apt/sources.list.d/citusdata_community.list" ]]; then if [[ ! -f "/etc/apt/sources.list.d/citusdata_community.list" ]]; then
${ui}.color gold ${ui}.color gold
@@ -289,17 +290,15 @@ function system.install_postgres {
${ui}.status tab "The repository is set up! You can now install packages." ${ui}.status tab "The repository is set up! You can now install packages."
${ui}.color none ${ui}.color none
fi fi
POSTGRES_PACKAGES+=" postgresql-${_pg_version}-citus-${_citus_version/*-}" POSTRES_PACKAGES+=" postgresql-${_pg_version}-citus-${_citus_version/*-}"
_pg_shared_preload+="citus" _pg_shared_preload+="citus"
fi fi
system.install_pkgs ${POSTGRES_PACKAGES} system.install_pkgs ${POSTRES_PACKAGES}
pg_conftool ${_pg_version} main set listen_addresses '*' pg_conftool ${_pg_version} main set listen_addresses '*'
pg_conftool ${_pg_version} main set log_timezone 'America/Sao_Paulo' pg_conftool ${_pg_version} main set log_timezone 'America/Sao_Paulo'
if [[ ! -z "${_pg_shared_preload}" ]]; then
pg_conftool ${_pg_version} main set shared_preload_libraries ${_pg_shared_preload} pg_conftool ${_pg_version} main set shared_preload_libraries ${_pg_shared_preload}
fi
local _pg_hba_file="/etc/postgresql/${_pg_version}/main/pg_hba.conf" local _pg_hba_file="/etc/postgresql/${_pg_version}/main/pg_hba.conf"
sudo cat <<-EOF | sed 's/^\s*\(.*\)/\1/g' > ${_pg_hba_file} sudo cat <<-EOF | sed 's/^\s*\(.*\)/\1/g' > ${_pg_hba_file}
@@ -859,14 +858,8 @@ system.setlocale
system.check_net system.check_net
system.setup_ntp system.setup_ntp
install_citus=0
${ui}.title $"Instalando e configurando serviços" ${ui}.title $"Instalando e configurando serviços"
if [[ ${install_citus} -eq 1 ]]; then system.install_postgres 17 citus-13.0
system.install_postgres 17 citus-13.0
else
system.install_postgres 17
fi
system.install_pyenv /usr/local/share/pyenv 2.7.18 system.install_pyenv /usr/local/share/pyenv 2.7.18
${ui}.title $"Configurando contas de usuários" ${ui}.title $"Configurando contas de usuários"

View File

@@ -2,7 +2,7 @@
set -euo pipefail set -euo pipefail
self=$(: "${0/*\/}"; echo ${_%%.*sh}) self=$(: "${0/*\/}"; echo ${_%%.*sh})
version=2508.01 version=2506.90
: ${LANG:=C.UTF-8} : ${LANG:=C.UTF-8}
@@ -167,7 +167,7 @@ function self.check_essential {
fi fi
} }
function self.get_token { function self.get_token() {
local _passphrase="Sig%$ºluc03s" local _passphrase="Sig%$ºluc03s"
tail -n +$(( \ tail -n +$(( \
@@ -202,12 +202,32 @@ function parsers.yaml {
out=${res} && echo ${out} out=${res} && echo ${out}
else else
err=$(: "${res//*\<module\>}"; echo "${_//:\ /: \[}]") err=$(: "${res//*\<module\>}"; echo "${_//:\ /: \[}]")
${ui}.status error "%s ${U_ITEM} %s" "${1##*\/} ${err}" $"NotFound" ${ui}.status error "%s ${U_ITEM} %s " "${1##*\/} ${err}" $"NotFound"
fi fi
} }
# == Configuração do Sistema====================================================================== # # == Configuração do Sistema====================================================================== #
function system.check_os {
import /etc/os-release
local _os_name=${NAME}
local _suite=${VERSION_CODENAME}
case ${_suite} in
noble|jammy) (${ui}.status info $"SO homologado: %s(%s)" ${_os_name} ${_suite}) ;;
bookworm) (${ui}.status info $"SO homologado: %s(%s)" ${_os_name} ${_suite}) ;;
trixie|*) (${ui}.status error $"SO não homologado: %s(%s)" ${_os_name} ${_suite} && exit 1) ;;
esac
return 0
}
function system.check_sudo {
# Check if user has sudo access
if ! [[ (0$(id -u) -eq 0 || "$(groups)" =~ "sudo") ]]; then
${ui}.status error $"Por favor use um usuário com privilégios de sudo"
sleep 10 && exit 1
fi
}
function system.setlocale { function system.setlocale {
${ui}.status info $"Configurando locales do sistema ..." ${ui}.status info $"Configurando locales do sistema ..."
for _locale in C en_US pt_BR; do for _locale in C en_US pt_BR; do
@@ -255,40 +275,31 @@ function system.setup_ntp {
${ui}.color none; ${ui}.color none;
} }
function system.setup_sshd { function system.create_group {
echo "UseDNS no" > /etc/sshd_config.d/no_dns.conf local _group=${@:1:1}
systemctl rertart ssh.service local _opts=${@:2}
}
# function system.create_group { # Create the Group
# local _group=${@:1:1} if ! [[ $(id -g ${_group} 2>/dev/null) ]]; then
# local _opts=${@:2} groupadd ${_opts} ${_group}
# fi
# # Create the Group }
# if ! [[ $(id -g ${_group} 2>/dev/null) ]]; then
# groupadd ${_opts} ${_group}
# fi
# }
function system.create_user { function system.create_user {
local _user=${@:1:1} local _user=${@:1:1}
local _groups=${@:2:1} local _groups=${@:2:1}
local _opts=${@:3}
if ! [[ $(id -u ${_user} 2>/dev/null) ]]; then if ! [[ $(id -u ${_user} 2>/dev/null) ]]; then
if [[ "${_opts}" =~ "-r" ]] || [[ "${_opts}" =~ "--system" ]]; then useradd -m -d /home/${_user} -U -s /bin/bash -G ${_groups} ${_user}
${ui}.status info $"Criando usuário do sistema: %s" ${_user}
useradd -M -U -G ${_groups} ${_opts} ${_user}
else else
${ui}.status info $"Criando usuário: %s" ${_user} usermod -s /bin/bash -aG ${_groups} ${_user}
useradd -m -d /home/${_user} -U -G ${_groups} ${_opts} ${_user}
fi
else
${ui}.status info $"Atualizando grupos do usuário: %s" ${_user}
usermod -aG ${_groups} ${_user}
fi fi
} }
function system.setup_openssh {
echo "UseDNS no" > /etc/sshd_config.d/no_dns.conf
systemctl rertart ssh.service
}
# == Instalação de Pacotes e Aplicativos ======================================================== # # == Instalação de Pacotes e Aplicativos ======================================================== #
@@ -377,9 +388,9 @@ function plugin.postgres {
product.setup_repos ${1:-pgdg} product.setup_repos ${1:-pgdg}
} }
_pg_check_repo pgdg #_pg_check_repo pgdg
if ! [[ -z "${_pg_citus_version}" ]]; then if ! [[ -z "${_pg_citus_version}" ]]; then
_pg_check_repo citus #_pg_check_repo citus
_pg_packages+=" postgresql-${_pg_version}-citus-${_pg_citus_version/*-}" _pg_packages+=" postgresql-${_pg_version}-citus-${_pg_citus_version/*-}"
_pg_shared_preload+="citus" _pg_shared_preload+="citus"
fi fi
@@ -428,7 +439,7 @@ EOF
| jq -nR '{ "postgresql.conf": [ inputs ] }'; \ | jq -nR '{ "postgresql.conf": [ inputs ] }'; \
sed -e '/^#/d;s/\ \+/\ /g' "${_pg_hba_file}" \ sed -e '/^#/d;s/\ \+/\ /g' "${_pg_hba_file}" \
| jq -nR '{ "pg_hba.conf": [ inputs ] }'; | jq -nR '{ "pg_hba.conf": [ inputs ] }';
) | jq -s '.'; echo ) | jq -s '.'
${ui}.writeln ${ui}.writeln
${ui}.status info $"Reiniciando o cluster " \ ${ui}.status info $"Reiniciando o cluster " \
@@ -573,85 +584,6 @@ function plugin.pyenv {
${ui}.writeln ${ui}.writeln
} }
function plugin.pip {
local _metadata_cache="${CACHEDIR}"
local _version_metadata="${_metadata_cache}/versions.yml"
# Retorna com erro se o produto não estiver definido
[[ -z "${PRODUCT}" ]] && return 1
local _product_cache="${CACHEDIR}/${PRODUCT}"
local __pip="runuser -l ${PRODUCT} -- python -m pip"
local _pip_log="$(mktemp ${_product_cache}/${self}.pip.XXXXX).log"
_pip.download() {
for _pkg in ${DOWNLOADS}; do
local _pkg_name=$(: "${_pkg%:*}"; echo "${_#*\/}")
# Tratamento de variantes do pacote:
local _pkg_verpath _pkg_variant=$(: "${_pkg#*/}"; echo "${_#*:}")
if ! [[ "${_pkg_name}" == "${_pkg_variant}" ]]; then
# true: _pkg_verpath vem da chave yaml <product>-<variant>
_pkg_verpath=$(parsers.yaml "${_version_metadata}" \
"downloads.${_pkg_name}-${_pkg_variant}")
else
# false: _pkg_verpath vem da chave yaml <product>
_pkg_verpath=$(parsers.yaml "${_version_metadata}" \
"downloads.${_pkg_name}")
fi
local _ext="tar.gz"
local _pkg_root="software/libs"
local _pkg_download_uri="$(product.get_download_uri ${_pkg_root} \
${_pkg_name} ${_pkg_verpath} ${_ext})"
local _pkg_output_file="$(product.get_output_file ${_pkg_name} \
${_pkg_verpath} ${_ext})"
installer.download \
"${_pkg_download_uri}" \
"${_pkg_output_file}" \
--quiet && \
echo "file://${_pkg_output_file}" >> "${_product_cache}/requirements-local.txt"
done
}
_pip.install() {
local \
_pip_opts="--disable-pip-version-check" \
_req_file
# Instala pacotes e módulos do python
(
${__pip} ${_pip_opts} install --upgrade --user pip setuptools \
&& find "${_product_cache}"/ -maxdepth 1 -name "requirements*.txt" \
| while read _req_file; do \
${__pip} install -r ${_req_file}
done
) 2>&1 \
| tee -a ${_pip_log} \
| ${ui}.subprocess.output 10 \
&& (
local _line; grep -iE 'installed|up-to-date' "${_pip_log}" \
| while read _line; do \
${ui}.tab 2
${ui}.item "$(${ui}.color green "${_line}${EL}")"
done
) \
|| ${ui}.subprocess.failure "Falha ao executar o PIP" ${_pip_log} PIP 100
${ui}.clear
${ui}.writeln
}
${ui}.status info $"Fazendo download dos pacotes python ..."
_pip.download
${ui}.writeln
${ui}.status info $"Instalando módulos python ..."
${ui}.get_cursor
_pip.install
${ui}.writeln
}
# == Installer =================================================================================== # # == Installer =================================================================================== #
function installer.configure { function installer.configure {
@@ -668,7 +600,7 @@ function installer.download {
local _dst="${2:-${CACHEDIR}/$(basename ${1})}" local _dst="${2:-${CACHEDIR}/$(basename ${1})}"
local _quiet=${3:-} local _quiet=${3:-}
local _repo_home="dl.sigsolucoes.net.br:/pub" local _repo_home="dl.sigsolucoes.net.br:/pub/"
local _repo_user="dl" local _repo_user="dl"
local _token=$(mktemp /tmp/${self}.dl.XXXXXX) local _token=$(mktemp /tmp/${self}.dl.XXXXXX)
@@ -679,20 +611,14 @@ function installer.download {
[[ -z "${_quiet}" ]] && ${ui}.status info $"Fazendo download [${_src}]" [[ -z "${_quiet}" ]] && ${ui}.status info $"Fazendo download [${_src}]"
#(echo ${_message} | base64 -d \ #(echo ${_message} | base64 -d \
# | bsdtar --passphrase ${_token_pass} -C $(dirname ${_token}) -xOf - > ${_token} \ # | bsdtar --passphrase ${_token_pass} -C $(dirname ${_token}) -xOf - > ${_token} \
local _err=;
(self.get_token > ${_token} \ (self.get_token > ${_token} \
&& chmod 0400 ${_token} \ && chmod 0400 ${_token} \
&& mkdir -p $(dirname "${_dst}") \ && scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
&& _err=$(scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ -qi ${_token} "${_repo_user}@${_repo_home}/${_src}" "${_dst}" \
-qi ${_token} "${_repo_user}@${_repo_home}/${_src}" "${_dst}" 2>&1) \
&& color=green || color=red; \ && color=green || color=red; \
${ui}.tab 2; \ ${ui}.color ${color}; \
${ui}.color ${color} "$(${ui}.item '')"; \
! [[ "${_quiet}" == "silent" ]] \ ! [[ "${_quiet}" == "silent" ]] \
&& ( && echo "${_src}" | sed "s/^\(.*\)/\ \ $(${ui}.item '')\1/g"; \
echo -n "${_src}"; \
! [[ -z "${_err}" ]] && echo " (${_err^})" || echo;
)
${ui}.color none; \ ${ui}.color none; \
) )
rm -f ${_token} rm -f ${_token}
@@ -807,78 +733,83 @@ function installer.product.menu {
# == Products ==================================================================================== # # == Products ==================================================================================== #
function product.download { function product.download {
local metadata_cache="${CACHEDIR}" metadata_cache="${CACHEDIR}"
local _version_metadata="${metadata_cache}/versions.yml"
local _prod_files="${1:-}" local \
_product_metadata="${metadata_cache}/products.yml" \
_version_metadata="${metadata_cache}/versions.yml" \
_prod_variant _prod_verpath _prod_download_uri \
_prod_root="software" _prod_output_dir _prod_file _lib \
_lib_root="software/libs" _lib_name _lib_variant _lib_verpath \
_lib_path _lib_download_uri _lib_file _ext="tar.gz"
# Retorna com erro se o produto não estiver definido
[[ -z "${PRODUCT}" ]] && return 1 [[ -z "${PRODUCT}" ]] && return 1
# Tratamento de variantes do produto: _prod_variant=$(parsers.yaml "${_product_metadata}" \
local _prod_verpath _prod_variant=$(product.get_property variant) "products.${PRODUCT}.variant")
if ! [[ "${PRODUCT}" == "${_prod_variant}" ]]; then
# true: _prod_verpath vem da chave yaml <product>-<variant> # Treat if product has variants:
_prod_verpath=$(parsers.yaml "${_version_metadata}" \ # true: verpath field comes from yaml key <product>-<variant>
"products.${PRODUCT}-${_prod_variant}") # false: verpath field comes from yaml key <product>
else ! [[ "${PRODUCT}" == "${_prod_variant}" ]] \
# false: _prod_verpath vem da chave yaml <product> && _prod_verpath=$(parsers.yaml "${_version_metadata}" \
_prod_verpath=$(parsers.yaml "${_version_metadata}" \ "products.${PRODUCT}-${_prod_variant}") \
|| _prod_verpath=$(parsers.yaml "${_version_metadata}" \
"products.${PRODUCT}") "products.${PRODUCT}")
fi
# Define a extensão do arquivo principal do produto _get_download_uri() {
local _ext="tar.gz"
#[[ "${@}" =~ '(ext=tar\.[bgxz]{2}\d*)' ]] \
# && _ext="${BASH_REMATCH[1]}"
local _prod_root="software"
local _prod_download_uri="$(product.get_download_uri ${_prod_root} \
${PRODUCT} ${_prod_verpath} ${_ext})"
local _prod_output_file="$(product.get_output_file ${PRODUCT} \
${_prod_verpath} ${_ext})"
# Download do arquivo principal do produto
mkdir -p $(dirname ${_prod_output_file})
${ui}.status info $"Fazendo download do produto ..."
installer.download \
"${_prod_download_uri}" \
"${_prod_output_file}" \
--quiet
#${ui}.writeln
# Download dos arquivos adicionais
local _files_root="installer"
local _keys=$(echo ${_prod_files//\'/\"} | jq 'keys_unsorted[]')
local _k; for _k in ${_keys[*]}; do
local _files=$(echo ${_prod_files//\'/\"} \
| jq ".${_k} |= join(\" \")" \
| jq ".${_k}"
)
local _file; for _file in ${_files}; do
_file="${_file//\$\{variant\}/${_prod_variant}}"
installer.download \
"${_files_root}/config/${PRODUCT}/${_file//\"}" \
"${CACHEDIR}/${PRODUCT}/${_file//\"}" \
--quiet
done
done
${ui}.writeln
chmod g+rx,o+rx ${CACHEDIR}
#${ui}.status info $"Download concluído."
#${ui}.prompt $"Pressione uma tecla para continuar ... "
}
function product.get_download_uri {
local _p=$(dirname "${3}") local _p=$(dirname "${3}")
! [[ "${_p}" == "." ]] && _p="${_p}/" || _p= ! [[ "${_p}" == "." ]] && _p="${_p}/" || _p=
echo "${1}/${2}/${_p}${2}-${3/*\/}.${4:-tar.gz}" echo "${1}/${2}/${_p}${2}-${3/*\/}.${4:-tar.gz}"
} }
function product.get_output_file { _get_output_file() {
local metadata_cache="${CACHEDIR}"
echo "${metadata_cache}/${PRODUCT}/${1}-${2/*\/}.${3:-tar.gz}" echo "${metadata_cache}/${PRODUCT}/${1}-${2/*\/}.${3:-tar.gz}"
}
#[[ "${@}" =~ '(ext=tar\.[bgxz]{2}\d*)' ]] \
# && _ext="${BASH_REMATCH[1]}"
_prod_download_uri="$(_get_download_uri ${_prod_root} \
${PRODUCT} ${_prod_verpath} ${_ext})"
_prod_output_file="$(_get_output_file ${PRODUCT} \
${_prod_verpath} ${_ext})"
mkdir -p $(dirname ${_prod_output_file})
${ui}.status info $"Fazendo download dos arquivos ..."
installer.download \
"${_prod_download_uri}" \
"${_prod_output_file}" \
--quiet
for _lib in ${DOWNLOADS}; do
_lib_name=$(: "${_lib%:*}"; echo "${_#*\/}")
_lib_variant=$(: "${_lib#*/}"; echo "${_#*:}")
# Treat if library has variants:
# true: verpath field comes from yaml key <library>-<variant>
# false: verpath field comes from yaml key <library>
! [[ "${_lib_name}" == "${_lib_variant}" ]] \
&& _lib_verpath=$(parsers.yaml "${_version_metadata}" \
"downloads.${_lib_name}-${_lib_variant}") \
|| _lib_verpath=$(parsers.yaml "${_version_metadata}" \
"downloads.${_lib_name}")
_lib_download_uri="$(_get_download_uri ${_lib_root} \
${_lib_name} ${_lib_verpath} ${_ext})"
_lib_output_file="$(_get_output_file ${_lib_name} \
${_lib_verpath} ${_ext})"
installer.download \
"${_lib_download_uri}" \
"${_lib_output_file}" \
--quiet
done
chmod g+rx,o+rx ${CACHEDIR}
${ui}.status info $"Download concluído."
#${ui}.prompt $"Pressione uma tecla para continuar ... "
} }
function product.get_property { function product.get_property {
@@ -911,7 +842,7 @@ function product.get_property {
name) echo "$(_get_property .name)" ;; name) echo "$(_get_property .name)" ;;
version) echo "$(basename ${_prod_verpath})" ;; version) echo "$(basename ${_prod_verpath})" ;;
variant) echo "$(_get_property .variant)" ;; variant) echo "$(_get_property .variant)" ;;
*) echo "$(_get_property ."${1:-}")" ;; *) echo "$(_get_property ."${1:-}")" || : ;;
esac esac
} }
@@ -954,7 +885,7 @@ function product.get_requires {
case ${_repo} in case ${_repo} in
""|default) continue ;; ""|default) continue ;;
local) echo "${_pkg}" >> ${CACHEDIR}/${PRODUCT}.local.build ;; local) echo "${_pkg}" >> ${CACHEDIR}/${PRODUCT}.local.build ;;
sig|pip) DOWNLOADS+="${_pkg} " ;; sig) DOWNLOADS+="${_pkg} " ;;
*) ! [[ "${REPOS}" =~ "${_repo}" ]] && REPOS+="${_repo} " *) ! [[ "${REPOS}" =~ "${_repo}" ]] && REPOS+="${_repo} "
esac esac
done done
@@ -999,49 +930,34 @@ function product.get_requires {
} }
function product.install { function product.install {
local metadata_cache="${CACHEDIR}" metadata_cache="${CACHEDIR}"
cli.section "%s [VERSÃO: %s] - INSTALAÇÃO DO PRODUTOS${EL}\n" \ cli.section "%s [VERSÃO: %s] - INSTALAÇÃO DO PRODUTOS${EL}\n" \
${self^^} \ ${self^^} \
${version} || : ${version} || :
${ui}.title $"Produto: " "$(product.get_property name)" ${ui}.title $"Produto: " "$(product.get_property name)"
${ui}.subtitle $"Configuração Geral"
# -- Configura região e idioma do sistema
#system.setlocale pt_BR.UTF-8 #system.setlocale pt_BR.UTF-8
#product.download
# -- Cria/atualiza usuário e grupos do produto _paths="$(product.get_property paths)"
local _user="$(product.get_property user.name)" _keys="$(echo "${_paths//\'/\"}" | jq 'keys_unsorted[]')"
local _shell="$(product.get_property user.shell)"
local _home="$(product.get_property paths.home)"
local _groups="$(product.get_property user.groups)"
system.create_user "${_user}" ${_groups//\ /,} -s "${_shell}" -d "${_home}" -r
chown -R "${_user}:" "${_home}"
# -- Cria filesystem (diretórios) do produto
local _paths="$(product.get_property paths)"
local _keys="$(echo "${_paths//\'/\"}" | jq 'keys_unsorted[]')"
${ui}.status info $"Criando diretórios e links ... " ${ui}.status info $"Criando diretórios e links ... "
local _k; for _k in ${_keys[*]}; do for _k in ${_keys[*]}; do
local _dir=$(echo "${_paths//\'/\"}" | jq ".${_k}" | sed 's/\"//g') _dir=$(echo "${_paths//\'/\"}" | jq ".${_k}")
mkdir -p "${_dir}" \ mkdir -p ${_dir} \
&& (${ui}.tab; ${ui}.item "${_dir//\"/}") \ && (${ui}.tab; ${ui}.item "${_dir//\"/}")
&& chown -R "${_user}:" "${_dir}"
done done
ln -snf /srv/sig /sig
${ui}.writeln ${ui}.writeln
# -- Faz download do produto e arquivos relacionados
local _files="$(product.get_property files)"
product.download "${_files}"
unset _files
# -- Configurando repositórios # -- Configurando repositórios
product.setup_repos ${REPOS} product.setup_repos ${REPOS}
# -- Instalando pacotes necessários # -- Instalando pacotes necessários
system.install_pkgs ${BUILD_REQUIRES} system.install_pkgs ${BUILD_REQUIRES}
${ui}.prompt "Aguarde ou pressione ENTER para continuar ..." -s -t 10 || :
# -- Compilando requisitos não empacotados # -- Compilando requisitos não empacotados
_builds=$(grep "^local/" ${metadata_cache}/${PRODUCT}.local.build) _builds=$(grep "^local/" ${metadata_cache}/${PRODUCT}.local.build)
@@ -1055,21 +971,26 @@ function product.install {
_k_args=${_args#*@} _k_args=${_args#*@}
;; ;;
esac esac
if ! [[ "no-clear" =~ "${_k_args}" ]]; then
${ui}.set_cursor 0 8
${ui}.get_cursor
${ui}.clear
fi
${ui}.subtitle $"Executando plugin: "${_args%@*} ${ui}.subtitle $"Executando plugin: "${_args%@*}
${_callback} ${_k_args//;/\ } ${_callback} ${_k_args//;/\ }
${ui}.prompt "Aguarde ou pressione ENTER para continuar ..." -s -t 10 || :
done done
echo "TODO: Configurar produto (function product.configure)"
## -- SIG ----------------------------- # ## -- SIG ----------------------------- #
# Pyenv
# useradd -m -d /srv/sig/${PRODUCT} -s /bin/bash -G pyenv -r -U ${PRODUCT} 2>/dev/null || :
# cat /etc/skel/.bashrc > /srv/sig/${PRODUCT}/.bashrc
# echo -e "\n# Load Python ${_pdpy}\npyenv local ${_pdpy} >/dev/null 2>&1" >> /srv/sig/${PRODUCT}/.bashrc
# echo ${_pdpy} > /srv/sig/${PRODUCT}/.python-version
#
# # Pip modules # # Pip modules
# ${ui}.status info $"Instalando produto [%s] ..." "${_name}"
# ${ui}.color gold
# runuser -l ${PRODUCT} -- python -m pip install --upgrade --user pip
# runuser -l ${PRODUCT} -- python -m pip install --upgrade --user setuptools
# for _lib in ${_libs}; do # for _lib in ${_libs}; do
# _lbpv=$(parsers.yaml ${CACHEDIR}/versions.yml libs.python${_pdpy/.*}.${_lib})
# runuser -l ${PRODUCT} -- python -m pip install --user \
# "${CACHEDIR}/${PRODUCT}/${_lib}-${_lbpv#*/}.tar.gz"
# if [[ "${_lib}" == "kiwi" ]]; then # if [[ "${_lib}" == "kiwi" ]]; then
# _f=/srv/sig/${PRODUCT}/.local/lib/python2.7/site-packages/kiwi/__installed__.py # _f=/srv/sig/${PRODUCT}/.local/lib/python2.7/site-packages/kiwi/__installed__.py
# find $(dirname ${_f})/ -name *.pyc -delete # find $(dirname ${_f})/ -name *.pyc -delete
@@ -1186,7 +1107,6 @@ self.check_essential
#${ui}.title $"Reconfigurando o sistema operacional" #${ui}.title $"Reconfigurando o sistema operacional"
#system.check_net #system.check_net
#system.setup_ntp #system.setup_ntp
#system.setup_sshd
#${ui}.title $"Configurando contas de usuários" #${ui}.title $"Configurando contas de usuários"
#system.create_user sig dialout,pyenv,sudo #system.create_user sig dialout,pyenv,sudo