-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy.sh
44 lines (37 loc) · 1.04 KB
/
deploy.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
39
40
41
42
43
44
#!/bin/bash
help()
{
echo ""
echo "Usage: $0 -u username -d mydomain.com"
echo -e "\t-u bento.me username (bento.me/<username>)"
echo -e "\t-d Domain name (mydomain.com)"
echo -e "\t-h Prints script usage help"
exit 1
}
while getopts "u:d:h" opt
do
case "$opt" in
u ) u="$OPTARG" ;;
d ) d="$OPTARG" ;;
h ) help ;;
? ) help ;; # prints help command for non-existing parameters
esac
done
# if no parameters
if [ -z "$u" ] || [ -z "$d" ]
then
echo "❓ One or more parameters are missing. Please, check the script help below.";
help
fi
# remove the old nginx config file if exists
printf "🗑️ Removing the old nginx.conf file...\n"
rm -f nginx.conf
# replace the variables in the nginx config file
printf "Replacing variables in nginx.conf file...\n"
sed "s|<DOMAIN>|$d|g; s|<USERNAME>|$u|g" nginx.conf.example > nginx.conf
# deploy the app
printf "🚀 Deploying the app...\n"
flyctl launch --copy-config
# issue SSL certificate
printf "🔐 Issuing SSL certificate...\n"
flyctl certs add $d -c ./fly.toml