-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node): Configuration revamp (SetupOS integration) (#3270)
NODE-1360 The IC-OS tool has been created, but not yet used by the IC-OS: #1539 This PR integrates the config tool into SetupOS. The config tool is utilized for config sanitization, organization, and access. Note that the *old* config is still being passed to HostOS, so this PR should have no impact on HostOS or GuestOS
- Loading branch information
1 parent
1ed522a
commit 36e2b45
Showing
20 changed files
with
276 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Shared config utilities. | ||
|
||
# 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. | ||
function get_config_value() { | ||
local CONFIG_FILE="/var/ic/config/config.json" | ||
local key=$1 | ||
jq -r "${key}" "${CONFIG_FILE}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
# check-config.sh verifies the existence of the configuration JSON file created by config.service, | ||
# halting the installation if not found. | ||
|
||
set -o nounset | ||
set -o pipefail | ||
|
||
SHELL="/bin/bash" | ||
PATH="/sbin:/bin:/usr/sbin:/usr/bin" | ||
|
||
source /opt/ic/bin/functions.sh | ||
|
||
check_config_file() { | ||
echo "* Checking Config..." | ||
local CONFIG_FILE="/var/ic/config/config.json" | ||
|
||
if [ -f "${CONFIG_FILE}" ]; then | ||
local config_contents=$(cat "${CONFIG_FILE}") | ||
echo -e "Configuration file '${CONFIG_FILE}' exists.\n" | ||
echo -e "File contents:\n${config_contents}" | ||
else | ||
local service_logs=$(journalctl -u config.service --no-pager) | ||
local log_message="Error creating SetupOS configuration. Configuration file '${CONFIG_FILE}' does not exist.\n\nConfig.service logs:\n${service_logs}" | ||
|
||
log_and_halt_installation_on_error 1 "${log_message}" | ||
fi | ||
} | ||
|
||
# Establish run order | ||
main() { | ||
log_start "$(basename $0)" | ||
check_config_file | ||
log_end "$(basename $0)" | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.