refactor: update dependencies installation script

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-01-26 13:55:48 -03:00
parent 1c39e743d4
commit 3a7eb3729c

View file

@ -1,140 +1,133 @@
#!/bin/bash #!/bin/bash
# #
# DEPENDENCIES.sh - Runtime Dependencies for General Bots # DEPENDENCIES.sh - Runtime Dependencies for General Bots
# #
# This script installs all system packages required to RUN botserver binary. # This script installs all system packages required to RUN botserver binary.
# These are the minimal dependencies needed for production deployment. # These are the minimal dependencies needed for production deployment.
# #
# Usage: sudo ./DEPENDENCIES.sh # Usage: sudo ./DEPENDENCIES.sh
# #
set -e set -e
# Colors # Colors
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
NC='\033[0m' NC='\033[0m'
echo -e "${GREEN}========================================${NC}" echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} General Bots Runtime Dependencies${NC}" echo -e "${GREEN} General Bots Runtime Dependencies${NC}"
echo -e "${GREEN}========================================${NC}" echo -e "${GREEN}========================================${NC}"
# Check root # Check root
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Error: Run as root (use sudo)${NC}" echo -e "${RED}Error: Run as root (use sudo)${NC}"
exit 1 exit 1
fi fi
# Detect OS # Detect OS
if [ -f /etc/os-release ]; then if [ -f /etc/os-release ]; then
. /etc/os-release . /etc/os-release
OS=$ID OS=$ID
else else
echo -e "${RED}Error: Cannot detect OS${NC}" echo -e "${RED}Error: Cannot detect OS${NC}"
exit 1 exit 1
fi fi
echo -e "${YELLOW}OS: $OS${NC}" echo -e "${YELLOW}OS: $OS${NC}"
install_debian_ubuntu() { install_debian_ubuntu() {
apt-get update
apt-get install -y \ apt-get install -y \
libpq5 \ libpq5 \
libssl3 \ libssl3 \
liblzma5 \ liblzma5 \
zlib1g \ zlib1g \
ca-certificates \ ca-certificates \
curl \ curl \
wget \ wget \
libabseil20210324 \ libclang1 \
libclang1 \ pkg-config \
pkg-config \ snapd
snapd
# LXC for containers
snap install lxd || apt-get install -y lxd || true
# Initialize LXD
if command -v lxd &> /dev/null && ! lxc list &> /dev/null 2>&1; then
lxd init --auto || true
fi
}
install_fedora_rhel() {
dnf install -y \
libpq \
openssl-libs \
xz-libs \
zlib \
ca-certificates \
curl \
wget \
abseil-cpp \
clang-libs \
pkgconf-pkg-config \
lxc \
lxc-templates
}
install_arch() { }
pacman -Sy --noconfirm \
postgresql-libs \
openssl \
xz \
zlib \
ca-certificates \
curl \
wget \
abseil-cpp \
clang \
pkgconf \
lxc
}
install_alpine() { install_fedora_rhel() {
apk add --no-cache \ dnf install -y \
libpq \ libpq \
openssl \ openssl-libs \
xz-libs \ xz-libs \
zlib \ zlib \
ca-certificates \ ca-certificates \
curl \ curl \
wget \ wget \
abseil-cpp \ abseil-cpp \
clang \ clang-libs \
pkgconf \ pkgconf-pkg-config \
lxc lxc \
} lxc-templates
}
case $OS in install_arch() {
ubuntu|debian|linuxmint|pop) pacman -Sy --noconfirm \
install_debian_ubuntu postgresql-libs \
;; openssl \
fedora|rhel|centos|rocky|almalinux) xz \
install_fedora_rhel zlib \
;; ca-certificates \
arch|manjaro) curl \
install_arch wget \
;; abseil-cpp \
alpine) clang \
install_alpine pkgconf \
;; lxc
*) }
echo -e "${RED}Unsupported OS: $OS${NC}"
echo "Required libraries:"
echo " - libpq (PostgreSQL client)"
echo " - libssl (OpenSSL)"
echo " - liblzma (XZ compression)"
echo " - zlib (compression)"
echo " - abseil-cpp (Google Abseil)"
echo " - clang (LLVM runtime)"
echo " - LXC (containers)"
exit 1
;;
esac
echo -e "${GREEN}Runtime dependencies installed!${NC}" install_alpine() {
echo "" apk add --no-cache \
echo "You can now run:" libpq \
echo " ./botserver" openssl \
xz-libs \
zlib \
ca-certificates \
curl \
wget \
abseil-cpp \
clang \
pkgconf \
lxc
}
case $OS in
ubuntu|debian|linuxmint|pop)
install_debian_ubuntu
;;
fedora|rhel|centos|rocky|almalinux)
install_fedora_rhel
;;
arch|manjaro)
install_arch
;;
alpine)
install_alpine
;;
*)
echo -e "${RED}Unsupported OS: $OS${NC}"
echo "Required libraries:"
echo " - libpq (PostgreSQL client)"
echo " - libssl (OpenSSL)"
echo " - liblzma (XZ compression)"
echo " - zlib (compression)"
echo " - abseil-cpp (Google Abseil)"
echo " - clang (LLVM runtime)"
echo " - LXC (containers)"
exit 1
;;
esac
echo -e "${GREEN}Runtime dependencies installed!${NC}"
echo ""
echo "You can now run:"
echo " ./botserver"