deployment_ddcdn_multisite/bin/first_install.sh

49 lines
1.3 KiB
Bash

#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
# USER
echo -e "${PURPLE}${BOLD}Create a user ? (y/N) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then
. bin/first-install/create_user.sh
fi
# SSH
echo -e "${PURPLE}${BOLD}Setup SSH ? (y/N) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then
. bin/first-install/setup_ssh.sh
fi
# FIREWALL AND FAIL2BAN
echo -e "${PURPLE}${BOLD}Setup Firewall and Fail2ban ? (y/N) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then
. bin/first-install/setup_firewall_fail2ban.sh
fi
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo -e "${ORANGE}${BOLD}Docker is not installed.${RESET}"
exit 1
else
echo -e "${BLUE}${BOLD}Docker is installed.${RESET}"
fi
# Check if a Caddy container is running
if docker ps --filter "ancestor=caddy" --format '{{.Names}}' | grep -q .; then
echo -e "${BLUE}${BOLD}A Caddy container is running.${BLUE}${BOLD}"
else
check_global_const USERNAME CADDYFILE
mkdir "/home/${USERNAME}/caddy"
mkdir "/home/${USERNAME}/caddy/caddyfile"
touch "${CADDYFILE}"
cp assets/caddy.docker-compose.yml "/home/${USERNAME}/caddy/docker-compose.yml"
docker network create web
docker compose -f "/home/${USERNAME}/caddy/docker-compose.yml" up -d
fi