ajout de la coloration des textes

This commit is contained in:
Valentin 2024-02-23 15:38:12 +01:00
parent c863c081a9
commit 4d93ea875c
1 changed files with 22 additions and 13 deletions

View File

@ -1,6 +1,10 @@
#!/bin/bash
echo "Deployment Debian + Caddy + Directus + Nuxt"
RED='\033[1;31m'
BOLD='\033[1m'
RESET='\033[0m'
echo -e "${RED}${BOLD}Deployment Debian + Caddy + Directus + Nuxt${RESET}"
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
@ -10,9 +14,10 @@ fi
#
# USER
#
read -p "Create a user ? (y/n) " answer
echo -e "${RED}${BOLD}Create a user ? (y/n) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then
echo "Create user"
echo -e "${RED}${BOLD}Create user${RESET}"
read -p "Enter username: " username
@ -21,7 +26,7 @@ if [[ "$answer" == "y" ]]; then
exit 1
fi
echo "Generate and store the password somewhere safe"
echo -e "${RED}${BOLD}Generate and store the password somewhere safe${RESET}"
read -s -p "Enter password: " password
echo
useradd -m "$username"
@ -30,15 +35,16 @@ if [[ "$answer" == "y" ]]; then
usermod -aG sudo $username
echo "User '$username' created with password successfully."
echo -e "${RED}${BOLD}User '$username' created with password successfully.${RESET}"
fi
#
# SSH
#
read -p "Setup SSH ? (y/n) " answer
echo -e "${RED}${BOLD}Setup SSH ? (y/n) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then
echo "Setup SSH"
echo -e "${RED}${BOLD}Setup SSH${RESET}"
touch /etc/ssh/sshd_config.d/custom.conf
echo "PermitRootLogin no" >> /etc/ssh/sshd_config.d/custom.conf
@ -49,9 +55,10 @@ fi
#
# FIREWALL AND FAIL2BAN
#
read -p "Setup Firewall and Fail2Ban ? (y/n) " answer
echo -e "${RED}${BOLD}Setup Firewall and Fail2ban ? (y/n) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then
echo "Setup Firewall and Fail2Ban"
echo -e "${RED}${BOLD}Setup Firewall and Fail2ban${RESET}"
apt install -y ufw fail2ban
systemctl enable fail2ban
ufw allow ssh
@ -63,17 +70,19 @@ fi
# TODO : ZABBIX AND URBACKUP
#
echo "TODO : Zabbix and Urbackup"
echo -e "${RED}${BOLD}TODO : Zabbix and Urbackup${RESET}"
#
# CADDY
#
read -p "Install Caddy webserver ? (y/n) " answer
echo -e "${RED}${BOLD}Install Caddy webserver ? (y/n) ${RESET}"
read answer
if [[ "$answer" == "y" ]]; then
echo "Install Caddy Webserver"
echo -e "${RED}${BOLD}Install Caddy Webserver${RESET}"
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
apt update
apt install -y caddy
fi
fi