Files
callaba-installer/install-callaba.sh.bk

286 lines
8.4 KiB
Bash

#!/bin/bash
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
REPO_URL="https://gitlab.callabacloud.com/callaba-8/linux-8.2.git"
REPO_DIR="linux-8.2"
ascii_title() {
cat <<'EOF'
____ _ _ _ ___ _ _ _
/ ___|__ _| | | __ _| |__ __ _ |_ _|_ __ ___| |_ __ _| | | ___ _ __
| | / _` | | |/ _` | '_ \ / _` | | || '_ \/ __| __/ _` | | |/ _ \ '__|
| |__| (_| | | | (_| | |_) | (_| | | || | | \__ \ || (_| | | | __/ |
\____\__,_|_|_|\__,_|_.__/ \__,_| |___|_| |_|___/\__\__,_|_|_|\___|_|
Made by redhat | Powered by World of IPTV
EOF
}
show_title() {
echo -e "${GREEN}"
ascii_title
echo -e "${NC}"
}
show_menu() {
echo -e "${YELLOW}Callaba Installer"
echo "*****************"
echo "1. Check the System requirements"
echo "2. Installation with regular CPU transcoding usage"
echo "3. Installation with NVIDIA GPU support"
echo "4. Installation with XILINX accelerated transcoding support"
echo "5. Update Callaba"
echo "6. Uninstall Callaba"
echo "7. Reset Admin password"
echo "8. Exit the Script"
echo -e "${NC}"
}
step_title() {
echo -e "\n${YELLOW}========== $1 ==========${NC}"
}
get_public_ip() {
curl -s https://api.ipify.org || hostname -I | awk '{print $1}'
}
check_requirements() {
step_title "CHECKING SYSTEM REQUIREMENTS"
ERR=0
# OS check
if [[ $(lsb_release -rs 2>/dev/null) != "22.04" ]]; then
echo -e "${YELLOW}[!] Ubuntu 22.04 is required.${NC}"
ERR=1
else
echo -e "${GREEN}[OK] Ubuntu 22.04 detected.${NC}"
fi
# Sudo/root check
if [[ $EUID -ne 0 ]]; then
if sudo -n true 2>/dev/null; then
echo -e "${GREEN}[OK] Sudo privileges detected.${NC}"
else
echo -e "${YELLOW}[!] Please run this script as root or with sudo privileges.${NC}"
ERR=1
fi
else
echo -e "${GREEN}[OK] Running as root.${NC}"
fi
# Docker check
if ! command -v docker &>/dev/null; then
echo -e "${YELLOW}[!] Docker not installed.${NC}"
ERR=1
else
DOCKER_VER=$(docker --version | awk '{print $3}' | sed 's/,//')
DOCKER_OK=$(echo -e "$DOCKER_VER\n27.4.0" | sort -V | head -n1)
if [[ "$DOCKER_OK" != "27.4.0" ]]; then
echo -e "${YELLOW}[!] Docker version must be 27.4.0 or higher. Current: $DOCKER_VER${NC}"
ERR=1
else
echo -e "${GREEN}[OK] Docker version: $DOCKER_VER${NC}"
fi
fi
# Docker Compose check
if ! docker compose version &>/dev/null; then
if ! command -v docker-compose &>/dev/null; then
echo -e "${YELLOW}[!] Docker Compose not installed.${NC}"
ERR=1
else
COMPOSE_VER=$(docker-compose --version | awk '{print $3}' | sed 's/,//')
COMPOSE_OK=$(echo -e "$COMPOSE_VER\n1.29.2" | sort -V | head -n1)
if [[ "$COMPOSE_OK" != "1.29.2" ]]; then
echo -e "${YELLOW}[!] Docker Compose version must be 1.29.2 or higher. Current: $COMPOSE_VER${NC}"
ERR=1
else
echo -e "${GREEN}[OK] Docker Compose version: $COMPOSE_VER${NC}"
fi
fi
else
COMPOSE_VER=$(docker compose version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
COMPOSE_OK=$(echo -e "$COMPOSE_VER\n1.29.2" | sort -V | head -n1)
if [[ "$COMPOSE_OK" != "1.29.2" ]]; then
echo -e "${YELLOW}[!] Docker Compose plugin version must be 1.29.2 or higher. Current: $COMPOSE_VER${NC}"
ERR=1
else
echo -e "${GREEN}[OK] Docker Compose plugin version: $COMPOSE_VER${NC}"
fi
fi
# Git check
if ! command -v git &>/dev/null; then
echo -e "${YELLOW}[!] git not installed.${NC}"
ERR=1
else
echo -e "${GREEN}[OK] git is installed.${NC}"
fi
# Public IP
echo -e "${YELLOW}Server public IP: $(get_public_ip)${NC}"
return $ERR
}
install_requirements() {
step_title "INSTALLING REQUIREMENTS"
# Update and install basics
apt-get update
apt-get install -y ca-certificates curl git sudo lsb-release
# Docker install
if ! command -v docker &>/dev/null || [[ $(docker --version | awk '{print $3}' | sed 's/,//') < "27.4.0" ]]; then
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
fi
# Docker Compose (old version, fallback)
if ! docker compose version &>/dev/null && ! command -v docker-compose &>/dev/null; then
sudo apt-get install -y docker-compose
fi
# Git
if ! command -v git &>/dev/null; then
sudo apt-get install -y git
fi
}
callaba_install() {
TYPE="$1" # cpu | nvidia | xilinx
step_title "INSTALLING CALLABA (${TYPE^^} MODE)"
# Clone repo if not already
if [ ! -d "$REPO_DIR" ]; then
git clone "$REPO_URL"
fi
cd "$REPO_DIR" || { echo -e "${YELLOW}Could not enter repo directory!${NC}"; exit 1; }
case "$TYPE" in
cpu) sudo bash install.sh 8.2.p.NDI.pre ;;
nvidia) sudo bash install.sh 8.2.p.NDI.pre nvidia ;;
xilinx) sudo bash install.sh 8.2.p.NDI.pre xilinx ;;
esac
callaba_success
}
callaba_update() {
step_title "UPDATING CALLABA"
read -p "Enter Callaba version (e.g. 8.2.p.NDI.pre): " VERSION
read -p "Enter GPU type (cpu/nvidia/xilinx): " TYPE
if [ ! -d "$REPO_DIR" ]; then
git clone "$REPO_URL"
fi
cd "$REPO_DIR" || { echo -e "${YELLOW}Could not enter repo directory!${NC}"; exit 1; }
sudo bash update.sh "$VERSION" "$TYPE"
callaba_success
}
callaba_uninstall() {
step_title "UNINSTALLING CALLABA"
if [ ! -d "$REPO_DIR" ]; then
git clone "$REPO_URL"
fi
cd "$REPO_DIR" || { echo -e "${YELLOW}Could not enter repo directory!${NC}"; exit 1; }
sudo bash remove.sh
echo -e "${YELLOW}Callaba has been uninstalled.${NC}"
}
callaba_reset_pw() {
step_title "RESETTING ADMIN PASSWORD"
if [ ! -d "$REPO_DIR" ]; then
git clone "$REPO_URL"
fi
cd "$REPO_DIR" || { echo -e "${YELLOW}Could not enter repo directory!${NC}"; exit 1; }
sudo bash reset-password.sh
}
callaba_success() {
step_title "INSTALLATION SUCCESSFUL"
echo ""
echo -e "${GREEN}"
echo -e "Launch Callaba Dashboard: http://$(get_public_ip)"
echo ""
echo "Default login"
echo "User: admin"
echo "Password: password"
echo "**********************************"
echo -e "${NC}"
}
main() {
while true; do
clear
show_title
show_menu
echo
read -p "Choose an option [1-8]: " CHOICE
case $CHOICE in
1)
check_requirements
if [ $? -ne 0 ]; then
read -p "Install all missing requirements automatically? [Y/n]: " YN
[[ "$YN" =~ ^[Yy]$|^$ ]] && install_requirements
echo -e "${YELLOW}Rechecking requirements...${NC}"
check_requirements
fi
read -p "Press enter to return to menu..." ;;
2)
check_requirements
if [ $? -eq 0 ]; then
callaba_install "cpu"
else
echo -e "${YELLOW}Requirements not met! Run option 1.${NC}"
fi
read -p "Press enter to return to menu..." ;;
3)
check_requirements
if [ $? -eq 0 ]; then
callaba_install "nvidia"
else
echo -e "${YELLOW}Requirements not met! Run option 1.${NC}"
fi
read -p "Press enter to return to menu..." ;;
4)
check_requirements
if [ $? -eq 0 ]; then
callaba_install "xilinx"
else
echo -e "${YELLOW}Requirements not met! Run option 1.${NC}"
fi
read -p "Press enter to return to menu..." ;;
5)
check_requirements
if [ $? -eq 0 ]; then
callaba_update
else
echo -e "${YELLOW}Requirements not met! Run option 1.${NC}"
fi
read -p "Press enter to return to menu..." ;;
6)
callaba_uninstall
read -p "Press enter to return to menu..." ;;
7)
callaba_reset_pw
read -p "Press enter to return to menu..." ;;
8)
echo -e "${GREEN}Bye!${NC}"; exit 0 ;;
*)
echo -e "${YELLOW}Invalid option. Try again.${NC}"
sleep 1 ;;
esac
done
}
main