Files
callaba-installer/callaba-installer.sh

331 lines
10 KiB
Bash

#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# ========= CPU ARCHITECTURE CHECK =========
cpu_arch=$(uname -m)
if [[ "$cpu_arch" != "x86_64" && "$cpu_arch" != "amd64" ]]; then
echo -e "${RED}======================================================================"
echo -e " INCOMPATIBLE CPU DETECTED: $cpu_arch"
echo -e " Callaba On-Premise is only compatible with x86_64 (amd64) CPUs!"
echo -e " This system is not supported."
echo -e " Please use a server/VM with an x86_64-compatible processor."
echo -e "======================================================================${NC}"
exit 1
fi
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}'
}
ensure_compose_shim() {
sudo bash -c 'echo -e "#!/bin/bash\ndocker compose \"\$@\"" > /usr/local/bin/docker-compose'
sudo chmod +x /usr/local/bin/docker-compose
}
install_docker_official() {
step_title "INSTALLING DOCKER (OFFICIAL WAY)"
sudo apt-get remove -y docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg lsb-release
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
sudo systemctl enable docker
sudo systemctl start docker
}
patch_callaba_install_sh() {
local install_sh="$REPO_DIR/install.sh"
if [[ ! -f "$install_sh" ]]; then
echo -e "${YELLOW}install.sh not found. Skipping patch.${NC}"
return
fi
# Comment out all lines that download or chmod the legacy docker-compose binary
sed -i '/github.*docker-compose/s/^/#/' "$install_sh"
sed -i '/chmod.*docker-compose/s/^/#/' "$install_sh"
# Remove any duplicate shim lines before adding (idempotence)
sed -i '/^sudo bash -c.*docker compose/d' "$install_sh"
# Insert the correct shim right after the get.docker.com install
awk '
/get.docker.com.*sh/ && !found_shim {
print $0
print "sudo bash -c '\''echo -e \"#!/bin/bash\\ndocker compose \\\"\\$@\\\"\" > /usr/local/bin/docker-compose'\''"
print "sudo chmod +x /usr/local/bin/docker-compose"
found_shim=1
next
}
{ print }
' "$install_sh" > "${install_sh}.tmp" && mv "${install_sh}.tmp" "$install_sh"
echo -e "${GREEN}Patched install.sh for Compose compatibility.${NC}"
}
check_requirements() {
step_title "CHECKING SYSTEM REQUIREMENTS"
ERR=0
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
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
ensure_compose_shim
if ! command -v docker &>/dev/null; then
echo -e "${YELLOW}[!] Docker not installed.${NC}"
ERR=1
else
DOCKER_VER=$(docker --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
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
if docker compose version &>/dev/null; then
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
else
echo -e "${YELLOW}[!] Docker Compose plugin not installed.${NC}"
ERR=1
fi
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
echo -e "${YELLOW}Server public IP: $(get_public_ip)${NC}"
return $ERR
}
install_requirements() {
step_title "INSTALLING REQUIREMENTS"
sudo apt-get update
sudo apt-get install -y ca-certificates curl git sudo lsb-release gnupg
if ! command -v docker &>/dev/null || [[ $(docker --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') < "27.4.0" ]]; then
install_docker_official
fi
if ! command -v git &>/dev/null; then
sudo apt-get install -y git
fi
ensure_compose_shim
}
callaba_install() {
TYPE="$1"
step_title "INSTALLING CALLABA (${TYPE^^} MODE)"
if [ ! -d "$REPO_DIR" ]; then
git clone "$REPO_URL"
fi
patch_callaba_install_sh
cd "$REPO_DIR" || { echo -e "${YELLOW}Could not enter repo directory!${NC}"; exit 1; }
ensure_compose_shim
if [ "$TYPE" = "cpu" ]; then
yes | sudo bash install.sh 8.2.p.NDI.pre
elif [ "$TYPE" = "nvidia" ]; then
yes | sudo bash install.sh 8.2.p.NDI.pre nvidia
elif [ "$TYPE" = "xilinx" ]; then
yes | sudo bash install.sh 8.2.p.NDI.pre xilinx
fi
if [ $? -eq 0 ]; then
callaba_success
else
echo -e "${YELLOW}Installation failed! Please check logs above.${NC}"
fi
}
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
patch_callaba_install_sh
cd "$REPO_DIR" || { echo -e "${YELLOW}Could not enter repo directory!${NC}"; exit 1; }
ensure_compose_shim
yes | sudo bash update.sh "$VERSION" "$TYPE"
if [ $? -eq 0 ]; then
callaba_success
else
echo -e "${YELLOW}Update failed! Please check logs above.${NC}"
fi
}
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 -e "${YELLOW}"
echo "**********************************"
echo -e "Installation successfull ! ${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