diff --git a/docker-configs/docker-compose.yml b/docker-configs/docker-compose.yml index 1cda66f..4437217 100644 --- a/docker-configs/docker-compose.yml +++ b/docker-configs/docker-compose.yml @@ -84,6 +84,7 @@ services: FREEDMR_GATEWAY_INGRESS_MODE: fbp FREEDMR_GATEWAY_FBP_RELATIONSHIPS: '__FREEDMR_GATEWAY_FBP_RELATIONSHIPS__' FREEDMR_GATEWAY_FBP_RELATIONSHIPS_FILE: /config/data-gateway-relationships.json + FREEDMR_GATEWAY_FBP_SOURCE_SERVER_ID: '__FREEDMR_GATEWAY_FBP_SOURCE_SERVER_ID__' FREEDMR_GATEWAY_RADIOID_PATH: /data/subscriber_ids.json FREEDMR_GATEWAY_APRS_HOST: rotate.aprs2.net FREEDMR_GATEWAY_APRS_PORT: '14580' diff --git a/docker-configs/docker-compose_install.sh b/docker-configs/docker-compose_install.sh index 2f1079b..e5523fd 100644 --- a/docker-configs/docker-compose_install.sh +++ b/docker-configs/docker-compose_install.sh @@ -317,6 +317,7 @@ sed -i "s|^[[:space:]]*#*- HDSTACK=.*| - HDSTACK=$HDSTACK_COUNT|" "$C sed -i "s|^[[:space:]]*#*- HDSTACK_BASEID=.*| - HDSTACK_BASEID=$HDSTACK_BASEID|" "$CONFIG_DIR/docker-compose.yml" sed -i "s|^[[:space:]]*- HDSTACK_BRIDGE=.*| - HDSTACK_BRIDGE=$HDSTACK_BRIDGE_VALUE|" "$CONFIG_DIR/docker-compose.yml" sed -i "s|__FREEDMR_GATEWAY_FBP_RELATIONSHIPS__|$FREEDMR_GATEWAY_FBP_RELATIONSHIPS|" "$CONFIG_DIR/docker-compose.yml" +sed -i "s|__FREEDMR_GATEWAY_FBP_SOURCE_SERVER_ID__|$HDSTACK_BASEID|" "$CONFIG_DIR/docker-compose.yml" sed -i "s|__FREEDMR_GATEWAY_APRS_LOGIN_CALL__|$FREEDMR_GATEWAY_APRS_LOGIN_CALL|" "$CONFIG_DIR/docker-compose.yml" sed -i "s|__FREEDMR_GATEWAY_APRS_PASSCODE__|$FREEDMR_GATEWAY_APRS_PASSCODE|" "$CONFIG_DIR/docker-compose.yml" printf '%s\n' "$FREEDMR_GATEWAY_FBP_RELATIONSHIPS" > \ diff --git a/docker-configs/upgrade-daprs-to-data-gateway.sh b/docker-configs/upgrade-daprs-to-data-gateway.sh index 7caf2f9..f2d0f24 100755 --- a/docker-configs/upgrade-daprs-to-data-gateway.sh +++ b/docker-configs/upgrade-daprs-to-data-gateway.sh @@ -484,7 +484,7 @@ awk -v gateway_key="$FBP_KEY" \ if [ "$native_count" -eq 0 ] then - awk -v relationships="$RELATIONSHIPS" -v aprs_call="$APRS_CALL" -v aprs_passcode="$APRS_PASSCODE" ' + awk -v relationships="$RELATIONSHIPS" -v base_id="$BASE_ID" -v aprs_call="$APRS_CALL" -v aprs_passcode="$APRS_PASSCODE" ' function print_gateway() { print " data-gateway:" print " container_name: freedmr-data-gateway" @@ -503,6 +503,7 @@ then print " FREEDMR_GATEWAY_INGRESS_MODE: fbp" print " FREEDMR_GATEWAY_FBP_RELATIONSHIPS: \047" relationships "\047" print " FREEDMR_GATEWAY_FBP_RELATIONSHIPS_FILE: /config/data-gateway-relationships.json" + print " FREEDMR_GATEWAY_FBP_SOURCE_SERVER_ID: \047" base_id "\047" print " FREEDMR_GATEWAY_RADIOID_PATH: /data/subscriber_ids.json" print " FREEDMR_GATEWAY_APRS_HOST: rotate.aprs2.net" print " FREEDMR_GATEWAY_APRS_PORT: \04714580\047" @@ -555,9 +556,10 @@ else fi COMPOSE_WITH_RELATIONSHIPS_FILE="$WORK_DIR/docker-compose.with-relationships-file.yml" -awk ' +awk -v base_id="$BASE_ID" ' function flush_gateway( i, inline_index, volumes_index, networks_index, - file_seen, mount_seen, list_environment) { + environment_index, file_seen, mount_seen, + source_seen, list_environment) { if (!gateway_count) return for (i = 1; i <= gateway_count; i++) { @@ -570,6 +572,10 @@ awk ' } if (gateway[i] ~ /FREEDMR_GATEWAY_FBP_RELATIONSHIPS_FILE/) file_seen = 1 + if (gateway[i] ~ /FREEDMR_GATEWAY_FBP_SOURCE_SERVER_ID/) + source_seen = 1 + if (gateway[i] ~ /^[[:space:]]*environment:[[:space:]]*$/) + environment_index = i if (gateway[i] ~ /^[[:space:]]*volumes:[[:space:]]*$/) volumes_index = i if (gateway[i] ~ /^[[:space:]]*networks:[[:space:]]*$/ && !networks_index) @@ -587,6 +593,12 @@ awk ' print " - \047/etc/freedmr/data-gateway-relationships.json:/config/data-gateway-relationships.json:ro\047" } print gateway[i] + if (!source_seen && environment_index == i) { + if (list_environment) + print " - FREEDMR_GATEWAY_FBP_SOURCE_SERVER_ID=" base_id + else + print " FREEDMR_GATEWAY_FBP_SOURCE_SERVER_ID: \047" base_id "\047" + } if (!file_seen && inline_index == i) { if (list_environment) print " - FREEDMR_GATEWAY_FBP_RELATIONSHIPS_FILE=/config/data-gateway-relationships.json" diff --git a/tests/test_data_gateway_upgrade.py b/tests/test_data_gateway_upgrade.py index a0a3101..b0b8fa4 100644 --- a/tests/test_data_gateway_upgrade.py +++ b/tests/test_data_gateway_upgrade.py @@ -99,6 +99,9 @@ class DataGatewayUpgradeTests(unittest.TestCase): self.assertIn(" freedmrmonitor2:\n", compose) self.assertIn("FREEDMR_GATEWAY_APRS_LOGIN_CALL: 'M0OLD'", compose) self.assertIn("FREEDMR_GATEWAY_APRS_PASSCODE: '54321'", compose) + self.assertIn( + "FREEDMR_GATEWAY_FBP_SOURCE_SERVER_ID: '23400'", compose + ) relationships = self._relationships(compose) self.assertEqual( diff --git a/tests/test_hdstack.py b/tests/test_hdstack.py index cd6ea43..6cb4738 100644 --- a/tests/test_hdstack.py +++ b/tests/test_hdstack.py @@ -504,6 +504,7 @@ class HDStackContainerTests(unittest.TestCase): self.assertNotIn("freedmr-data-gateway:development-latest", compose) self.assertIn("FREEDMR_GATEWAY_INGRESS_MODE: fbp", compose) self.assertIn("FREEDMR_GATEWAY_FBP_RELATIONSHIPS:", compose) + self.assertIn("FREEDMR_GATEWAY_FBP_SOURCE_SERVER_ID:", compose) self.assertIn("/etc/freedmr/json/:/data/:ro", compose) self.assertIn("FREEDMR_ALLOW_UNMIGRATED_START=1", compose) @@ -523,6 +524,10 @@ class HDStackContainerTests(unittest.TestCase): self.assertIn('- HDSTACK=$HDSTACK_COUNT', installer) self.assertIn('- HDSTACK_BASEID=$HDSTACK_BASEID', installer) self.assertIn('- HDSTACK_BRIDGE=$HDSTACK_BRIDGE_VALUE', installer) + self.assertIn( + '__FREEDMR_GATEWAY_FBP_SOURCE_SERVER_ID__|$HDSTACK_BASEID', + installer, + ) self.assertIn("prompt_value 'APRS-IS login callsign'", installer) self.assertIn("prompt_value 'APRS-IS passcode'", installer) self.assertIn('build_data_gateway_relationships', installer)