-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
51 lines (51 loc) · 4.71 KB
/
entrypoint.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
45
46
47
48
49
50
51
#!/bin/sh
echo
echo "███╗ ██╗ ██████╗ ██╗███╗ ██╗██╗ ██╗ ██╗ ██╗██████╗ ███████╗████████╗███████╗ █████╗ ███╗ ███╗";
echo "████╗ ██║██╔════╝ ██║████╗ ██║╚██╗██╔╝ ██║ ██║██╔══██╗██╔════╝╚══██╔══╝██╔════╝██╔══██╗████╗ ████║";
echo "██╔██╗ ██║██║ ███╗██║██╔██╗ ██║ ╚███╔╝█████╗██║ ██║██████╔╝███████╗ ██║ █████╗ ███████║██╔████╔██║";
echo "██║╚██╗██║██║ ██║██║██║╚██╗██║ ██╔██╗╚════╝██║ ██║██╔═══╝ ╚════██║ ██║ ██╔══╝ ██╔══██║██║╚██╔╝██║";
echo "██║ ╚████║╚██████╔╝██║██║ ╚████║██╔╝ ██╗ ╚██████╔╝██║ ███████║ ██║ ███████╗██║ ██║██║ ╚═╝ ██║";
echo "╚═╝ ╚═══╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝";
echo " ";
echo "███╗ ███╗██╗ ██╗██████╗ ███████╗██╗ █████╗ ██╗ ██╗██████╗ █████╗ ██████╗ ███████╗";
echo "████╗ ████║╚██╗ ██╔╝██╔══██╗██╔════╝██║ ██╔══██╗╚██╗ ██╔╝██╔══██╗██╔══██╗██╔════╝ ██╔════╝";
echo "██╔████╔██║ ╚████╔╝ ██████╔╝█████╗ ██║ ███████║ ╚████╔╝ ██████╔╝███████║██║ ███╗█████╗ ";
echo "██║╚██╔╝██║ ╚██╔╝ ██╔══██╗██╔══╝ ██║ ██╔══██║ ╚██╔╝ ██╔═══╝ ██╔══██║██║ ██║██╔══╝ ";
echo "██║ ╚═╝ ██║ ██║ ██║ ██║███████╗███████╗██║ ██║ ██║ ██║ ██║ ██║╚██████╔╝███████╗";
echo "╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝";
echo " ";
echo "Getting IP address from $CONTAINER_MYRELAYPAGE ..."
myrelaypage_ip=$(ping -c 1 "$CONTAINER_MYRELAYPAGE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1)
if [ "$myrelaypage_ip" = "Name does not resolve" ]; then
echo ">>> Failed to retrieve IP for $CONTAINER_MYRELAYPAGE ❌"
echo
echo "Please verify if the container $CONTAINER_MYRELAYPAGE is on the same network than container nginx-upsteam-myrelaypage."
echo "Exit."
echo
exit
else
echo ">>> Found IP $myrelaypage_ip ✅"
CONTAINER_MYRELAYPAGE=$myrelaypage_ip
fi
echo
echo "Getting IP address from $CONTAINER_NOSTR_RELAY ..."
nostr_relay_ip=$(ping -c 1 "$CONTAINER_NOSTR_RELAY" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -1)
if [ "$nostr_relay_ip" = "Name does not resolve" ]; then
echo ">>> Failed to retrieve IP for $CONTAINER_NOSTR_RELAY ❌"
echo
echo "Please verify if the container $CONTAINER_NOSTR_RELAY is on the same network than container nginx-upsteam-myrelaypage."
echo "Exit."
echo
exit
else
echo ">>> Found IP $nostr_relay_ip ✅"
CONTAINER_NOSTR_RELAY=$nostr_relay_ip
fi
echo
echo -n "Replacing env with envsubst into nginx conf file ... "
envsubst '$CONTAINER_MYRELAYPAGE $CONTAINER_NOSTR_RELAY' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf
echo "✅"
echo
echo "Starting NGINX ..."
echo
exec "$@"