2021-09-20 19:45:38 +03:00
|
|
|
#!/bin/bash
|
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
# Licensed under the Apache 2.0 License.
|
|
|
|
|
|
|
|
# The purpose of this script is to wrap the launch of a CCF node
|
|
|
|
# when the IP address of the node isn't known in advance
|
|
|
|
# (e.g. dynamically launched container).
|
2023-02-14 18:28:30 +03:00
|
|
|
# This sets the node address and published RPC address configuration entries
|
2021-09-20 19:45:38 +03:00
|
|
|
# based on the IP address of the container (it assumes that the container
|
|
|
|
# is connected to service-specific network)
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
cmd=$*
|
|
|
|
container_ip=$(hostname -i | cut -d " " -f 2) # Network container IP address
|
|
|
|
|
2023-02-14 18:28:30 +03:00
|
|
|
# Node makes use of configuration file (2.x nodes)
|
|
|
|
container_ip_replace_str="CONTAINER_IP"
|
|
|
|
config_file_path="$(echo "${cmd}" | grep -o -P "(?<=--config).*" | cut -d " " -f 2)"
|
|
|
|
sed --follow-symlinks -i -e "s/${container_ip_replace_str}/${container_ip}/g" "${config_file_path}"
|
2021-09-20 19:45:38 +03:00
|
|
|
|
|
|
|
eval "${cmd}"
|