From fcf0998212c01a8257ab4b991429250d082689a6 Mon Sep 17 00:00:00 2001 From: Valentin Date: Mon, 11 Nov 2024 20:25:35 +0100 Subject: [PATCH] ajout de trucs --- README.md | 11 +++++++++++ bin/add-site/install_directus.sh | 7 +++++++ bin/add-site/set_url.sh | 15 +++++++++++++++ bin/add_site.sh | 15 +++++++++++++++ bin/first_install.sh | 18 ++++++++++++++++++ bin/variables.sh | 4 +++- install.sh | 4 ++++ 7 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 bin/add-site/install_directus.sh create mode 100644 bin/add-site/set_url.sh create mode 100644 bin/add_site.sh diff --git a/README.md b/README.md index bc444cf..4fe90c1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,13 @@ Deployment [**D**ebian](https://www.debian.org/) (os) + [**D**ocker](https://www.docker.com/) (containerization) + [**C**addy](https://caddyserver.com/) (webserver) + [**D**irectus](https://directus.io/) (cms) + [**N**uxt](https://nuxt.com/) (static front). +Installation + +On a fresh install as root user using + +sudo passwd root + +su - root + + Upgrade + +apt update && apt upgrade -y \ No newline at end of file diff --git a/bin/add-site/install_directus.sh b/bin/add-site/install_directus.sh new file mode 100644 index 0000000..ebebb48 --- /dev/null +++ b/bin/add-site/install_directus.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +mkdir /home/$username/cms.$DOMAIN_NAME +cp assets/directus.docker-compose.yml /home/$username/cms.$DOMAIN_NAME/docker-compose.yml +cp assets/.env.example /home/$username/cms.$DOMAIN_NAME/.env +cd /home/$username/cms.$DOMAIN_NAME +docker compose up -d \ No newline at end of file diff --git a/bin/add-site/set_url.sh b/bin/add-site/set_url.sh new file mode 100644 index 0000000..d381b16 --- /dev/null +++ b/bin/add-site/set_url.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +echo -e "${PURPLE}${BOLD}Enter the domain name of the website${RESET}" +read DOMAIN_NAME + +if [[ -z "$ip" ]]; then + ip=$(hostname -I | cut -d' ' -f1) +fi + +echo -e "${PURPLE}${BOLD}Configure the ${DOMAIN_NAME} DNS ZONE as the following${RESET}" +echo -e "${BLUE}Domain : ${DOMAIN_NAME} | Type : A | Target : ${ip}${RESET}" +echo -e "${BLUE}Domain : cms.${DOMAIN_NAME} | Type : A | Target : ${ip}${RESET}" +echo -e "${BLUE}Domain : www.${DOMAIN_NAME} | Type : A | Target : ${ip}${RESET}" +echo -e "${PURPLE}${BOLD}Press any key when done${RESET}" +read \ No newline at end of file diff --git a/bin/add_site.sh b/bin/add_site.sh new file mode 100644 index 0000000..3821854 --- /dev/null +++ b/bin/add_site.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# SET URL +echo -e "${PURPLE}${BOLD}Set url ? (y/N) ${RESET}" +read answer +if [[ "$answer" == "y" ]]; then + . bin/add-site/set_url.sh +fi + +# INSTALL DIRECTUS +echo -e "${PURPLE}${BOLD}Install Directus ? (y/N) ${RESET}" +read answer +if [[ "$answer" == "y" ]]; then + . bin/add-site/install_directus.sh +fi \ No newline at end of file diff --git a/bin/first_install.sh b/bin/first_install.sh index 9178906..231453f 100644 --- a/bin/first_install.sh +++ b/bin/first_install.sh @@ -31,4 +31,22 @@ 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 "Docker is not installed." + exit 1 +else + echo "Docker is installed." +fi + +# Check if a Caddy container is running +if docker ps --filter "ancestor=caddy" --format '{{.Names}}' | grep -q .; then + echo "A Caddy container is running." +else + mkdir /home/$username/caddy + cp assets/caddy.docker-compose.yml /home/$username/caddy/docker-compose.yml + cd /home/$username/caddy + docker compose up -d fi \ No newline at end of file diff --git a/bin/variables.sh b/bin/variables.sh index 67b8ea7..98de300 100644 --- a/bin/variables.sh +++ b/bin/variables.sh @@ -5,4 +5,6 @@ PURPLE='\033[35m' ORANGE='\033[33m' BLUE='\033[34m' BOLD='\033[1m' -RESET='\033[0m' \ No newline at end of file +RESET='\033[0m' + +DOMAIN_NAME="" \ No newline at end of file diff --git a/install.sh b/install.sh index 10c6215..846c817 100644 --- a/install.sh +++ b/install.sh @@ -12,3 +12,7 @@ fi # First install, root only echo -e "${PURPLE}${BOLD}First server installation${RESET}" . bin/first_install.sh + +# Install website +echo -e "${PURPLE}${BOLD}Install website${RESET}" +. bin/add_site.sh \ No newline at end of file