-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsetup.sh
35 lines (28 loc) · 876 Bytes
/
setup.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
#!/bin/bash
function makeAliases() {
ip_address="127.0.0.1"
host_name="$1"
matches_in_hosts="$(grep -n "$host_name" /etc/hosts | cut -f1 -d:)"
host_entry="${ip_address} ${host_name}"
echo "Please enter the password."
if [ -n "$matches_in_hosts" ]
then
echo "Updating existing record."
while read -r line_number; do
sudo sed -i '' "${line_number}s/.*/${host_entry} /" /etc/hosts
done <<< "$matches_in_hosts"
else
echo "Adding new record."
echo "$host_entry" | sudo tee -a /etc/hosts > /dev/null
fi
}
function makeCerts() {
brew install mkcert
mkcert -install
mkdir certs
mkcert -key-file key.pem -cert-file cert.pem "$1"
mv key.pem cert.pem certs
}
domain="localhost" # Change this to your domain: ie. local-app.example.com
makeAliases $domain
makeCerts $domain