forked from canonical/lxd-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint
executable file
·38 lines (33 loc) · 1.32 KB
/
entrypoint
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
#! /usr/bin/env bash
set -e
# demo config
if [[ ! -z "$LXD_UI_BACKEND_KEY_PEM" ]]; then
printf %s "$LXD_UI_BACKEND_KEY_PEM" > key.pem
cp haproxy-demo.cfg /tmp/haproxy-local.cfg
sed -i "s#LXD_UI_BACKEND_IP#$LXD_UI_BACKEND_IP#" /tmp/haproxy-local.cfg
sed -i "s#LXD_UI_BACKEND_SECRET#$LXD_UI_BACKEND_SECRET#" /tmp/haproxy-local.cfg
. /usr/local/nvm/nvm.sh
haproxy -f /tmp/haproxy-local.cfg
npx serve --single --no-clipboard -l 3000 build
# dev config
else
cp haproxy-dev.cfg /tmp/haproxy-local.cfg
set -o allexport; source .env; set +o allexport
if [ -f .env.local ]
then
set -o allexport; source .env.local; set +o allexport
fi
sed -i "s#LXD_UI_BACKEND_IP#$LXD_UI_BACKEND_IP#" /tmp/haproxy-local.cfg
# generate certificates for dev environment
if [ ! -d "keys" ]; then
mkdir -p keys
openssl req -nodes -x509 -newkey rsa:2048 -keyout keys/lxd-ui.key -out keys/lxd-ui.crt -subj "/C=GB/ST=London/L=London/O=LXD UI/OU=dev/CN=localhost" -days 3000
openssl dhparam -out keys/dhparams.pem 2048
cat keys/lxd-ui.key keys/lxd-ui.crt > keys/lxd-ui.pem
cp keys/lxd-ui.key keys/lxd-ui.crt.key
echo 'finished generating certificates'
echo 'please add the certificates to your local LXD as explained in README.md'
fi
echo 'booting on https://localhost:8407'
haproxy -f /tmp/haproxy-local.cfg -db
fi