aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesus <heckyel@hyperbola.info>2025-05-18 19:35:56 -0500
committerJesus <heckyel@hyperbola.info>2025-05-18 19:35:56 -0500
commit5c764e650ce5f1c652abc63dd196637bd77d81bd (patch)
treeac80c91a0e54a935eb809a5faed22b42b2ae60c9
parente31761a54ce72d9bda4c7d32ce92b064bb7ab1c5 (diff)
downloadhyperterm-5c764e650ce5f1c652abc63dd196637bd77d81bd.tar.lz
hyperterm-5c764e650ce5f1c652abc63dd196637bd77d81bd.tar.xz
hyperterm-5c764e650ce5f1c652abc63dd196637bd77d81bd.zip
update install.sh
-rw-r--r--install.sh58
1 files changed, 35 insertions, 23 deletions
diff --git a/install.sh b/install.sh
index 8944b32..139ec68 100644
--- a/install.sh
+++ b/install.sh
@@ -32,9 +32,9 @@ function msg_err() {
function install_package() {
local pkg="$1"
local sudo_cmd=""
- local distro=""
- local os_data
+ local OS_ID=""
+ # Determine if root or use sudo/doas
case "$(id -u)" in
0) sudo_cmd="" ;;
*)
@@ -45,37 +45,49 @@ function install_package() {
;;
esac
- os_data="$(cat /etc/*release 2>/dev/null | tr '[:upper:]' '[:lower:]')"
+ # Get OS ID (e.g., arch, debian, ubuntu, fedora, alpine, etc.)
+ OS_ID=$(
+ cat /etc/*release 2>/dev/null |
+ tr '[:upper:]' '[:lower:]' |
+ grep "^id=" | head -n1 | cut -d= -f2 | tr -d '"'
+ )
- case "$os_data" in
- *id=artix*|*id=arch*|*id=hyperbola*) distro="arch" ;;
- *id_like=arch*) distro="arch" ;;
- *id=debian*|*id=ubuntu*|*id_like=debian*) distro="debian" ;;
- *)
- msg_err "Sistema operativo no soportado automáticamente." \
- "Operating system not automatically supported."
- exit 1
- ;;
- esac
-
- case "$distro" in
- arch)
+ case "$OS_ID" in
+ arch|manjaro|endeavouros|hyperbola|artix)
$sudo_cmd pacman -Sy --noconfirm "$pkg"
;;
- debian)
- $sudo_cmd apt-get update
- $sudo_cmd apt-get install -y "$pkg"
+ debian|ubuntu|linuxmint|pop|pop_os)
+ $sudo_cmd apt update
+ $sudo_cmd apt install -y "$pkg"
+ ;;
+ fedora|rhel|centos)
+ $sudo_cmd dnf install -y "$pkg"
+ ;;
+ opensuse*|suse)
+ $sudo_cmd zypper --non-interactive install "$pkg"
+ ;;
+ alpine)
+ $sudo_cmd apk add --no-cache "$pkg"
+ ;;
+ *)
+ msg_err "Sistema operativo no soportado: $OS_ID" "Unsupported OS: $OS_ID"
+ exit 1
;;
esac
}
-programs=("curl" "less" "ls" "netstat" "unzip")
+programs=("curl" "less" "ls" "iproute2" "unzip")
for program in "${programs[@]}"; do
if ! command -v "$program" &>/dev/null; then
case "$program" in
- netstat) pkg="net-tools" ;;
- ls) pkg="coreutils" ;;
- *) pkg="$program" ;;
+ ls) pkg="coreutils" ;;
+ iproute2)
+ case "$OS_ID" in
+ fedora|rhel|centos) pkg="iproute" ;;
+ *) pkg="iproute2" ;;
+ esac
+ ;;
+ *) pkg="$program" ;;
esac
msg "Instalando dependencia: $pkg" "Installing dependency: $pkg"
install_package "$pkg"