Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(node): normalize config.sh to return empty string #3502

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions ic-os/components/misc/config/setupos/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@
# Retrieves a value from the config.json file using a JSON path.
# Arguments:
# $1 - JSON path to the desired value (e.g., '.icos_settings.nns_urls')
# Note: If the key is not found, this function will return null.
# Returns:
# If key is not found or value is "null", returns empty string.
# Otherwise, returns value.
andrewbattat marked this conversation as resolved.
Show resolved Hide resolved
function get_config_value() {
local CONFIG_FILE="/var/ic/config/config.json"
local key=$1
jq -r "${key}" "${CONFIG_FILE}"

local value=$(jq -r "${key}" "${CONFIG_FILE}")

if [[ "${value}" == "null" ]]; then
echo ""
else
echo "${value}"
fi
}
13 changes: 5 additions & 8 deletions ic-os/components/setupos-scripts/check-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,13 @@ function print_network_settings() {
echo "* Printing user defined network settings..."
echo " IPv6 Prefix : ${ipv6_prefix}"
echo " IPv6 Gateway: ${ipv6_gateway}"
if [[ -n ${ipv4_address} && "${ipv4_address}" != "null" &&
-n ${ipv4_prefix_length} && "${ipv4_prefix_length}" != "null" &&
-n ${ipv4_gateway} && "${ipv4_gateway}" != "null" ]]; then

if [[ -n ${ipv4_address} && -n ${ipv4_prefix_length} && -n ${ipv4_gateway} ]]; then
echo " IPv4 Address: ${ipv4_address}"
echo " IPv4 Prefix Length: ${ipv4_prefix_length}"
echo " IPv4 Gateway: ${ipv4_gateway}"
fi
if [[ -n ${domain_name} && "${domain_name}" != "null" ]]; then
if [[ -n ${domain_name} ]]; then
echo " Domain name: ${domain_name}"
fi
echo " "
Expand Down Expand Up @@ -214,13 +213,11 @@ main() {
get_network_settings
print_network_settings

if [[ -n ${domain_name} && "${domain_name}" != "null" ]]; then
if [[ -n ${domain_name} ]]; then
validate_domain_name
fi

if [[ -n ${ipv4_address} && "${ipv4_address}" != "null" &&
-n ${ipv4_prefix_length} && "${ipv4_prefix_length}" != "null" &&
-n ${ipv4_gateway} && "${ipv4_gateway}" != "null" ]]; then
if [[ -n ${ipv4_address} && -n ${ipv4_prefix_length} && -n ${ipv4_gateway} ]]; then
setup_ipv4_network
ping_ipv4_gateway
fi
Expand Down
Loading