Compare commits
1 Commits
dd5608e8e3
...
v2506.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16cc315bd6 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +0,0 @@
|
|||||||
*\.old
|
|
||||||
builtin/cli.bash.gz.b64
|
|
||||||
snippets/
|
|
||||||
tools/
|
|
||||||
@@ -9,11 +9,11 @@ export C_ORANGE="\033[38;5;208m"
|
|||||||
export C_GOLD="\033[38;5;220m"
|
export C_GOLD="\033[38;5;220m"
|
||||||
export C_PURPLE="\033[38;5;5m"
|
export C_PURPLE="\033[38;5;5m"
|
||||||
|
|
||||||
export S_INFO="${C_BLUE}\u2691 [info]${NO_FMT} "
|
export S_INFO="${C_BLUE}\u2691 [info] ${NO_FMT} "
|
||||||
export S_SUCCESS="${C_GREEN}\u2691 [success]${NO_FMT}\u2713 "
|
export S_SUCCESS="${C_GREEN}\u2691 [success] ${NO_FMT}\u2713 "
|
||||||
export S_DEBUG="${C_PURPLE}\u2691 [debug]${NO_FMT} "
|
export S_DEBUG="${C_PURPLE}\u2691 [debug]${NO_FMT} "
|
||||||
export S_WARN="${C_ORANGE}\u2691 [warning]${NO_FMT} "
|
export S_WARN="${C_ORANGE}\u2691 [warning] ${NO_FMT} "
|
||||||
export S_ERROR="${C_RED}\u2691 [error]${NO_FMT}\u2715 "
|
export S_ERROR="${C_RED}\u2691 [error] ${NO_FMT}\u2715 "
|
||||||
|
|
||||||
export U_ITEM="\u2192"
|
export U_ITEM="\u2192"
|
||||||
|
|
||||||
@@ -52,3 +52,4 @@ cli.section() {
|
|||||||
__section.content "${@:4}"
|
__section.content "${@:4}"
|
||||||
__section.footer
|
__section.footer
|
||||||
}
|
}
|
||||||
|
cli.section "${@}"
|
||||||
|
|||||||
213
builtin/cli.bash
213
builtin/cli.bash
@@ -1,213 +0,0 @@
|
|||||||
export F_BOLD="\e[1m"
|
|
||||||
export F_NONE="\e[0m"
|
|
||||||
|
|
||||||
export C_NONE="\e[0m"
|
|
||||||
export C_RED="\e[38;5;9m"
|
|
||||||
export C_BLUE="\e[38;5;12m"
|
|
||||||
export C_GREEN="\e[38;5;2m"
|
|
||||||
export C_ORANGE="\e[38;5;208m"
|
|
||||||
export C_YELLOW="\e[38;5;220m"
|
|
||||||
export C_PURPLE="\e[38;5;5m"
|
|
||||||
|
|
||||||
export S_DEBUG="${C_PURPLE}\u2691 [debug]${F_NONE} "
|
|
||||||
export S_CRIT="${F_BOLD}${C_RED}\u2691 [critical]${F_NONE} "
|
|
||||||
export S_ERROR="${C_RED}\u2691 [error]${F_NONE} "
|
|
||||||
export S_WARN="${C_ORANGE}\u2691 [warning]${F_NONE} "
|
|
||||||
export S_INFO="${F_BOLD}${C_BLUE}\u2691 [info]${F_NONE} "
|
|
||||||
export S_NOTICE="${C_BLUE}\u2691 [notice]${F_NONE} "
|
|
||||||
export S_SUCCESS="${F_BOLD}${C_GREEN}\u2691 [success]${F_NONE} "
|
|
||||||
|
|
||||||
export U_ITEM="\u21e2"
|
|
||||||
export U_TICK="\u2713"
|
|
||||||
export U_FAIL="\u2715"
|
|
||||||
|
|
||||||
export COLS="$(( $(tput cols) - 1 ))"
|
|
||||||
export EL=$(tput el)
|
|
||||||
|
|
||||||
: "cli.clear"
|
|
||||||
function cli.clear {
|
|
||||||
clear
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get the cursor current position and returns CURSOR_X, CURSOR_Y
|
|
||||||
: "cli.get_cursor"
|
|
||||||
cli.get_cursor() {
|
|
||||||
local _xy
|
|
||||||
|
|
||||||
echo -ne $"\E[6n"
|
|
||||||
read -rsdR _xy
|
|
||||||
_xy="${_xy#*[}"
|
|
||||||
export CURSOR_X=${_xy/*;}
|
|
||||||
export CURSOR_Y=${_xy/;*}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Puts the cursor at x:y (defaults to 0:0)
|
|
||||||
: "cli.set_cursor <x> <y>"
|
|
||||||
cli.set_cursor() {
|
|
||||||
printf "\E[%sH" "${2:0};${1:0}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Just prints N blank lines
|
|
||||||
: "cli.jump <number_lines>"
|
|
||||||
cli.jump() {
|
|
||||||
for i in $(seq 1 ${1:-1}); do
|
|
||||||
printf "%s${EL}\n"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Just like printf
|
|
||||||
: "cli.print [<printf_format>] <arg1> [<arg2> ...]"
|
|
||||||
cli.print() {
|
|
||||||
printf $"${1}" ${@:2}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Folds text at 'size' column
|
|
||||||
: "cli.fold <size> <text>"
|
|
||||||
cli.fold() {
|
|
||||||
printf "%s" "${@:2}" | fold -sw ${1}
|
|
||||||
}
|
|
||||||
|
|
||||||
: "cli.status <status> [<printf_format>] <arg>"
|
|
||||||
cli.status() {
|
|
||||||
local fmt=${2//\\n}
|
|
||||||
cli.jump
|
|
||||||
case "${1:-info}" in
|
|
||||||
debug) printf "\e[0F${S_DEBUG}${fmt:-%s}${@:3}${EL}\n" ;;
|
|
||||||
crit*) printf "\e[0F${S_CRIT}${fmt:-%s}${@:3}${EL}\n" ;;
|
|
||||||
error) printf "\e[0F${S_ERROR}${fmt:-%s}${@:3}${EL}\n" ;;
|
|
||||||
warn*) printf "\e[0F${S_WARN}${fmt:-%s}${@:3}${EL}\n" ;;
|
|
||||||
info*) printf "\e[0F${S_INFO}${fmt:-%s}${@:3}${EL}\n" ;;
|
|
||||||
noti*) printf "\e[0F${S_NOTICE}${fmt:-%s}${@:3}${EL}\n" ;;
|
|
||||||
succ*) printf "\e[0F${S_SUCCESS}${fmt:-%s}${@:3}${EL}\n" ;;
|
|
||||||
*) printf "\e[0F${S_INFO}${fmt:-%s}" "${@:3}" ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
: "cli.color <color> [<printf_format>] <arg1> [<arg2> ...]"
|
|
||||||
cli.color() {
|
|
||||||
local fmt="${2:-}"
|
|
||||||
fmt="${fmt//\\n}"
|
|
||||||
case "${1:-}" in
|
|
||||||
red) printf "${C_RED}${fmt:-%s}${C_NONE}" ${@:3} ;;
|
|
||||||
blue) printf "${C_BLUE}${fmt:-%s}${C_NONE}" ${@:3} ;;
|
|
||||||
green) printf "${C_GREEN}${fmt:-%s}${C_NONE}" ${@:3} ;;
|
|
||||||
orange) printf "${C_ORANGE}${fmt:-%s}${C_NONE}" ${@:3} ;;
|
|
||||||
yellow) printf "${C_YELLOW}${fmt:-%s}${C_NONE}" ${@:3} ;;
|
|
||||||
purple) printf "${C_PURPLE}${fmt:-%s}${C_NONE}" ${@:3} ;;
|
|
||||||
*) printf "${C_NONE}${fmt:-%s}${C_NONE}" ${@:3} ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
: "cli.emphasis <color|bold> [<printf_format>] <arg1> [<arg2> ...]"
|
|
||||||
cli.emphasis() {
|
|
||||||
local fmt="${2:-}"
|
|
||||||
fmt="${fmt//\\n}"
|
|
||||||
case "${1:-bold}" in
|
|
||||||
red) printf "${C_RED}${F_BOLD}${fmt:-%s}${F_NONE}" "${@:3}" ;;
|
|
||||||
blue) printf "${C_BLUE}${F_BOLD}${fmt:-%s}${F_NONE}" "${@:3}" ;;
|
|
||||||
green) printf "${C_GREEN}${F_BOLD}${fmt:-%s}${F_NONE}" "${@:3}" ;;
|
|
||||||
orange) printf "${C_ORANGE}${F_BOLD}${fmt:-%s}${F_NONE}" "${@:3}" ;;
|
|
||||||
yellow) printf "${C_YELLOW}${F_BOLD}${fmt:-%s}${F_NONE}" "${@:3}" ;;
|
|
||||||
purple) printf "${C_PURPLE}${F_BOLD}${fmt:-%s}${F_NONE}" "${@:3}" ;;
|
|
||||||
bold|*) printf "${F_BOLD}${fmt:-%s}${F_NONE}" "${@:3}" ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
: "cli.bold <arg>"
|
|
||||||
cli.bold() {
|
|
||||||
cli.emphasis bold "%s" "${@}"
|
|
||||||
}
|
|
||||||
|
|
||||||
: "cli.tab <size>"
|
|
||||||
cli.tab() {
|
|
||||||
s=${1:-2}
|
|
||||||
! [[ -z "${s//[0-9]}" ]] && s=2
|
|
||||||
printf "%${s:-2}s" " "
|
|
||||||
}
|
|
||||||
|
|
||||||
: "cli.items [<printf_format>] <text> [<text> ...]"
|
|
||||||
cli.items() {
|
|
||||||
printf "${U_ITEM} ${1:-%s}" "${@:2}"
|
|
||||||
}
|
|
||||||
|
|
||||||
: "cli.items <text>"
|
|
||||||
cli.item() {
|
|
||||||
cli.items "%s\n" "${@}" | head -1
|
|
||||||
}
|
|
||||||
|
|
||||||
: "cli.title <text>"
|
|
||||||
cli.title() {
|
|
||||||
cli.items "%s" "$(cli.emphasis blue "%s" "${@^^}")"
|
|
||||||
cli.line
|
|
||||||
}
|
|
||||||
|
|
||||||
: "cli.subtitle <text>"
|
|
||||||
cli.subtitle() {
|
|
||||||
printf "%0.s\u2508%s"
|
|
||||||
cli.bold " ${@^^} "
|
|
||||||
cli.get_cursor
|
|
||||||
for i in $(seq 0 $((( ${COLS} - ${CURSOR_X} )))); do
|
|
||||||
printf "%0.s\u2508"
|
|
||||||
done
|
|
||||||
cli.jump
|
|
||||||
}
|
|
||||||
|
|
||||||
: "cli.prompt <tab_size> [<prompt_text>]"
|
|
||||||
cli.prompt() {
|
|
||||||
read -p "$(cli.print ${1:-})" k
|
|
||||||
echo ${k}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Draws a horizontal line
|
|
||||||
: "cli.line [nobreak]"
|
|
||||||
cli.line() {
|
|
||||||
[[ -z "${1:-}" ]] && cli.jump
|
|
||||||
for i in $(seq 1 ${COLS}); do
|
|
||||||
printf "%0.s\u2504"
|
|
||||||
done
|
|
||||||
[[ -z "${1:-}" ]] && cli.jump
|
|
||||||
}
|
|
||||||
|
|
||||||
# Draws a thin horizontal divisor line
|
|
||||||
: "cli.boldline"
|
|
||||||
cli.boldline() {
|
|
||||||
for i in $(seq 1 ${COLS}); do
|
|
||||||
printf "%0.s\u2581"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
: "cli.section <printf_format> <title> <subtitle> <content>"
|
|
||||||
cli.section() {
|
|
||||||
__section.header() {
|
|
||||||
__section.title() {
|
|
||||||
printf $"${@:1:1}" \
|
|
||||||
$(echo -ne ${F_BOLD}${C_BLUE}${@:2:1}${F_NONE}) \
|
|
||||||
$(echo -ne ${C_ORANGE}${@:3}${F_NONE})
|
|
||||||
}
|
|
||||||
__section.title.underline() {
|
|
||||||
cli.boldline
|
|
||||||
}
|
|
||||||
__section.title "${@}"
|
|
||||||
__section.title.underline
|
|
||||||
}
|
|
||||||
__section.content() {
|
|
||||||
cli.jump 2
|
|
||||||
cli.fold ${COLS} "${@}"
|
|
||||||
}
|
|
||||||
__section.footer() {
|
|
||||||
__section.footer.line() {
|
|
||||||
cli.line
|
|
||||||
}
|
|
||||||
__section.footer.line
|
|
||||||
}
|
|
||||||
__section.header "${@:1:3}"
|
|
||||||
__section.content "${@:4}"
|
|
||||||
__section.footer
|
|
||||||
}
|
|
||||||
|
|
||||||
cli.self_compress() {
|
|
||||||
cat cli.bash | \
|
|
||||||
gzip -c9 - | \
|
|
||||||
base64 -w77 | \
|
|
||||||
xargs printf ' %s \\\n'
|
|
||||||
}
|
|
||||||
161
sig-installer
Executable file → Normal file
161
sig-installer
Executable file → Normal file
@@ -3,7 +3,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
self=$(basename ${0})
|
self=$(basename ${0})
|
||||||
self=${self/.*bash}
|
self=${self/.*bash}
|
||||||
version=2506.3
|
version=2506.1
|
||||||
|
|
||||||
# == Funções Gerais ============================================================================== #
|
# == Funções Gerais ============================================================================== #
|
||||||
|
|
||||||
@@ -564,23 +564,17 @@ function produto.install {
|
|||||||
runuser -l ${PRODUTO} -- python -m pip install --upgrade --user pip
|
runuser -l ${PRODUTO} -- python -m pip install --upgrade --user pip
|
||||||
runuser -l ${PRODUTO} -- python -m pip install --upgrade --user setuptools
|
runuser -l ${PRODUTO} -- python -m pip install --upgrade --user setuptools
|
||||||
for _lib in ${_libs}; do
|
for _lib in ${_libs}; do
|
||||||
|
[[ "${_lib}" == "stoqdrivers" ]] && continue
|
||||||
_lbpv=$(parsers.yaml ${CACHEDIR}/versoes.yml libs.python${_pdpy/.*}.${_lib})
|
_lbpv=$(parsers.yaml ${CACHEDIR}/versoes.yml libs.python${_pdpy/.*}.${_lib})
|
||||||
runuser -l ${PRODUTO} -- python -m pip install --user \
|
runuser -l ${PRODUTO} -- python -m pip install --user \
|
||||||
"${CACHEDIR}/${PRODUTO}/${_lib}-${_lbpv#*/}.tar.gz"
|
"${CACHEDIR}/${PRODUTO}/${_lib}-${_lbpv#*/}.tar.gz"
|
||||||
if [[ "${_lib}" == "kiwi" ]]; then
|
|
||||||
_f=/srv/sig/${PRODUTO}/.local/lib/python2.7/site-packages/kiwi/__installed__.py
|
|
||||||
find $(dirname ${_f})/ -name *.pyc -delete
|
|
||||||
download "installer/config/${PRODUTO}/__installed__.py" "${_f}" \
|
|
||||||
&& chown -R ${PRODUTO}:${PRODUTO} "${_f}" \
|
|
||||||
&& chmod 644 ${_f} \
|
|
||||||
&& touch ${_f}
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
case "${PRODUTO}" in
|
case "${PRODUTO}" in
|
||||||
sigerp)
|
sigerp)
|
||||||
_date=$(date +%Y%m%d%H%M%S)
|
_date=$(date +%Y%m%d%H%M%S)
|
||||||
_pdpy=$(parsers.yaml ${CACHEDIR}/produtos.yml "produtos.${PRODUTO}.python")
|
_pdpy=$(parsers.yaml ${CACHEDIR}/produtos.yml "produtos.${PRODUTO}.python")
|
||||||
|
_dbuser="openerp"
|
||||||
|
|
||||||
# Addons SigERP
|
# Addons SigERP
|
||||||
[[ -d "/srv/sig/${PRODUTO}/addons" ]] && \
|
[[ -d "/srv/sig/${PRODUTO}/addons" ]] && \
|
||||||
@@ -600,7 +594,7 @@ function produto.install {
|
|||||||
# Runner and systemd units
|
# Runner and systemd units
|
||||||
download "installer/config/${PRODUTO}/sigerp-runner-pyenv-${_pdpy}.sh" \
|
download "installer/config/${PRODUTO}/sigerp-runner-pyenv-${_pdpy}.sh" \
|
||||||
"/srv/sig/${PRODUTO}/sigerp-runner" \
|
"/srv/sig/${PRODUTO}/sigerp-runner" \
|
||||||
&& chmod +x "/srv/sig/${PRODUTO}/sigerp-runner" \
|
&& chmod +x "/srv/sig/${PRODUTO}/sigerp-runner" \
|
||||||
&& ln -snf \
|
&& ln -snf \
|
||||||
"/srv/sig/${PRODUTO}/sigerp-runner" \
|
"/srv/sig/${PRODUTO}/sigerp-runner" \
|
||||||
"/usr/local/bin/sigerp-runner"
|
"/usr/local/bin/sigerp-runner"
|
||||||
@@ -644,18 +638,17 @@ function produto.install {
|
|||||||
system.install_pkgs ${SIGERP_PACKAGES}
|
system.install_pkgs ${SIGERP_PACKAGES}
|
||||||
|
|
||||||
# Create/Alter PostgreSQL user
|
# Create/Alter PostgreSQL user
|
||||||
local _dbuser="openerp"
|
local _password=$(openssl rand -base64 32 | sed 's/\//|/g')
|
||||||
local _password=$(openssl rand -base64 32 | sed 's/[/+-_=]//g')
|
|
||||||
${ui}.status info $"Criando/Atualizando usuário do banco de dados [%s]" ${PRODUTO}
|
${ui}.status info $"Criando/Atualizando usuário do banco de dados [%s]" ${PRODUTO}
|
||||||
sudo -iu postgres \
|
sudo -iu postgres \
|
||||||
psql -c \
|
psql -c \
|
||||||
"CREATE USER ${_dbuser} WITH \
|
"CREATE USER ${dbuser} WITH \
|
||||||
PASSWORD '${_password}' \
|
PASSWORD '${_password}' \
|
||||||
CREATEDB;" \
|
CREATEDB;" \
|
||||||
|| \
|
|| \
|
||||||
sudo -iu postgres \
|
sudo -iu postgres \
|
||||||
psql -c \
|
psql -c \
|
||||||
"ALTER USER ${_dbuser} WITH \
|
"ALTER USER ${dbuser} WITH \
|
||||||
PASSWORD '${_password}' \
|
PASSWORD '${_password}' \
|
||||||
CREATEDB;"
|
CREATEDB;"
|
||||||
|
|
||||||
@@ -671,20 +664,12 @@ function produto.install {
|
|||||||
;;
|
;;
|
||||||
sigpdv)
|
sigpdv)
|
||||||
_date=$(date +%Y%m%d%H%M%S)
|
_date=$(date +%Y%m%d%H%M%S)
|
||||||
|
|
||||||
# -- Faz o backup da pasta anterior do SigPDV
|
|
||||||
[[ -d "/srv/sig/${PRODUTO}/sigpdv" ]] && \
|
[[ -d "/srv/sig/${PRODUTO}/sigpdv" ]] && \
|
||||||
mv \
|
mv \
|
||||||
/srv/sig/${PRODUTO}/sigpdv \
|
/srv/sig/${PRODUTO}/sigpdv \
|
||||||
/srv/sig/${PRODUTO}/sigpdv.${_date}.bak
|
/srv/sig/${PRODUTO}/sigpdv.${_date}.bak
|
||||||
|
|
||||||
|
# TODO: Simplificar essa baderna
|
||||||
# -- Cria a árvore de diretórios do SigPDV
|
|
||||||
mkdir -p /srv/sig/${PRODUTO}/sigpdv
|
|
||||||
mkdir -p /usr/local/sigext
|
|
||||||
mkdir -p /recebe
|
|
||||||
|
|
||||||
# -- Instala pacotes necessários para rodar o programa
|
|
||||||
SIGPV_PACKAGES="
|
SIGPV_PACKAGES="
|
||||||
atop \
|
atop \
|
||||||
libmysqlclient21 \
|
libmysqlclient21 \
|
||||||
@@ -699,101 +684,109 @@ function produto.install {
|
|||||||
"
|
"
|
||||||
system.install_pkgs ${SIGPV_PACKAGES}
|
system.install_pkgs ${SIGPV_PACKAGES}
|
||||||
|
|
||||||
# -- Download e instalação dos addons e aplicação de correções
|
mkdir -p /srv/sig/${PRODUTO}/sigpdv
|
||||||
tar -C /srv/sig/${PRODUTO}/ \
|
mkdir -p /usr/local/sigext
|
||||||
-xzf ${CACHEDIR}/${PRODUTO}/${PRODUTO}-${_pdpv#*/}.tar.gz
|
mkdir -p /recebe
|
||||||
ln -snf \
|
|
||||||
/srv/sig/${PRODUTO}/sigpdv \
|
|
||||||
/srv/sig/sigpdv/.local/lib/python2.7/site-packages/
|
|
||||||
ln -snf \
|
|
||||||
/srv/sig/${PRODUTO}/sigpdv \
|
|
||||||
/usr/local/
|
|
||||||
# Correção para erro "Dois frentes em execução"
|
|
||||||
download "installer/config/${PRODUTO}/${PRODUTO}-single-instance-fix.patch" \
|
download "installer/config/${PRODUTO}/${PRODUTO}-single-instance-fix.patch" \
|
||||||
"${CACHEDIR}/sigpdv/${PRODUTO}-single-instance-fix.patch"
|
"${CACHEDIR}/sigpdv/${PRODUTO}-single-instance-fix.patch"
|
||||||
|
|
||||||
|
tar -C /srv/sig/${PRODUTO}/ \
|
||||||
|
-xzf ${CACHEDIR}/${PRODUTO}/${PRODUTO}-${_pdpv#*/}.tar.gz
|
||||||
patch -d /srv/sig/${PRODUTO}/sigpdv \
|
patch -d /srv/sig/${PRODUTO}/sigpdv \
|
||||||
-p0 < "${CACHEDIR}/sigpdv/${PRODUTO}-single-instance-fix.patch"
|
-p0 < "${CACHEDIR}/sigpdv/${PRODUTO}-single-instance-fix.patch"
|
||||||
|
|
||||||
# -- Instalação dos módulos python de dependências
|
ln -snf /srv/sig/${PRODUTO}/sigpdv /usr/local/
|
||||||
|
|
||||||
|
ln -snf \
|
||||||
|
/srv/sig/${PRODUTO}/sigpdv \
|
||||||
|
/srv/sig/sigpdv/.local/lib/python2.7/site-packages/
|
||||||
|
|
||||||
|
mkdir /srv/sig/sigpdv/.local/lib/python2.7/site-packages/share \
|
||||||
|
&& mv /srv/sig/${PRODUTO}/.local/share/kiwi \
|
||||||
|
/srv/sig/sigpdv/.local/lib/python2.7/site-packages/share/ \
|
||||||
|
&& ln -snf \
|
||||||
|
/srv/sig/sigpdv/.local/lib/python2.7/site-packages/share/kiwi \
|
||||||
|
/srv/sig/${PRODUTO}/.local/share/ \
|
||||||
|
|
||||||
|
tar --transform="s|stoqdrivers/||" \
|
||||||
|
-C /srv/sig/sigpdv/.local/lib/python2.7/site-packages/ \
|
||||||
|
-xzf ${CACHEDIR}/${PRODUTO}/stoqdrivers-0.9.11.tar.gz \
|
||||||
|
stoqdrivers/stoqdrivers
|
||||||
|
|
||||||
download "installer/config/${PRODUTO}/requirements.txt" \
|
download "installer/config/${PRODUTO}/requirements.txt" \
|
||||||
"/srv/sig/${PRODUTO}/sigpdv/requirements.txt"
|
"/srv/sig/${PRODUTO}/sigpdv/requirements.txt"
|
||||||
[[ -f "/srv/sig/${PRODUTO}/sigpdv/requirements.txt" ]] && \
|
|
||||||
runuser -l ${PRODUTO} -- \
|
|
||||||
python -m pip install -qq -r /srv/sig/${PRODUTO}/sigpdv/requirements.txt --user \
|
|
||||||
&& rm -f /srv/sig/${PRODUTO}/sigpdv/requirements.txt
|
|
||||||
|
|
||||||
# -- Lançadores dos programas
|
|
||||||
download "installer/config/${PRODUTO}/${PRODUTO}-wrapper.sh" \
|
download "installer/config/${PRODUTO}/${PRODUTO}-wrapper.sh" \
|
||||||
"/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" \
|
"/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" \
|
||||||
&& chmod +x "/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" \
|
&& chmod +x "/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" \
|
||||||
&& ln -snf "/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" /usr/local/bin/start-comanda \
|
&& ln -snf "/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" /usr/local/bin/start-comanda \
|
||||||
&& ln -snf "/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" /usr/local/bin/start-consulta-cda \
|
&& ln -snf "/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" /usr/local/bin/start-consulta-cda \
|
||||||
&& ln -snf "/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" /usr/local/bin/start-pdvconfig \
|
&& ln -snf "/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" /usr/local/bin/start-pdvconfig \
|
||||||
&& ln -snf "/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" /usr/local/bin/start-sigpdv \
|
&& ln -snf "/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" /usr/local/bin/start-sigpdv \
|
||||||
&& ln -snf "/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" /usr/local/bin/start-sigpve
|
&& ln -snf "/srv/sig/${PRODUTO}/${PRODUTO}-wrapper.sh" /usr/local/bin/start-sigpve
|
||||||
ln -snf \
|
|
||||||
/srv/sig/${PRODUTO}/${PRODUTO}/debian/icons/* \
|
ln -snf /srv/sig/${PRODUTO}/${PRODUTO}/debian/icons/* \
|
||||||
/usr/share/pixmaps/
|
/usr/share/pixmaps/
|
||||||
mkdir /usr/local/share/applications/ \
|
mkdir /usr/local/share/applications/ \
|
||||||
&& ln -snf \
|
&& ln -snf \
|
||||||
/srv/sig/${PRODUTO}/${PRODUTO}/debian/desktop-files/* \
|
/srv/sig/${PRODUTO}/${PRODUTO}/debian/desktop-files/* \
|
||||||
/usr/local/share/applications/ \
|
/usr/local/share/applications/ \
|
||||||
&& sed -i 's|/usr/bin|/usr/local/bin|g' /usr/local/share/applications/*.desktop \
|
&& sed -i 's|/usr/bin|/usr/local/bin|g' /usr/local/share/applications/*.desktop \
|
||||||
&& update-desktop-database || :
|
&& update-desktop-database || :
|
||||||
|
|
||||||
|
download "installer/config/${PRODUTO}/${PRODUTO}.sudo" \
|
||||||
|
"/etc/sudoers.d/${PRODUTO}" \
|
||||||
|
&& chown root:root "/etc/sudoers.d/${PRODUTO}" \
|
||||||
|
&& chmod 600 "/etc/sudoers.d/${PRODUTO}"
|
||||||
|
|
||||||
# -- Configuração padrão inicial
|
|
||||||
download "installer/config/${PRODUTO}/pdvconfig.cfg" \
|
download "installer/config/${PRODUTO}/pdvconfig.cfg" \
|
||||||
"/usr/local/sigext/pdvconfig.cfg"
|
"/usr/local/sigext/pdvconfig.cfg"
|
||||||
|
|
||||||
download "installer/config/${PRODUTO}/CliSiTef.ini" \
|
download "installer/config/${PRODUTO}/CliSiTef.ini" \
|
||||||
"/usr/local/sigext/CliSiTef.ini"
|
"/usr/local/sigext/CliSiTef.ini"
|
||||||
for amb in homologacao producao lib_ssl_antiga; do
|
for amb in homologacao producao lib_ssl_antiga; do
|
||||||
ln -snf \
|
ln -snf \
|
||||||
"/usr/local/sigext/CliSiTef.ini" \
|
"/usr/local/sigext/CliSiTef.ini" \
|
||||||
/srv/sig/${PRODUTO}/${PRODUTO}/sigtef/lib_x86_64/${amb}/
|
/srv/sig/${PRODUTO}/sigtef/lib_x86_64/${amb}/
|
||||||
done
|
done
|
||||||
|
|
||||||
# -- Configurações de segurança e dos usuários
|
# PostgreSQL user and database
|
||||||
local _app_user=${PRODUTO}
|
local _password=$(openssl rand -base64 32 | sed 's/\//|/g')
|
||||||
local _app_group=${_app_user}
|
${ui}.status info $"Criando/Atualizando usuário e banco de dados [%s]" ${PRODUTO}
|
||||||
# Acesso do usuário do desktop
|
|
||||||
local _desktop_user=$(getent passwd | sed '/x:1000/!d;s/:.*//g')
|
|
||||||
usermod -aG ${_app_group},pyenv ${_desktop_user}
|
|
||||||
# Configuração do sudo
|
|
||||||
download "installer/config/${PRODUTO}/${PRODUTO}.sudo" \
|
|
||||||
"/etc/sudoers.d/${PRODUTO}" \
|
|
||||||
&& chown root:root "/etc/sudoers.d/${PRODUTO}" \
|
|
||||||
&& chmod 600 "/etc/sudoers.d/${PRODUTO}"
|
|
||||||
# Permissões de usuários e grupos
|
|
||||||
for dir in /srv/sig/${PRODUTO} /usr/local/sigext /recebe; do
|
|
||||||
chown -R ${_app_user}:${_app_group} ${dir}
|
|
||||||
chmod -R g+rw,o-rwx ${dir}
|
|
||||||
done
|
|
||||||
|
|
||||||
# -- Configuração do banco de dados PostgreSQL
|
|
||||||
local _db_name=${PRODUTO}
|
|
||||||
local _db_user=${_db_name}
|
|
||||||
local _db_pass=$(openssl rand -base64 32 | sed 's/[/+-_=]//g')
|
|
||||||
${ui}.status info $"Configurando o banco de dados [%s]" ${_db_name}}
|
|
||||||
sudo -iu postgres \
|
sudo -iu postgres \
|
||||||
psql -c \
|
psql -c \
|
||||||
"CREATE USER ${_db_user} WITH \
|
"CREATE USER ${PRODUTO} WITH \
|
||||||
PASSWORD '${_db_pass}' \
|
PASSWORD '${_password}' \
|
||||||
CREATEDB;" \
|
CREATEDB;" \
|
||||||
|| \
|
|| \
|
||||||
sudo -iu postgres \
|
sudo -iu postgres \
|
||||||
psql -c \
|
psql -c \
|
||||||
"ALTER USER ${_db_user} WITH \
|
"ALTER USER ${PRODUTO} WITH \
|
||||||
PASSWORD '${_db_pass}' \
|
PASSWORD '${_password}' \
|
||||||
CREATEDB;"
|
CREATEDB;"
|
||||||
|
|
||||||
if [[ 0${?} -eq 0 ]]; then
|
if [[ 0${?} -eq 0 ]]; then
|
||||||
sed -i "s/.*db_pdv_pass.*/db_pdv_pass = ${_db_pass}/g" \
|
sed -i "s/.*db_pdv_pass.*/db_pdv_pass = ${_password}/g" \
|
||||||
"/usr/local/sigext/pdvconfig.cfg"
|
"/usr/local/sigext/pdvconfig.cfg"
|
||||||
sudo -i -u postgres createdb -O ${_db_user} ${_db_name} >/dev/null 2>&1 || :
|
sudo -i -u postgres createdb -O ${PRODUTO} ${PRODUTO} >/dev/null 2>&1 || :
|
||||||
${ui}.status warn $"Senha de acesso ao banco de dados: %s" ${_db_pass}
|
${ui}.status warn $"Senha de acesso ao banco de dados: %s" ${_password}
|
||||||
sleep 5
|
sleep 5
|
||||||
fi
|
fi
|
||||||
;;
|
|
||||||
|
|
||||||
|
chown -R ${PRODUTO}: /usr/local/sigext /recebe
|
||||||
|
chmod -R g+rw /usr/local/sigext /recebe
|
||||||
|
# End TODO
|
||||||
|
|
||||||
|
[[ -f "/srv/sig/${PRODUTO}/sigpdv/requirements.txt" ]] && \
|
||||||
|
runuser -l ${PRODUTO} -- \
|
||||||
|
python -m pip install -qq -r /srv/sig/${PRODUTO}/sigpdv/requirements.txt --user \
|
||||||
|
&& rm -f /srv/sig/${PRODUTO}/sigpdv/requirements.txt
|
||||||
|
chown -R ${PRODUTO}: /srv/sig/${PRODUTO}/
|
||||||
|
|
||||||
|
local _user=$(getent passwd | sed '/x:1000/!d;s/:.*//g')
|
||||||
|
usermod -aG ${PRODUTO} ${_user}
|
||||||
|
;;
|
||||||
sigvpn)
|
sigvpn)
|
||||||
${ui}.status warn $"Não implementado."
|
${ui}.status warn $"Não implementado."
|
||||||
# rm -f /etc/apt/trusted.gpg.d/openvpn*.gpg
|
# rm -f /etc/apt/trusted.gpg.d/openvpn*.gpg
|
||||||
@@ -821,7 +814,7 @@ function produto.install {
|
|||||||
#system.remove_pkgs ${BUILD_PACKAGES}
|
#system.remove_pkgs ${BUILD_PACKAGES}
|
||||||
|
|
||||||
${ui}.color none
|
${ui}.color none
|
||||||
${ui}.status info $"Instalação concluída. REINICIE o computador."
|
${ui}.status info $"Instalação concluída. Reinicie o computador."
|
||||||
${ui}.prompt $"Pressione ENTER para continuar ... "
|
${ui}.prompt $"Pressione ENTER para continuar ... "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1206
sig-installer-dev
1206
sig-installer-dev
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user