ajout des conditionnels

This commit is contained in:
Valentin 2024-02-23 15:14:36 +01:00
parent cd2b3aafba
commit c863c081a9
1 changed files with 44 additions and 37 deletions

View File

@ -10,7 +10,8 @@ fi
#
# USER
#
read -p "Create a user ? (y/n) " answer
if [[ "$answer" == "y" ]]; then
echo "Create user"
read -p "Enter username: " username
@ -30,28 +31,33 @@ echo "$username:$password" | chpasswd
usermod -aG sudo $username
echo "User '$username' created with password successfully."
fi
#
# SSH
#
read -p "Setup SSH ? (y/n) " answer
if [[ "$answer" == "y" ]]; then
echo "Setup SSH"
touch /etc/ssh/sshd_config.d/custom.conf
echo "PermitRootLogin no" >> /etc/ssh/sshd_config.d/custom.conf
echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config.d/custom.conf
systemctl reload ssh
fi
#
# FIREWALL AND FAIL2BAN
#
read -p "Setup Firewall and Fail2Ban ? (y/n) " answer
if [[ "$answer" == "y" ]]; then
echo "Setup Firewall and Fail2Ban"
apt install -y ufw fail2ban
systemctl enable fail2ban
ufw allow ssh
ufw allow http
ufw allow https
fi
#
# TODO : ZABBIX AND URBACKUP
@ -62,11 +68,12 @@ echo "TODO : Zabbix and Urbackup"
#
# CADDY
#
read -p "Install Caddy webserver ? (y/n) " answer
if [[ "$answer" == "y" ]]; then
echo "Install Caddy Webserver"
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
caddy run
fi