Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions imageroot/actions/clone-module/20initialize
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

#
# Copyright (C) 2024 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-3.0-or-later
#

exec 1>&2 # Send any output to stderr, to not alter the action response protocol
set -e

start=$(echo $TCP_PORTS_RANGE | cut -d'-' -f1)

ovpn_udp_port=$start
api_port=$(($start+1))
ui_port=$(($start+2))
proxy_port=$(($start+3))
promtail_port=$(($start+4))
# port 6 and 7 are reserved for loki
# port 8 is reserved for prometheus
# port 9 is reserved for grafana
webssh_port=$(($start+9))
db_port=$(($start+10))

num=$(echo $MODULE_ID | sed 's/nethsecurity\-controller//')

# the port range has changed we must update the ports in the network.env file
cat << EOF > network.env
OVPN_UDP_PORT=$ovpn_udp_port
OVPN_TUN=tunnsc$num
API_PORT=$api_port
API_BIND_IP=127.0.0.1
LISTEN_ADDRESS=127.0.0.1:$api_port
UI_PORT=$ui_port
UI_BIND_IP=127.0.0.1
PROXY_PORT=$proxy_port
PROXY_BIND_UI=127.0.0.1
WEBSSH_PORT=$webssh_port
EOF

# replace the ports in the db.env file
sed -i "s/^POSTGRES_PORT=.*/POSTGRES_PORT=$db_port/" db.env
sed -i "s|^\(REPORT_DB_URI=postgres://report:[^@]*@127.0.0.1:\)[0-9]\{1,\}|\1$db_port|" db.env

mkdir -p clients
1 change: 1 addition & 0 deletions imageroot/actions/clone-module/30configure
Loading