-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
44 lines (39 loc) · 1.21 KB
/
Copy pathinit.sh
File metadata and controls
44 lines (39 loc) · 1.21 KB
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
39
40
41
42
43
44
#!/bin/bash
# Function to replace domain names in nginx.conf based on environment variables
nginx_replace_domain() {
sed -i "s/www.yourdomain.com/www.$1/g" nginx.conf
sed -i "s/yourdomain.com/$1/g" nginx.conf
echo "Domain names in nginx.conf have been updated."
}
# Function to prompt for variable value and export them
ask_value() {
read -p "Enter $1: " value
export "$1=$value"
if [ "$1" == "WORDPRESS_DOMAIN" ]; then
nginx_replace_domain "$value"
fi
}
# Function to set all variables
set_all() {
ask_value "WORDPRESS_DOMAIN"
ask_value "WORDPRESS_DB_NAME"
ask_value "WORDPRESS_DB_USER"
ask_value "WORDPRESS_DB_PASSWORD"
ask_value "WORDPRESS_DB_ROOT_PASSWORD"
ask_value "CERTBOT_EMAIL"
}
# Check if environment variables are set
if [ -z "$WORDPRESS_DOMAIN" ]; then
set_all
echo "Environment variables have been set."
else
echo "Environment variables already exist."
read -p "Do you want to change their values? (y/n): " response
if [ "$response" = "y" ]; then
set_all
echo "Environment variables have been updated."
else
echo "Using existing environment variables."
fi
fi
echo "Domain names in nginx.conf have been updated."