update install.sh
This commit is contained in:
parent
e31761a54c
commit
5c764e650c
58
install.sh
58
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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user