Add autodep.sh
All checks were successful
CI Pipeline / shasums (push) Successful in 31s
git-sync-with-mirror / git-sync (push) Successful in 43s
CI Pipeline / build (push) Successful in 4m24s

This commit is contained in:
Jesus 2025-05-18 20:09:31 -05:00
parent d5e477f13d
commit c98c789f32
Signed by: heckyel
GPG Key ID: 531E723EED721D7C
5 changed files with 122 additions and 47 deletions

63
hyperterm/core/autodep.sh Normal file
View File

@ -0,0 +1,63 @@
#!/bin/bash
function install_package() {
local pkg="$1"
if command -v "$pkg" &>/dev/null; then
return 0
fi
msg "El paquete $pkg no se encontró. Procediendo a instalar..." \
"$pkg not found. Attempting to install..."
local INSTALLER=""
local SUDO=""
local USER_CMD=$(command -v sudo || command -v doas)
[[ "$(id -u)" -ne 0 ]] && SUDO="$USER_CMD"
local OS_ID=""
if [ -f /etc/os-release ]; then
OS_ID=$(grep "^ID=" /etc/os-release | head -n1 | cut -d= -f2 | tr -d '"')
OS_ID=${OS_ID,,}
fi
case "$OS_ID" in
arch|manjaro|artix|hyperbola)
INSTALLER="pacman -Sy --noconfirm $pkg"
;;
debian|ubuntu|linuxmint|elementary|pop)
INSTALLER="apt-get update && apt-get install -y $pkg"
;;
fedora)
INSTALLER="dnf install -y $pkg"
;;
void)
INSTALLER="xbps-install -Sy $pkg"
;;
gentoo)
INSTALLER="emerge app-arch/$pkg"
;;
alpine)
INSTALLER="apk add $pkg"
;;
*)
msg_err "Distro no compatible con la instalación automática de $pkg." \
"Unsupported distro for automatic $pkg installation."
return 1
;;
esac
msg "Ejecutando instalación con: $SUDO $INSTALLER" \
"Running install command: $SUDO $INSTALLER"
$SUDO bash -c "$INSTALLER"
if command -v "$pkg" &>/dev/null; then
return 0
else
msg_err "Falló al instalar: $pkg" \
"Failed to install $pkg."
return 1
fi
}

View File

@ -106,7 +106,7 @@ function updbashrc() {
sleep 1 sleep 1
# Step 3: Core files # Step 3: Core files
for f in autocomplete.sh colors.sh git.sh languages.sh status.sh update.sh; do for f in autocomplete.sh autodep.sh colors.sh git.sh languages.sh status.sh update.sh; do
download_file "hyperterm/core/$f" "$HOME/.hyperterm/core/$f" download_file "hyperterm/core/$f" "$HOME/.hyperterm/core/$f"
done done

View File

@ -34,10 +34,11 @@ if [[ -f $HOME/.hyperterm/tools/aliases.sh ]]; then source "$HOME/.hyperterm/too
# bash_functions # bash_functions
#---------------- #----------------
# [ core ] # [ core ]
if [[ -f $HOME/.hyperterm/core/languages.sh ]]; then source "$HOME/.hyperterm/core/languages.sh"; else true; fi
if [[ -f $HOME/.hyperterm/core/autodep.sh ]]; then source "$HOME/.hyperterm/core/autodep.sh"; else true; fi
if [[ -f $HOME/.hyperterm/core/autocomplete.sh ]]; then source "$HOME/.hyperterm/core/autocomplete.sh"; else true; fi if [[ -f $HOME/.hyperterm/core/autocomplete.sh ]]; then source "$HOME/.hyperterm/core/autocomplete.sh"; else true; fi
if [[ -f $HOME/.hyperterm/core/colors.sh ]]; then source "$HOME/.hyperterm/core/colors.sh"; else true; fi if [[ -f $HOME/.hyperterm/core/colors.sh ]]; then source "$HOME/.hyperterm/core/colors.sh"; else true; fi
if [[ -f $HOME/.hyperterm/core/git.sh ]]; then source "$HOME/.hyperterm/core/git.sh"; else true; fi if [[ -f $HOME/.hyperterm/core/git.sh ]]; then source "$HOME/.hyperterm/core/git.sh"; else true; fi
if [[ -f $HOME/.hyperterm/core/languages.sh ]]; then source "$HOME/.hyperterm/core/languages.sh"; else true; fi
if [[ -f $HOME/.hyperterm/core/status.sh ]]; then source "$HOME/.hyperterm/core/status.sh"; else true; fi if [[ -f $HOME/.hyperterm/core/status.sh ]]; then source "$HOME/.hyperterm/core/status.sh"; else true; fi
if [[ -f $HOME/.hyperterm/core/update.sh ]]; then source "$HOME/.hyperterm/core/update.sh"; else true; fi if [[ -f $HOME/.hyperterm/core/update.sh ]]; then source "$HOME/.hyperterm/core/update.sh"; else true; fi

View File

@ -1,11 +1,12 @@
cdfe049ec07f02a1893cda29c13085d06709e09a30b0c2e1111585278315f03139d61080c883cb3fd87f2bf64e05d9b5e5eaaad84c97ced890d83c73eb399fcb ../.bash_profile cdfe049ec07f02a1893cda29c13085d06709e09a30b0c2e1111585278315f03139d61080c883cb3fd87f2bf64e05d9b5e5eaaad84c97ced890d83c73eb399fcb ../.bash_profile
57bf0f09423414323ada7c518e2865db8651aa1b239fb5d89d3eb0687d4c3f5d8fe66fe48c6988ff50db0f54f67edfd36c4ea3193fe909c2349eee4a3efcdaa6 ./core/update.sh d8aee7e20496df3fc31a903a85d086acddbe9c618b88cf5bd22a2c052593a058d956d50e9c6c27eeac3be8899f3cfac13050b43bba9fb4c8f0656d509c7decc3 ./core/update.sh
1cfba599047d84a17ff92b695ebf527a505a30acc9ec21a2b9f410a7ea6dde4b23b5cf62e557d82f2fe9a8980649942424b879ca53baae4d4cb3057681baa7b6 ./core/colors.sh 1cfba599047d84a17ff92b695ebf527a505a30acc9ec21a2b9f410a7ea6dde4b23b5cf62e557d82f2fe9a8980649942424b879ca53baae4d4cb3057681baa7b6 ./core/colors.sh
065cfa39f1b4312ed275ad1039827a24f703176c653a8d27303d145f9d389a60ec5b3a9eb167e060cc6fd093b9c03cfb1a8b70254d444fbc6e62e2297d88b310 ./core/status.sh 065cfa39f1b4312ed275ad1039827a24f703176c653a8d27303d145f9d389a60ec5b3a9eb167e060cc6fd093b9c03cfb1a8b70254d444fbc6e62e2297d88b310 ./core/status.sh
2036a79215a5434e31f3406bea3f2ffa7e94ffef86c2d1ceb8865db29f19fe7f342f9cab93288f57c75daed36ef146f85d15f8d633931a27d55c3983f55ef15b ./core/git.sh 2036a79215a5434e31f3406bea3f2ffa7e94ffef86c2d1ceb8865db29f19fe7f342f9cab93288f57c75daed36ef146f85d15f8d633931a27d55c3983f55ef15b ./core/git.sh
55b23b0311ba3c3061084bcacf4ae7d679a3e3653270def15014fef173d5c930ee2b4378e61b9e67b369ff8c08624e592b2bd87271a00be8fb16ee05cdd6dc3f ./core/autodep.sh
7447d3e167ab207d3ef4218e201a06bf5a3fc23281639f16f7f405f1d66b73923845d450fdb0a94672757866a9da0324f728564a1b61b2ed1678fe576eb565cf ./core/autocomplete.sh 7447d3e167ab207d3ef4218e201a06bf5a3fc23281639f16f7f405f1d66b73923845d450fdb0a94672757866a9da0324f728564a1b61b2ed1678fe576eb565cf ./core/autocomplete.sh
f3e00b2aa8ab9f3ab44570adaa2520408ed66fd00f551654d60b64a4be3546ec781b7efa39bcd774937e654b6ffb4c7af3f21eeb36caf9c01f82f85cf28e2b4d ./core/languages.sh f3e00b2aa8ab9f3ab44570adaa2520408ed66fd00f551654d60b64a4be3546ec781b7efa39bcd774937e654b6ffb4c7af3f21eeb36caf9c01f82f85cf28e2b4d ./core/languages.sh
b846a929844e74fc76ce65d2bd7aefcdeb03e058d9ce68a7f3f6bce6080a843d90eae78cecc2faac0c5b066a739a8328dfcd042cd25cb5aaa856e956a0c4d0c2 ./tools/rar2zip.sh fd5f163c7503cb65daf095f0352e67541aecfbf5ed14ca4b74605a3e158b8d54d7f1a20079471245fe462dd7408b11b0027c9c2c25a961418d8f51b4006bf566 ./tools/rar2zip.sh
73becd983f15d68b3c459adb4fe847bbbd6343519640aa5e03bb530e61a59ed0545dd3b3621ad82da378bbf15c4d9ee63984004d3bfed26d9d9df643f1524de5 ./tools/proxy.sh 73becd983f15d68b3c459adb4fe847bbbd6343519640aa5e03bb530e61a59ed0545dd3b3621ad82da378bbf15c4d9ee63984004d3bfed26d9d9df643f1524de5 ./tools/proxy.sh
0b9671c851278cd6a5484ab95b62606b0b925f9606f4de400c5e15a66e35e86bb6bb15e4e1b599ca819c230604bce0ca755d599ec9cd59a14b41f352ef897997 ./tools/aliases.sh 0b9671c851278cd6a5484ab95b62606b0b925f9606f4de400c5e15a66e35e86bb6bb15e4e1b599ca819c230604bce0ca755d599ec9cd59a14b41f352ef897997 ./tools/aliases.sh
fab9d339a99c7d2e1809d1c44f533523c6bfcdcc8d63c62b335ce7d4c666c8bdd7ac319316bf71f043163a3a0184e25ecfe1ee32724627424d042a05fa80ce77 ./tools/vconverter.sh fab9d339a99c7d2e1809d1c44f533523c6bfcdcc8d63c62b335ce7d4c666c8bdd7ac319316bf71f043163a3a0184e25ecfe1ee32724627424d042a05fa80ce77 ./tools/vconverter.sh
@ -24,4 +25,4 @@ f760432c3d76befad30588299eb2d1412d77b22fd850ffbd840c72123885d4e916a7e0b16e7048c5
074e8549d638dee7470583c04ebbb7408181974806bd5e2cf5fc134ddee83c01040ed9d59a8aa00a87287b25df1c2e23edf3c063426952a8aeb56db8310ef8fd ./themes/joy.sh 074e8549d638dee7470583c04ebbb7408181974806bd5e2cf5fc134ddee83c01040ed9d59a8aa00a87287b25df1c2e23edf3c063426952a8aeb56db8310ef8fd ./themes/joy.sh
07bb7b6bd609e855d0a7c9e39a0ff2959851f559106e8f59816312f298b03e87f39e53430869ed61a1271e265e976ea6b56f7ccee46c4ec3c37b40f1fc11cfad ./themes/default.sh 07bb7b6bd609e855d0a7c9e39a0ff2959851f559106e8f59816312f298b03e87f39e53430869ed61a1271e265e976ea6b56f7ccee46c4ec3c37b40f1fc11cfad ./themes/default.sh
c6c149704883ce5cbbd941019259effb105dd6910c98910782024311b3362df2e68d03c947908d40686c2620c1521aeee2ffb019a906ad367be1cc3d429ecd82 ./themes/minterm.sh c6c149704883ce5cbbd941019259effb105dd6910c98910782024311b3362df2e68d03c947908d40686c2620c1521aeee2ffb019a906ad367be1cc3d429ecd82 ./themes/minterm.sh
04ab2fefad0680b22001f241e2ce772d07eadef206bd09208627d9dc1b4366d190374d439930215db5f5a742f9fe0bba8fcbaf34164a9332ad7e132c70ba9f92 ./hyperterm.sh 33e0f862f72b0269de38545d2d41fcd7372f285841d0429614b7b206bc5ad5e8a51a4bdbf44e41c117e6ff642d8cc1521e8525bbb08c0d03a3ba69c6c978dbf8 ./hyperterm.sh

View File

@ -7,51 +7,50 @@
function check_and_install_7z() { function check_and_install_7z() {
if command -v 7z &>/dev/null; then if command -v 7z &>/dev/null; then
return return 0
fi fi
echo "7z not found. Attempting to install..." install_package p7zip
}
INSTALLER="" function check_and_install_unar_unrar() {
SUDO="" local unar_missing=0
USER_CMD=$(command -v sudo || command -v doas) local unrar_missing=0
[[ "$(id -u)" -ne 0 ]] && SUDO="$USER_CMD" command -v unar &>/dev/null || unar_missing=1
command -v unrar &>/dev/null || unrar_missing=1
OS_ID=$( case "$unar_missing$unrar_missing" in
cat /etc/*release 2>/dev/null | 00)
tr '[:upper:]' '[:lower:]' | # both installed
grep "^id=" | head -n1 | cut -d= -f2 | tr -d '"' return 0
)
case "$OS_ID" in
arch|manjaro|artix|hyperbola)
INSTALLER="pacman -Sy --noconfirm p7zip"
;; ;;
debian|ubuntu|linuxmint|elementary|pop) 10)
INSTALLER="apt-get update && apt-get install -y p7zip-full" # unar installed, unrar missing
install_package unrar && return 0
;; ;;
fedora) 01)
INSTALLER="dnf install -y p7zip p7zip-plugins" # unrar installed, unar missing
install_package unar && return 0
;; ;;
void) 11)
INSTALLER="xbps-install -Sy p7zip" # both missing, try unar first, then unrar
;; install_package unar && return 0
gentoo) install_package unrar && return 0
INSTALLER="emerge app-arch/p7zip" echo "Error: could not install either unar or unrar."
;;
alpine)
INSTALLER="apk add p7zip"
;;
*)
echo "Unsupported distro. Cannot install 7z automatically."
return 1 return 1
;; ;;
esac esac
}
if [ -n "$INSTALLER" ]; then function extract_rar() {
echo "Installing 7z using: $SUDO $INSTALLER" if command -v unar &>/dev/null; then
$SUDO bash -c "$INSTALLER" unar "$1" -o "$2"
elif command -v unrar &>/dev/null; then
unrar x -o+ "$1" "$2"
else
echo "Error: neither unar nor unrar available to extract $1"
return 1
fi fi
} }
@ -61,34 +60,45 @@ function rar2zip() {
exit 1 exit 1
} }
check_and_install_unar_unrar || {
echo "Failed to install unar or unrar. Aborting."
exit 1
}
echo "Converting RAR files to ZIP..." echo "Converting RAR files to ZIP..."
WORKDIR="/dev/shm/" WORKDIR="/dev/shm"
for INFILE in "$@"; do for INFILE in "$@"; do
OLDFILE=$(realpath "${INFILE}") OLDFILE=$(realpath "$INFILE")
BASENAME=$(basename "${OLDFILE%.*}") BASENAME=$(basename "${OLDFILE%.*}")
DIRNAME=$(dirname "$OLDFILE") DIRNAME=$(dirname "$OLDFILE")
NEWNAME="${DIRNAME}/$BASENAME.zip" NEWNAME="${DIRNAME}/${BASENAME}.zip"
if [ ! -e "${NEWNAME}" ]; then if [ ! -e "$NEWNAME" ]; then
TEMPDIR=$(mktemp -p "$WORKDIR" -d) TEMPDIR=$(mktemp -p "$WORKDIR" -d)
echo "Extracting $OLDFILE" echo "Extracting $OLDFILE"
unar "$OLDFILE" -o "${TEMPDIR}/" extract_rar "$OLDFILE" "$TEMPDIR/" || {
echo "Extraction failed for $OLDFILE"
rm -rf "$TEMPDIR"
continue
}
7z a -tzip -mx=9 "$NEWNAME" "${TEMPDIR}/*" 7z a -tzip -mx=9 "$NEWNAME" "${TEMPDIR}/*"
touch -r "$OLDFILE" "$NEWNAME" touch -r "$OLDFILE" "$NEWNAME"
rm -r "$TEMPDIR" rm -rf "$TEMPDIR"
gio trash "$OLDFILE" gio trash "$OLDFILE" 2>/dev/null || rm -f "$OLDFILE"
echo "${OLDFILE}: Original file moved to trash" echo "$OLDFILE: Original file moved to trash"
else else
echo "${NEWNAME}: File already exists!" echo "$NEWNAME: File already exists!"
fi fi
done done
echo "Conversion complete." echo "Conversion complete."
} }
rar2zip "$@"