#!/bin/bash set -e # Colors RED="\e[31m" GREEN="\e[32m" YELLOW="\e[33m" BLUE="\e[34m" CYAN="\e[36m" BOLD="\e[1m" RESET="\e[0m" # Output functions info() { echo -e "${CYAN}[INFO]${RESET} $1"; } success() { echo -e "${GREEN}[OK]${RESET} $1"; } warn() { echo -e "${YELLOW}[WARN]${RESET} $1"; } error() { echo -e "${RED}[ERROR]${RESET} $1"; } # Progress bar with percentage progress_bar() { local duration=$1 local width=30 for ((i=0; i<=width; i++)); do percent=$((i*100/width)) bar=$(printf "%0.s#" $(seq 1 $i)) spaces=$(printf "%0.s " $(seq 1 $((width-i)))) echo -ne "${BLUE}[${bar}${spaces}] ${percent}%${RESET}\r" sleep $(awk "BEGIN {print $duration/$width}") done echo } info "Detecting distribution..." if [ -f /etc/redhat-release ]; then DISTRO="redhat" success "Detected RedHat-based system" yum -y install perl-libwww-perl.noarch perl-LWP-Protocol-https.noarch perl-GDGraph elif [ -f /etc/debian_version ]; then DISTRO="debian" success "Detected Debian-based system" apt-get update -y apt-get -y install libwww-perl liblwp-protocol-https-perl libgd-graph-perl else error "Unsupported distribution" exit 1 fi install_package () { NAME=$1 info "Installing ${BOLD}$NAME${RESET}..." progress_bar 2 cd /usr/src rm -fv /usr/src/${NAME}.tgz wget -4 -q http://mirror.mobinhost.com/scripts/configserver/${NAME}.tgz tar -xzf ${NAME}.tgz cd ${NAME} sh install.sh cd .. rm -Rfv /usr/src/${NAME}* success "$NAME installed successfully!" } # Detect DirectAdmin or cPanel if [ -x /usr/local/directadmin/directadmin ]; then success "DirectAdmin detected" warn "Only CSF can be installed on DirectAdmin." read -p "$(echo -e ${YELLOW}"Do you want to install CSF now? (y/n): "${RESET})" ans if [[ "$ans" =~ ^[Yy]$ ]]; then install_package csf else warn "CSF installation skipped." fi elif [ -x /usr/local/cpanel/cpanel ]; then success "cPanel detected" info "You can install CSF, CMC, CMM, CMQ and CSE." read -p "$(echo -e ${YELLOW}"Do you want to install ALL of them? (y/n): "${RESET})" all_ans if [[ "$all_ans" =~ ^[Yy]$ ]]; then for pkg in csf cmc cmm cmq cse; do install_package $pkg done else info "Select which ones to install:" for pkg in csf cmc cmm cmq cse; do read -p "$(echo -e ${YELLOW}"Install $pkg? (y/n): "${RESET})" ans if [[ "$ans" =~ ^[Yy]$ ]]; then install_package $pkg else warn "$pkg skipped." fi done fi else warn "No DirectAdmin or cPanel detected." info "Defaulting to CSF installation only." read -p "$(echo -e ${YELLOW}"Do you want to install CSF? (y/n): "${RESET})" ans if [[ "$ans" =~ ^[Yy]$ ]]; then install_package csf fi fi success "Installation process completed!"