diff options
author | Jesus <heckyel@hyperbola.info> | 2025-05-18 19:35:56 -0500 |
---|---|---|
committer | Jesus <heckyel@hyperbola.info> | 2025-05-18 19:35:56 -0500 |
commit | 5c764e650ce5f1c652abc63dd196637bd77d81bd (patch) | |
tree | ac80c91a0e54a935eb809a5faed22b42b2ae60c9 | |
parent | e31761a54ce72d9bda4c7d32ce92b064bb7ab1c5 (diff) | |
download | hyperterm-5c764e650ce5f1c652abc63dd196637bd77d81bd.tar.lz hyperterm-5c764e650ce5f1c652abc63dd196637bd77d81bd.tar.xz hyperterm-5c764e650ce5f1c652abc63dd196637bd77d81bd.zip |
update install.sh
-rw-r--r-- | install.sh | 58 |
1 files changed, 35 insertions, 23 deletions
@@ -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" |