Skip to content

Commit 9c10a64

Browse files
committed
feat(clone-module): replace symlink with new initialization script for port configuration
1 parent f886edd commit 9c10a64

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

imageroot/actions/clone-module/20initialize

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
#
4+
# Copyright (C) 2024 Nethesis S.r.l.
5+
# SPDX-License-Identifier: GPL-3.0-or-later
6+
#
7+
8+
exec 1>&2 # Send any output to stderr, to not alter the action response protocol
9+
set -e
10+
11+
start=$(echo $TCP_PORTS_RANGE | cut -d'-' -f1)
12+
13+
ovpn_udp_port=$start
14+
api_port=$(($start+1))
15+
ui_port=$(($start+2))
16+
proxy_port=$(($start+3))
17+
promtail_port=$(($start+4))
18+
# port 6 and 7 are reserved for loki
19+
# port 8 is reserved for prometheus
20+
# port 9 is reserved for grafana
21+
webssh_port=$(($start+9))
22+
db_port=$(($start+10))
23+
24+
num=$(echo $MODULE_ID | sed 's/nethsecurity\-controller//')
25+
26+
# the port range has changed we must update the ports in the network.env file
27+
cat << EOF > network.env
28+
OVPN_UDP_PORT=$ovpn_udp_port
29+
OVPN_TUN=tunnsc$num
30+
API_PORT=$api_port
31+
API_BIND_IP=127.0.0.1
32+
LISTEN_ADDRESS=127.0.0.1:$api_port
33+
UI_PORT=$ui_port
34+
UI_BIND_IP=127.0.0.1
35+
PROXY_PORT=$proxy_port
36+
PROXY_BIND_UI=127.0.0.1
37+
WEBSSH_PORT=$webssh_port
38+
EOF
39+
40+
# replace the ports in the db.env file
41+
sed -i "s/^POSTGRES_PORT=.*/POSTGRES_PORT=$db_port/" db.env
42+
sed -i "s|^\(REPORT_DB_URI=postgres://report:[^@]*@127.0.0.1:\)[0-9]\{1,\}|\1$db_port|" db.env
43+
44+
mkdir -p clients

0 commit comments

Comments
 (0)