terminal

KROTEK

menu

MYSQL + Opening ports installation

Choose your system:

Debian

Debian

Logo: Tobias Benjamin Kohl
CC BY-SA
Ubuntu

Ubuntu

Logo: Canonical
CC BY-SA
Rocky Linux

Rocky Linux

Logo: Rocky Enterprise Software Foundation
CC BY-SA
Alma Linux

Alma Linux

Logo: AlmaLinux OS Foundation
CC BY-SA
Alpine Linux

Alpine Linux

Logo: Alpine Linux
CC BY-SA

Install/Uninstall script (Docker /
Warning: Undefined array key "
Deprecated: htmlspecialchars(): Passing null to parameter " in /var/www/scripts/PHP_HTML/maininstall.php on line 49

Warning: Trying to access array offset on null in /var/www/scripts/PHP_HTML/maininstall.php on line 49

Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/scripts/PHP_HTML/maininstall.php on line 49
)

download content_copy expand_more
#!/bin/bash
set -e

# ========== COLORS ==========
NC='\033[0m'        # No Color / Reset
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
BOLD='\033[1m'

# ========== SPINNER FUNCTIONS ==========
spinner_pid=""

start_spinner() {
  local msg="$1"
  echo -ne "${BLUE}[INFO] ℹ️${NC} ${msg}... "
  trap stop_spinner INT
  (
    local spin='-\|/'
    while true; do
      for i in $(seq 0 $(( ${#spin} - 1 )) ); do
        echo -ne "\b${spin:$i:1}"
        sleep 0.1
      done
    done
  ) &
  spinner_pid=$!
  disown
}

stop_spinner() {
  if [[ -n "$spinner_pid" ]]; then
    kill "$spinner_pid" &>/dev/null || true
    wait "$spinner_pid" 2>/dev/null || true
    spinner_pid=""
  fi
  echo -e "\b${GREEN}[OK] ✓${NC}"
  trap - INT
}

run_step() {
  start_spinner "$1"
  shift
  "$@" &>/dev/null
  stop_spinner
}

run_multistep() {
  start_spinner "$1"
  shift
  {
    "$@"
  } &>/dev/null
  stop_spinner
}

# ========== DETECT DISTRIBUTION ==========
DISTRO=""
if [[ -f /etc/os-release ]]; then
  . /etc/os-release
  DISTRO=$(echo "$ID" | tr '[:upper:]' '[:lower:]')
fi
[[ "$DISTRO" == "rhel" ]] && DISTRO="centos"
echo -e "${BLUE}[INFO] Detected distribution: ${BOLD}${DISTRO}${NC}"

case "$DISTRO" in
  debian|ubuntu)
    PKG_UPDATE="sudo apt update -y && sudo apt upgrade -y"
    PKG_INSTALL="sudo apt install -y"
    PKG_REMOVE="sudo apt remove --purge -y"
    PKG_CLEAN="sudo apt autoremove -y && sudo apt clean"
    ;;
  almalinux|rocky|oracle|centos)
    PKG_UPDATE="sudo dnf update -y"
    PKG_INSTALL="sudo dnf install -y"
    PKG_REMOVE="sudo dnf remove -y"
    PKG_CLEAN="sudo dnf autoremove -y && sudo dnf clean all"
    ;;
  *)
    echo -e "${RED}[ERROR] Unsupported distribution: $DISTRO${NC}"
    exit 1
    ;;
esac

echo -e "\n${BOLD}${YELLOW}=== Docker + NGINX Installer (without firewalld) ===${NC}\n"
echo "1) Install"
echo "2) Uninstall"
read -rp "Choose an option [1-2]: " ACTION

if [[ "$ACTION" == "1" ]]; then
  echo -e "\n${BOLD}${YELLOW}=== Installation ===${NC}\n"

  run_multistep "Updating system" bash -c "$PKG_UPDATE"

  # Install required packages for Docker repo setup
  if [[ "$DISTRO" == "debian" || "$DISTRO" == "ubuntu" ]]; then
    run_step "Installing prerequisites" sudo $PKG_INSTALL apt-transport-https ca-certificates curl gnupg lsb-release
    run_step "Adding Docker GPG key" curl -fsSL https://download.docker.com/linux/${DISTRO}/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
    echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/${DISTRO} $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    run_multistep "Updating package database" sudo apt update
  else
    run_step "Installing dnf-plugins-core" sudo $PKG_INSTALL dnf-plugins-core
    run_step "Adding Docker repo" sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  fi

  run_multistep "Installing Docker" sudo $PKG_INSTALL docker-ce docker-ce-cli containerd.io

  # Workaround: Force iptables legacy if available (AlmaLinux, Rocky, CentOS)
  if [[ "$DISTRO" == "almalinux" || "$DISTRO" == "rocky" || "$DISTRO" == "centos" ]]; then
    if command -v alternatives &>/dev/null && [[ -f /usr/sbin/iptables-legacy ]]; then
      run_step "Setting iptables legacy backend" sudo alternatives --set iptables /usr/sbin/iptables-legacy
      run_step "Setting ip6tables legacy backend" sudo alternatives --set ip6tables /usr/sbin/ip6tables-legacy
    fi
  fi

  run_step "Enabling Docker" sudo systemctl enable docker
  run_step "Starting Docker" sudo systemctl start docker

  # Create simple directory for nginx static site
  SITE_DIR="$HOME/docker-nginx-site"
  mkdir -p "$SITE_DIR"

  # Create example index.html
  cat > "$SITE_DIR/index.html" <<EOF
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Sample NGINX page in Docker</title>
</head>
<body>
  <h1>Welcome to the site running in Docker!</h1>
  <p>This is a sample index.html file.</p>
</body>
</html>
EOF

  echo -e "${BLUE}[INFO] Running nginx container with mounted site on port 80...${NC}"
  docker rm -f my-nginx 2>/dev/null || true
  docker run -d --name my-nginx -p 80:80 -v "$SITE_DIR":/usr/share/nginx/html:ro nginx

  echo -e "\n${GREEN}[DONE] ✅ Docker and NGINX are up and running. The site is available on port 80.${NC}"

elif [[ "$ACTION" == "2" ]]; then
  echo -e "\n${BOLD}${YELLOW}=== Uninstallation ===${NC}\n"

  run_step "Stopping nginx container" docker rm -f my-nginx || true
  run_step "Stopping Docker" sudo systemctl stop docker || true
  run_step "Disabling Docker" sudo systemctl disable docker || true
  run_multistep "Removing Docker packages" sudo $PKG_REMOVE docker-ce docker-ce-cli containerd.io
  run_multistep "Cleaning unused packages" sudo $PKG_CLEAN

  echo -e "\n${GREEN}[DONE] ✅ Docker and nginx removed.${NC}"

else
  echo -e "${RED}[ERROR] Invalid option selected.${NC}"
  exit 1
fi

Use the following command to auto-download and run:


Warning: Undefined array key "
Deprecated: htmlspecialchars(): Passing null to parameter " in /var/www/scripts/PHP_HTML/autoscripts.php on line 87

Warning: Trying to access array offset on null in /var/www/scripts/PHP_HTML/autoscripts.php on line 87
curl -fsSL -o script.sh "https://krotek.serveblog.net/how-to-install/DATABASE/MYSQL/scripts.php?variant=docker&type=script&system=%3Cbr+%2F%3E%3Cb%3EDeprecated%3C%2Fb%3E%3A++htmlspecialchars%28%29%3A+Passing+null+to+parameter+" && chmod +x script.sh && sudo ./script.sh