forked from beckn/protocol-server
-
Notifications
You must be signed in to change notification settings - Fork 3
/
nginx_certbot_installation.sh
executable file
·38 lines (32 loc) · 1.16 KB
/
nginx_certbot_installation.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Function to install Nginx and Certbot
install_nginx_certbot() {
echo "Installing Nginx and Certbot..."
# Check the system package manager and install Nginx and Certbot accordingly
if [ -x "$(command -v apt-get)" ]; then
# APT (Debian/Ubuntu)
sudo apt-get update
sudo apt-get install -y nginx certbot python3-certbot-nginx jq
elif [ -x "$(command -v yum)" ]; then
# YUM (Red Hat/CentOS)
sudo yum install -y nginx certbot jq
elif [ -x "$(command -v amazon-linux-extras)" ]; then
# Amazon Linux 2
sudo amazon-linux-extras install nginx1.12
sudo yum install -y certbot jq
else
echo "Unsupported package manager. Please install Nginx and Certbot manually."
exit 1
fi
# Check if Nginx and Certbot installation was successful
if [ $? -eq 0 ]; then
echo "Nginx and Certbot installed successfully."
else
echo "Failed to install Nginx and Certbot. Exiting."
exit 1
fi
}
if [ -z "$(command -v nginx)" ] || [ -z "$(command -v certbot)" ]; then
install_nginx_certbot
fi
echo "Nginx and Certbot are installed skipping installation"