2023-08-09 12:36:03 +02:00
#!/bin/sh
2026-01-12 11:59:58 +01:00
echo "I am a Logos Messaging node"
2023-08-09 12:36:03 +02:00
2024-08-19 20:11:06 +10:00
if [ -n " ${ ETH_CLIENT_ADDRESS } " ] ; then
echo "ETH_CLIENT_ADDRESS variable was renamed to RLN_RELAY_ETH_CLIENT_ADDRESS"
echo "Please update your .env file"
exit 1
2024-06-28 09:21:13 +10:00
fi
2024-06-27 11:42:18 +10:00
if [ -z " ${ RLN_RELAY_ETH_CLIENT_ADDRESS } " ] ; then
2023-09-22 11:45:45 +03:00
echo "Missing Eth client address, please refer to README.md for detailed instructions"
2023-09-21 15:28:39 +03:00
exit 1
fi
2023-08-09 12:36:03 +02:00
MY_EXT_IP = $( wget -qO- https://api4.ipify.org)
2023-09-05 13:13:59 +02:00
DNS_WSS_CMD =
2024-08-16 19:11:37 +10:00
if [ -z " ${ DOMAIN } " ] ; then
2024-08-19 20:11:06 +10:00
echo "auto-domain: DOMAIN is unset, trying to guess it"
2024-08-16 19:11:37 +10:00
# Check if we have an IP
IPCHECK = $( echo " ${ MY_EXT_IP } " | grep -c '^[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+$' )
2024-10-14 16:17:56 +11:00
if [ " ${ IPCHECK } " -ne 1 ] ; then
2024-08-19 20:11:06 +10:00
echo " Failed to get ip, received: ' ${ MY_EXT_IP } ' "
2024-08-16 19:11:37 +10:00
else
2024-08-19 20:11:06 +10:00
echo " auto-domain: ip is ' ${ MY_EXT_IP } ' "
2024-08-16 19:11:37 +10:00
# Get reverse DNS
DNS = $( dig +short -x " ${ MY_EXT_IP } " )
# Check if looks like a DNS
DNSCHECK = $( echo " ${ DNS } " | grep -c '^\([a-zA-Z0-9_\-]\+\.\)\+$' )
2024-10-14 16:17:56 +11:00
if [ " ${ DNSCHECK } " -ne 1 ] ; then
2024-08-16 19:11:37 +10:00
echo " Failed to get DNS, received: ' ${ DNS } ' "
else
2024-08-19 20:11:06 +10:00
DOMAIN = $( echo " ${ DNS } " | sed s/\. $//)
echo " auto-domain: DOMAIN deduced and set to ${ DOMAIN } "
# Double check the domain is setup to return right IP
# OpenDNS servers are used to bypass /etc/hosts as it may return loopback address
DNS_IP = $( dig +short @208.67.222.222 " ${ DNS } " )
if [ " ${ DNS_IP } " != " ${ MY_EXT_IP } " ] ; then
echo " auto-domain: DNS queried returned a different ip: ' ${ DNS_IP } ', unsetting DOMAIN "
unset DOMAIN
else
echo " auto-domain: last verification successful, DOMAIN= ${ DOMAIN } "
fi
fi
2024-08-16 19:11:37 +10:00
fi
fi
2023-09-05 13:13:59 +02:00
if [ -n " ${ DOMAIN } " ] ; then
2026-01-12 09:53:46 +01:00
## A domain has been either set or inferred. Let's try to use it for websocket secure support.
2023-09-05 13:13:59 +02:00
2026-01-12 09:53:46 +01:00
apk add --no-cache openssl
2023-09-05 13:13:59 +02:00
2026-01-12 09:53:46 +01:00
LETSENCRYPT_PATH = " /etc/letsencrypt/live/ ${ DOMAIN } "
CERT = " ${ LETSENCRYPT_PATH } /fullchain.pem "
KEY = " ${ LETSENCRYPT_PATH } /privkey.pem "
2023-09-05 13:13:59 +02:00
2026-01-12 09:53:46 +01:00
echo " $( date '+%Y-%m-%d %H:%M:%S' ) [INFO] Waiting for a valid TLS certificate for ${ DOMAIN } ... "
2023-09-05 13:13:59 +02:00
2026-01-12 09:53:46 +01:00
while true; do
if [ ! -f " ${ CERT } " ] || [ ! -f " ${ KEY } " ] ; then
echo " $( date '+%Y-%m-%d %H:%M:%S' ) [INFO] Certificate files not found yet. Waiting... "
elif ! openssl x509 -checkend 0 -noout -in " ${ CERT } " >/dev/null 2>& 1; then
echo " $( date '+%Y-%m-%d %H:%M:%S' ) [WARN] Certificate exists but is expired. Waiting for renewal... "
echo " $( date '+%Y-%m-%d %H:%M:%S' ) [INFO] If that takes more than 15 minutes, please remove --quiet attr in run_certbot.sh so that you can see the reason why renewal is not working. "
else
echo " $( date '+%Y-%m-%d %H:%M:%S' ) [INFO] Valid TLS certificate detected. "
break
fi
2023-09-05 13:13:59 +02:00
2026-01-12 09:53:46 +01:00
sleep 60
done
WS_SUPPORT = "--websocket-support=true"
WSS_SUPPORT = "--websocket-secure-support=true"
WSS_KEY = " --websocket-secure-key-path= ${ KEY } "
WSS_CERT = " --websocket-secure-cert-path= ${ CERT } "
DNS4_DOMAIN = " --dns4-domain-name= ${ DOMAIN } "
DNS_WSS_CMD = " ${ WS_SUPPORT } ${ WSS_SUPPORT } ${ WSS_CERT } ${ WSS_KEY } ${ DNS4_DOMAIN } "
2023-09-05 13:13:59 +02:00
fi
2026-01-12 09:53:46 +01:00
2023-09-22 11:45:45 +03:00
if [ -n " ${ NODEKEY } " ] ; then
2023-09-05 13:13:59 +02:00
NODEKEY = --nodekey= ${ NODEKEY }
fi
2023-08-09 12:36:03 +02:00
2023-09-22 11:45:45 +03:00
if [ -n " ${ RLN_RELAY_CRED_PASSWORD } " ] ; then
2024-01-09 16:12:20 +05:30
RLN_RELAY_CRED_PASSWORD = --rln-relay-cred-password= " ${ RLN_RELAY_CRED_PASSWORD } "
2025-07-29 02:37:45 +02:00
## Enable Light Push (RLNaaS) if RLN credentials are used
LIGHTPUSH = --lightpush= true
## Pass default value for credentials path if not set
RLN_RELAY_CRED_PATH = --rln-relay-cred-path= ${ RLN_RELAY_CRED_PATH :- /keystore/keystore.json }
echo " Using RLN credentials from ${ RLN_RELAY_CRED_PATH } "
else
LIGHTPUSH = --lightpush= false
# Ensure no empty values are passed
RLN_RELAY_CRED_PATH = ""
RLN_RELAY_CRED_PASSWORD = ""
2023-09-22 11:45:45 +03:00
fi
2025-07-29 02:37:45 +02:00
2024-03-15 14:22:58 +01:00
STORE_RETENTION_POLICY = --store-message-retention-policy= size:1GB
2024-03-14 10:05:57 +01:00
if [ -n " ${ STORAGE_SIZE } " ] ; then
STORE_RETENTION_POLICY = --store-message-retention-policy= size:" ${ STORAGE_SIZE } "
fi
2023-08-09 12:36:03 +02:00
exec /usr/bin/wakunode\
2024-08-19 20:11:06 +10:00
--relay= true\
--filter= true\
2025-09-12 13:36:48 +05:30
--peer-exchange= true\
2025-07-29 02:37:45 +02:00
${ LIGHTPUSH } \
2024-08-19 20:11:06 +10:00
--keep-alive= true\
--max-connections= 150\
--cluster-id= 1\
--discv5-discovery= true\
--discv5-udp-port= 9005\
--discv5-enr-auto-update= True\
--log-level= DEBUG\
--tcp-port= 30304\
--metrics-server= True\
--metrics-server-port= 8003\
--metrics-server-address= 0.0.0.0\
--rest= true\
--rest-admin= true\
--rest-address= 0.0.0.0\
--rest-port= 8645\
2026-01-12 11:59:58 +01:00
--rest-allow-origin= "logos-messaging.github.io" \
2024-08-19 20:11:06 +10:00
--rest-allow-origin= "localhost:*" \
--nat= extip:" ${ MY_EXT_IP } " \
--store= true\
--store-message-db-url= " postgres:// ${ POSTGRES_USER } : ${ POSTGRES_PASSWORD } @postgres:5432/postgres " \
--rln-relay-eth-client-address= " ${ RLN_RELAY_ETH_CLIENT_ADDRESS } " \
2025-07-29 02:37:45 +02:00
${ RLN_RELAY_CRED_PATH } \
${ RLN_RELAY_CRED_PASSWORD } \
2024-08-19 20:11:06 +10:00
${ DNS_WSS_CMD } \
${ NODEKEY } \
${ STORE_RETENTION_POLICY } \
${ EXTRA_ARGS }
2023-09-05 13:13:59 +02:00