fix term prompt
This commit is contained in:
parent
5eac1b3352
commit
c15c4095b3
3 changed files with 22 additions and 22 deletions
|
@ -1,5 +1,11 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
alias tsudo='printf "%s" "$SUDO_PASSWORD" | sudo -Skp ""'
|
||||||
|
|
||||||
|
echo_debug() { # DEBUG
|
||||||
|
printf '\033[1mDEBUG:\033[0m \033[2m%s...\033[0m\n' "$1" # DEBUG
|
||||||
|
} # DEBUG
|
||||||
|
|
||||||
urlencode() {
|
urlencode() {
|
||||||
ENCODEDURL="$(curl -Gs -w %{url_effective} --data-urlencode @- ./ ||: )"
|
ENCODEDURL="$(curl -Gs -w %{url_effective} --data-urlencode @- ./ ||: )"
|
||||||
printf '%s' "$ENCODEDURL" | sed 's/%0[aA]$//;s/^.*[?]//'
|
printf '%s' "$ENCODEDURL" | sed 's/%0[aA]$//;s/^.*[?]//'
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# TODO:
|
# TODO:
|
||||||
# - Check all variables to avoid root execution on unspecified places
|
# - Check all variables to avoid root execution on unspecified places
|
||||||
echo_debug() { # DEBUG
|
|
||||||
printf '\033[1mDEBUG:\033[0m \033[2m%s...\033[0m\n' "$1" # DEBUG
|
|
||||||
} # DEBUG
|
|
||||||
|
|
||||||
alias tsudo='printf "%s" "$SUDO_PASSWORD" | sudo -Skp ""'
|
|
||||||
|
|
||||||
debian_install_certs() {
|
debian_install_certs() {
|
||||||
# Source: https://fran.cr/instalar-firma-digital-costa-rica-gnu-linux-ubuntu-debian/
|
# Source: https://fran.cr/instalar-firma-digital-costa-rica-gnu-linux-ubuntu-debian/
|
||||||
|
|
31
04-main.sh
31
04-main.sh
|
@ -67,42 +67,41 @@ if [ "$MENU" = "zenity" ] ; then
|
||||||
echo_debug "Termina correctamente" # DEBUG
|
echo_debug "Termina correctamente" # DEBUG
|
||||||
zenity --title "$TITLE" --text "$PROMPT_END_SUCCESS" --info
|
zenity --title "$TITLE" --text "$PROMPT_END_SUCCESS" --info
|
||||||
|
|
||||||
else
|
elif [ "$MENU" = "term" ] ; then
|
||||||
MENU="term"
|
term_prompt info "$PROMPT_WELCOME" && read -r NULL
|
||||||
term_prompt "$TITLE" "$PROMPT_WELCOME" info && read -r NULL
|
! command -v curl && term_prompt error "$TITLE" "$PROMPT_ERR_DEPS curl" && exit 1
|
||||||
! command -v curl && term_prompt "$TITLE" "$PROMPT_ERR_DEPS curl" error && exit 1
|
|
||||||
|
|
||||||
# Serial number is required for download
|
# Serial number is required for download
|
||||||
term_prompt "$TITLE" "$PROMPT_SERIAL" entry && read -r SERIAL
|
term_prompt entry "$PROMPT_SERIAL" && read -r SERIAL
|
||||||
[ -z "$SERIAL" ] && term_prompt "$TITLE" "$PROMPT_ERR_SERIAL" error && exit 1
|
[ -z "$SERIAL" ] && term_prompt error "$TITLE" "$PROMPT_ERR_SERIAL" && exit 1
|
||||||
|
|
||||||
echo_debug "Generar tempkey y obtener URL de descarga" # DEBUG
|
echo_debug "Generar tempkey y obtener URL de descarga" # DEBUG
|
||||||
ARCHIVE="$(get_archive)"
|
ARCHIVE="$(get_archive)"
|
||||||
TEMPKEY="${ARCHIVE##* }"
|
TEMPKEY="${ARCHIVE##* }"
|
||||||
FILE="${ARCHIVE%% *}"
|
FILE="${ARCHIVE%% *}"
|
||||||
DOWNLOAD_URL="$(printf 'https://soportefirmadigital.com/sfdj/getiso.aspx?tempkey=%s' "$TEMPKEY")"
|
DOWNLOAD_URL="$(printf 'https://soportefirmadigital.com/sfdj/getiso.aspx?tempkey=%s' "$TEMPKEY")"
|
||||||
[ -z "$DOWNLOAD_URL" ] && term_prompt "$TITLE" "$PROMPT_ERR_DOWNLOAD" error && exit 1
|
[ -z "$DOWNLOAD_URL" ] && term_prompt error "$PROMPT_ERR_DOWNLOAD" && exit 1
|
||||||
[ -z "$FILE" ] && term_prompt "$TITLE" "$PROMPT_ERR_DOWNLOAD" error && exit 1
|
[ -z "$FILE" ] && term_prompt error "$PROMPT_ERR_DOWNLOAD" && exit 1
|
||||||
SAVE_DIR="/tmp/soportefirmadigital"
|
SAVE_DIR="/tmp/soportefirmadigital"
|
||||||
SAVE_FILE="$SAVE_DIR/$FILE"
|
SAVE_FILE="$SAVE_DIR/$FILE"
|
||||||
mkdir -p "$SAVE_DIR"
|
mkdir -p "$SAVE_DIR"
|
||||||
SIZE="$(curl -sI "$DOWNLOAD_URL" | sed '/[Cc]ontent-[Ll]ength/!d;s/^.*: //g' | awk '{$1/=1024;printf "%d",$1}')"
|
SIZE="$(curl -sI "$DOWNLOAD_URL" | sed '/[Cc]ontent-[Ll]ength/!d;s/^.*: //g' | awk '{$1/=1024;printf "%d",$1}')"
|
||||||
|
|
||||||
term_prompt "$TITLE" "$PROMPT_DOWNLOAD" info && echo
|
term_prompt info "$PROMPT_DOWNLOAD" && echo
|
||||||
curl "$DOWNLOAD_URL" -o "$SAVE_FILE" --progress-bar
|
curl "$DOWNLOAD_URL" -o "$SAVE_FILE" --progress-bar
|
||||||
|
|
||||||
echo_debug "Consultar sudo pass" # DEBUG
|
echo_debug "Consultar sudo pass" # DEBUG
|
||||||
term_prompt "$TITLE" "$PROMPT_SUDO_PASSWORD" entry && IFS= read -r SUDO_PASSWORD
|
term_prompt entry "$PROMPT_SUDO_PASSWORD" && IFS= read -r SUDO_PASSWORD
|
||||||
[ -z "$SUDO_PASSWORD" ] && term_prompt "$TITLE" "$PROMPT_ERR_DEPS_INSTALL" error && exit 1
|
[ -z "$SUDO_PASSWORD" ] && term_prompt error "$PROMPT_ERR_DEPS_INSTALL" && exit 1
|
||||||
CORRECT_SUDO_PASSWORD="$(printf '%s' "$SUDO_PASSWORD" | sudo -Skp '' whoami >/dev/null 2>&1 || printf 'no')"
|
CORRECT_SUDO_PASSWORD="$(tsudo whoami >/dev/null 2>&1 || printf 'no')"
|
||||||
[ "$CORRECT_SUDO_PASSWORD" = "no" ] && term_prompt "$TITLE" "$PROMPT_ERR_DEPS_INSTALL" error && exit 1
|
[ "$CORRECT_SUDO_PASSWORD" = "no" ] && term_prompt error "$PROMPT_ERR_DEPS_INSTALL" && exit 1
|
||||||
|
|
||||||
# Install dependencies, components and
|
# Install dependencies, components and
|
||||||
# certificates according to OS
|
# certificates according to OS
|
||||||
term_prompt "$TITLE" "$PROMPT_DEPS_INSTALL" info && echo
|
term_prompt info "$PROMPT_DEPS_INSTALL" && echo
|
||||||
install_certs "$SAVE_FILE"
|
install_certs "$SAVE_FILE"
|
||||||
[ "$?" != "0" ] && term_prompt "$TITLE" "$PROMPT_ERR_DEPS_INSTALL" error && exit 1
|
[ "$?" != "0" ] && term_prompt error "$PROMPT_ERR_DEPS_INSTALL" && exit 1
|
||||||
|
|
||||||
term_prompt "$TITLE" "$PROMPT_END_SUCCESS" info && echo
|
term_prompt info "$PROMPT_END_SUCCESS" && echo
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue