pass env vars, shellcheck directives
This commit is contained in:
parent
59ae712215
commit
cfb694761f
5 changed files with 23 additions and 23 deletions
25
01-utils.sh
25
01-utils.sh
|
@ -7,6 +7,8 @@ echo_debug() { # DEBUG
|
|||
} # DEBUG
|
||||
|
||||
urlencode() {
|
||||
# This is a false positive
|
||||
# shellcheck disable=SC1083
|
||||
ENCODEDURL="$(curl -Gs -w %{url_effective} --data-urlencode @- ./ ||: )"
|
||||
printf '%s' "$ENCODEDURL" | sed 's/%0[aA]$//;s/^.*[?]//'
|
||||
}
|
||||
|
@ -43,6 +45,8 @@ get_archive() {
|
|||
}
|
||||
|
||||
set_version() {
|
||||
# This is a shellcheck limitation
|
||||
# shellcheck disable=SC1090
|
||||
for os in /etc/os-release /usr/lib/os-release; do
|
||||
[ -f $os ] && . $os && break
|
||||
done
|
||||
|
@ -72,25 +76,6 @@ set_version() {
|
|||
esac
|
||||
}
|
||||
|
||||
firmador_libre() {
|
||||
FIRMADOR="https://firmador.libre.cr/firmador.jar"
|
||||
DIR="$HOME/.local/share/firmador"
|
||||
[ "$ID" = "macos" ] && DIR="$HOME/.local/share/firmador"
|
||||
|
||||
mkdir -p "$DIR"
|
||||
(cd "$DIR" && curl -O "$FIRMADOR")
|
||||
FIRMADOR="$DIR/firmador.jar"
|
||||
|
||||
printf '[Desktop Entry]
|
||||
Name=Firmador
|
||||
Comment=Herramienta para firmar documentos
|
||||
Category=Utility
|
||||
Exec=java -jar %s
|
||||
Icon=%s/.local/share/firmador/firmador.png
|
||||
Terminal=false
|
||||
Type=Application' "$FIRMADOR" "$HOME" > ~/.local/share/applications/firmador.desktop
|
||||
}
|
||||
|
||||
set_menu() {
|
||||
if [ -z "$MENU" ] ; then
|
||||
command -v zenity > /dev/null && MENU="zenity" && return 0
|
||||
|
@ -118,6 +103,8 @@ if [ "$MENU" = "zenity" ] ; then
|
|||
zenity --title "$TITLE" --password
|
||||
|
||||
elif [ "$MENU" = "term" ] ; then
|
||||
# nil (or whatever variable) must be set for portability
|
||||
# shellcheck disable=SC2034
|
||||
[ "$MODE" = "info" ] &&
|
||||
printf '\n\033[1m\033[34m=== %s ===\033[0m\n%s ENTER' "$TITLE" "$PROMPT" >/dev/stdin &&
|
||||
read -r nil
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/bin/sh
|
||||
# False positive
|
||||
# shellcheck disable=SC2034
|
||||
|
||||
set_lang() {
|
||||
# See: /var/lib/AccountsService/users/
|
||||
|
|
|
@ -25,6 +25,8 @@ PACKAGE="${PACKAGE##*/}"
|
|||
tsudo cp -p "$PACKAGE_DIR"/usr/lib/x64-athena/libASEP11.so /usr/lib/x86_64-linux-gnu/
|
||||
|
||||
echo_debug "Symlinks y componentes..." # DEBUG
|
||||
# This must not be expanded
|
||||
# shellcheck disable=SC2016
|
||||
tsudo sh -c '
|
||||
# --- Certificados ---
|
||||
for file in /usr/local/share/ca-certificates/*.crt ; do openssl x509 -inform DER -in "$file" -out "$file.tmp" 2> /dev/null ; done
|
||||
|
|
15
04-main.sh
15
04-main.sh
|
@ -16,7 +16,8 @@ if ! command -v curl > /dev/null ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
SERIAL="$(menu entry "$PROMPT_SERIAL")"
|
||||
SERIAL="${SERIAL:=$(menu entry "$PROMPT_SERIAL")}"
|
||||
|
||||
if [ -z "$SERIAL" ] ; then
|
||||
menu error "$PROMPT_ERR_SERIAL"
|
||||
exit 1
|
||||
|
@ -61,9 +62,12 @@ elif [ "$MENU" = "term" ] ; then
|
|||
|
||||
fi
|
||||
|
||||
# This way is better in this case
|
||||
# shellcheck disable=SC2009
|
||||
ACTIVE="$(ps -t | grep 'curl.*soportefirmadigital' | sed '/grep/d')"
|
||||
ACTIVE="${ACTIVE# }"
|
||||
ACTIVEID="${ACTIVE%% *}"
|
||||
|
||||
if [ -n "$ACTIVE" ] ; then
|
||||
menu error "$PROMPT_ERR_DOWNLOAD"
|
||||
echo_debug "Killing process ID: $ACTIVEID from: $ACTIVE" # DEBUG
|
||||
|
@ -71,7 +75,8 @@ if [ -n "$ACTIVE" ] ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
SUDO_PASSWORD="$(menu pass "$PROMPT_PASS_DEPS_INSTALL")"
|
||||
SUDO_PASSWORD="${SUDO_PASSWORD:=$(menu pass "$PROMPT_PASS_DEPS_INSTALL")}"
|
||||
|
||||
if [ -z "$SUDO_PASSWORD" ] || ! tsudo whoami >/dev/null 2>&1 ; then
|
||||
menu error "$PROMPT_ERR_DEPS_INSTALL"
|
||||
exit 1
|
||||
|
@ -84,15 +89,19 @@ if [ "$MENU" = "zenity" ] ; then
|
|||
zenity --title "$TITLE" --text "$PROMPT_DEPS_INSTALL" --progress --pulsate --auto-close >&4) 3>&1 ) |
|
||||
(read -r xs; exit "$xs") ) 4>&1
|
||||
#install_certs # Just run this instead to see debug info # DEBUG
|
||||
# Ignore as this is needed for this "workaround"
|
||||
# shellcheck disable=SC2181
|
||||
if [ "$?" != "0" ] ; then
|
||||
menu error "$PROMPT_ERR_DEPS_INSTALL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
elif [ "$MENU" = "term" ] ; then
|
||||
menu info "$PROMPT_DEPS_INSTALL" && echo
|
||||
! install_certs && menu error "$PROMPT_ERR_DEPS_INSTALL" && exit 1
|
||||
|
||||
fi
|
||||
|
||||
menu info "$PROMPT_END_SUCCESS"
|
||||
menu info "$PROMPT_END_SUCCESS\n"
|
||||
|
||||
exit 0
|
||||
|
|
2
Makefile
2
Makefile
|
@ -4,7 +4,7 @@ all: $(SCRIPT)
|
|||
|
||||
$(SCRIPT): $(wildcard [0-9][0-9]-*.sh)
|
||||
printf '#!/bin/sh\n' > $@
|
||||
for i in $? ; do cat $$i ; done | sed '/^ *#.*$$/d;/.*# *DEBUG/d' >> $@
|
||||
for i in $? ; do cat $$i ; done | sed '/^ *# shellcheck/! s/^ *#.*$$//g;/.*# *DEBUG/d' >> $@
|
||||
|
||||
debug: $(wildcard [0-9][0-9]-*.sh)
|
||||
printf '#!/bin/sh\n' > $@-$(SCRIPT)
|
||||
|
|
Loading…
Reference in a new issue