-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·25 lines (19 loc) · 882 Bytes
/
setup.sh
File metadata and controls
executable file
·25 lines (19 loc) · 882 Bytes
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
#!/bin/bash
# Get the new domain from user input
echo "Enter the new development domain name:"
read new_domain
if grep -q "$new_domain" /etc/hosts; then
echo "The given domain already exists. Please choose different one."
else
# Add the new domain to /etc/hosts
echo "127.0.0.1 $new_domain.local" | sudo tee -a /etc/hosts
# Copy the contents from the example env to .env file
cp src/.env.example src/.env | sudo tee -a src/.env
# Replace the existing domain in .env file with the newly created one
sed -i "s/WP_HOME=.*$/WP_HOME='http://$new_domain.local/'" src/.env | sudo tee -a src/.env
# Rebuild and restart the Docker containers
docker compose down -v
docker compose build --no-cache
docker compose up -d
echo "======= Your application has been successfully built. You can access it on http://$new_domain.local ======="
fi