ajout des conditionnels
This commit is contained in:
parent
cd2b3aafba
commit
c863c081a9
81
install.sh
81
install.sh
|
@ -10,48 +10,54 @@ fi
|
||||||
#
|
#
|
||||||
# USER
|
# USER
|
||||||
#
|
#
|
||||||
|
read -p "Create a user ? (y/n) " answer
|
||||||
|
if [[ "$answer" == "y" ]]; then
|
||||||
|
echo "Create user"
|
||||||
|
|
||||||
echo "Create user"
|
read -p "Enter username: " username
|
||||||
|
|
||||||
read -p "Enter username: " username
|
if id "$username" &>/dev/null; then
|
||||||
|
echo "User '$username' already exists."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if id "$username" &>/dev/null; then
|
echo "Generate and store the password somewhere safe"
|
||||||
echo "User '$username' already exists."
|
read -s -p "Enter password: " password
|
||||||
exit 1
|
echo
|
||||||
|
useradd -m "$username"
|
||||||
|
chsh -s /bin/bash $username
|
||||||
|
echo "$username:$password" | chpasswd
|
||||||
|
|
||||||
|
usermod -aG sudo $username
|
||||||
|
|
||||||
|
echo "User '$username' created with password successfully."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Generate and store the password somewhere safe"
|
|
||||||
read -s -p "Enter password: " password
|
|
||||||
echo
|
|
||||||
useradd -m "$username"
|
|
||||||
chsh -s /bin/bash $username
|
|
||||||
echo "$username:$password" | chpasswd
|
|
||||||
|
|
||||||
usermod -aG sudo $username
|
|
||||||
|
|
||||||
echo "User '$username' created with password successfully."
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# SSH
|
# SSH
|
||||||
#
|
#
|
||||||
|
read -p "Setup SSH ? (y/n) " answer
|
||||||
|
if [[ "$answer" == "y" ]]; then
|
||||||
|
echo "Setup SSH"
|
||||||
|
|
||||||
echo "Setup SSH"
|
touch /etc/ssh/sshd_config.d/custom.conf
|
||||||
|
echo "PermitRootLogin no" >> /etc/ssh/sshd_config.d/custom.conf
|
||||||
touch /etc/ssh/sshd_config.d/custom.conf
|
echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config.d/custom.conf
|
||||||
echo "PermitRootLogin no" >> /etc/ssh/sshd_config.d/custom.conf
|
systemctl reload ssh
|
||||||
echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config.d/custom.conf
|
fi
|
||||||
systemctl reload ssh
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# FIREWALL AND FAIL2BAN
|
# FIREWALL AND FAIL2BAN
|
||||||
#
|
#
|
||||||
|
read -p "Setup Firewall and Fail2Ban ? (y/n) " answer
|
||||||
echo "Setup Firewall and Fail2Ban"
|
if [[ "$answer" == "y" ]]; then
|
||||||
apt install -y ufw fail2ban
|
echo "Setup Firewall and Fail2Ban"
|
||||||
systemctl enable fail2ban
|
apt install -y ufw fail2ban
|
||||||
ufw allow ssh
|
systemctl enable fail2ban
|
||||||
ufw allow http
|
ufw allow ssh
|
||||||
ufw allow https
|
ufw allow http
|
||||||
|
ufw allow https
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# TODO : ZABBIX AND URBACKUP
|
# TODO : ZABBIX AND URBACKUP
|
||||||
|
@ -62,11 +68,12 @@ echo "TODO : Zabbix and Urbackup"
|
||||||
#
|
#
|
||||||
# CADDY
|
# CADDY
|
||||||
#
|
#
|
||||||
|
read -p "Install Caddy webserver ? (y/n) " answer
|
||||||
echo "Install Caddy Webserver"
|
if [[ "$answer" == "y" ]]; then
|
||||||
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
|
echo "Install Caddy Webserver"
|
||||||
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
|
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
|
||||||
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
|
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
|
||||||
apt update
|
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
|
||||||
apt install -y caddy
|
apt update
|
||||||
caddy run
|
apt install -y caddy
|
||||||
|
fi
|
Loading…
Reference in New Issue