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

feat(node): Configuration revamp (GuestOS integration) #1563

Draft
wants to merge 286 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
286 commits
Select commit Hold shift + click to select a range
59e327f
Fix networking read_config_variables
andrewbattat Oct 3, 2024
e8335eb
Fix generate-guestos-config sourcing
andrewbattat Oct 3, 2024
af9a7fb
Fix file path bug
andrewbattat Oct 4, 2024
17c7926
Revert nns_url naming
andrewbattat Oct 4, 2024
08aa0a4
Revert additional urls reference
andrewbattat Oct 4, 2024
7f18d53
Fix bug in GenerateMacAddress
andrewbattat Oct 4, 2024
0d11498
Fix nns_url jq call
andrewbattat Oct 4, 2024
58bedec
Add comment for get_ipmi_mac error log
andrewbattat Oct 4, 2024
fba751c
Revert change to ipmitool error parsing
andrewbattat Oct 4, 2024
575f73f
Add hostos_config_path variable
andrewbattat Oct 4, 2024
6aaf9c3
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 4, 2024
cab3719
Remove extra function.sh calls from merge
andrewbattat Oct 4, 2024
0e1d9bd
Reorganize sourcing in setupos scripts
andrewbattat Oct 4, 2024
cd15138
Remove unnecessary setup-hostname logic
andrewbattat Oct 7, 2024
5385e7e
Log config.json in log-config.sh
andrewbattat Oct 7, 2024
e0af9fa
Remove copying config.ini and deployment.json to HostOS
andrewbattat Oct 7, 2024
92c5213
Fix CONFIG name in log-config
andrewbattat Oct 7, 2024
426c176
Remove unused HostOS config constants
andrewbattat Oct 7, 2024
a1b5755
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 7, 2024
e2d0d83
Replace fetch-mgmt-mac.sh with hostos_tool command
andrewbattat Oct 7, 2024
0bfe363
Fix hostos_tool after merge
andrewbattat Oct 7, 2024
7b0c771
Revert nns_url renaming
andrewbattat Oct 8, 2024
63b0d12
Rename nns_url_list
andrewbattat Oct 8, 2024
2c3e077
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 8, 2024
71cdcc8
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 9, 2024
a933b39
Add missing check-config.sh in setupos
andrewbattat Oct 9, 2024
3f10503
Add check-config file description
andrewbattat Oct 9, 2024
b8317db
Update check-config.sh comment
andrewbattat Oct 9, 2024
615d3d6
Add guestos config object to guestos config
andrewbattat Oct 9, 2024
71079e2
Add guestos config.sh and reorganize and rename config scripts
andrewbattat Oct 9, 2024
455ad95
Remove conf scripts from generate-replica-config inputs except networ…
andrewbattat Oct 9, 2024
e580545
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 9, 2024
f3a8adb
Fix pre-commit
andrewbattat Oct 10, 2024
29721d1
Make config_file optional for ic-crypto-csp service to run successfully
andrewbattat Oct 10, 2024
c0c1f7d
Fix ipv4 address setting
andrewbattat Oct 10, 2024
da38336
Fix pre-commit
andrewbattat Oct 10, 2024
3b6ace5
Make config non-optional to fix ic-crypto-csp failure
andrewbattat Oct 10, 2024
c6fa4a6
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 10, 2024
1325e00
Remove config input to generate-replica-config
andrewbattat Oct 10, 2024
8703c28
Use config object for generate-filebeat-config.sh
andrewbattat Oct 10, 2024
1cc5d80
Move generate-btc-adapter-config and generate-https-outcalls-adapter-…
andrewbattat Oct 10, 2024
2d1121f
Remove outstanding guestos conf files
andrewbattat Oct 10, 2024
7204e18
Remove outdated comment
andrewbattat Oct 14, 2024
c379217
Update setup-ssh-account-keys to use the config object
andrewbattat Oct 14, 2024
4b0c75c
Remove old config from build-bootstrap
andrewbattat Oct 14, 2024
f7c6379
Clean up build-bootstrap-config-image.sh
andrewbattat Oct 14, 2024
5758e4b
Organize build-bootstrap-config-image
andrewbattat Oct 14, 2024
114b07a
Remove unnecessary elastic-search argument
andrewbattat Oct 14, 2024
beacf9f
Remove unnecessary nns_url parameter
andrewbattat Oct 14, 2024
4c7c35d
Reorganize build-bootstrap-config-image parameters
andrewbattat Oct 14, 2024
30e8f3c
Update filebeat comment
andrewbattat Oct 15, 2024
b9abed9
Add note on config.sh return values
andrewbattat Oct 15, 2024
37697fa
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 16, 2024
0dff434
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 16, 2024
8ebb285
Fix ic-btc-mainnet-adapter.service
andrewbattat Oct 16, 2024
ff8f911
Fix generate-filebeat-config.sh
andrewbattat Oct 16, 2024
4226469
Fix generate-filebeat-config.sh
andrewbattat Oct 16, 2024
4050a6e
Update generate-replica-config.sh to not use network.conf
andrewbattat Oct 16, 2024
c4104f3
Fix guestos-ipv6-address agument
andrewbattat Oct 16, 2024
b9e508e
Update setup-hostname.sh to use config object
andrewbattat Oct 16, 2024
b68e457
Convert fixed ipv6 address to a String
andrewbattat Oct 16, 2024
f237d01
Fix config.sh comment
andrewbattat Oct 16, 2024
bfe38ac
Refactor generate-replica-config
andrewbattat Oct 16, 2024
30353a4
Reorganize function ordering
andrewbattat Oct 16, 2024
542537c
Create set_default_config_values
andrewbattat Oct 16, 2024
6ac4aae
Fix generate-filebeat-config
andrewbattat Oct 16, 2024
94c889a
Fix get_config_value for ipv6_config
andrewbattat Oct 16, 2024
5341a68
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 17, 2024
b24be33
Fix node_ID bug
andrewbattat Oct 17, 2024
06b9daa
Remove network.conf from guestos config
andrewbattat Oct 17, 2024
4b8da4a
Add mgmt_mac to ICOSSettings and rename deployment_environment
andrewbattat Oct 17, 2024
9878ae0
Create mac_address crate to fix cyclic dependency between network and…
andrewbattat Oct 17, 2024
e213948
Consolidate setup-hostname.sh and use config object hostname
andrewbattat Oct 17, 2024
f65556e
Delete unused FetchMacAddress command
andrewbattat Oct 17, 2024
3487162
Fix reference to mac_address crate
andrewbattat Oct 17, 2024
77817d3
Remove colons in mgmt_mac
andrewbattat Oct 17, 2024
6779607
Fix buildifier
andrewbattat Oct 18, 2024
ddb37cf
Add type description
andrewbattat Oct 18, 2024
248abc5
Remove unnecessary network.conf references
andrewbattat Oct 18, 2024
1014760
Update guestos_tool to use the config object
andrewbattat Oct 18, 2024
3da367a
Remove old, unnecessary todo
andrewbattat Oct 18, 2024
468b9a9
Update bootstrap-ic-node comment
andrewbattat Oct 18, 2024
d11c584
Update GuestOS config partition documentation
andrewbattat Oct 18, 2024
0f7c637
Use malicious_behavior in config_tool
andrewbattat Oct 18, 2024
913a49e
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 21, 2024
4ee764e
Create GenerateTestnetConfig config command
andrewbattat Oct 21, 2024
fa2ddfa
Fix default config values
andrewbattat Oct 21, 2024
a9968f7
Construct guestos config object from launch-single-vm
andrewbattat Oct 21, 2024
e61ca1d
Pass guestos-config to build-bootstrap
andrewbattat Oct 22, 2024
223e12c
Fix configure_ipv6
andrewbattat Oct 22, 2024
67a8aff
Move launch-single-vm to use config_tool
andrewbattat Oct 22, 2024
7bc2270
Update config documentation
andrewbattat Oct 22, 2024
ea6a2ac
process_nns_urls
andrewbattat Oct 22, 2024
477fcee
Update == HostOS -> GuestOS config documentation
andrewbattat Oct 22, 2024
b5432c3
Fix filebeat service
andrewbattat Oct 22, 2024
11e5ac2
Fix MALICIOUS_BEHAVIOR generate-replica-config
andrewbattat Oct 22, 2024
02a3c3a
Remove unnecessary TODO
andrewbattat Oct 22, 2024
6ccef25
Remove testing logic and clean up launch-single-vm
andrewbattat Oct 22, 2024
07156b3
Remove unused import
andrewbattat Oct 22, 2024
ed8771d
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 23, 2024
c542e26
Update Testing configuration documentation
andrewbattat Oct 23, 2024
20db7ac
Fix IPV6_ADDRESS generate-replica-config
andrewbattat Oct 23, 2024
b138af6
Update farm to use new config tool
andrewbattat Oct 23, 2024
63c199b
Update call to generate_testnet_config
andrewbattat Oct 23, 2024
4389311
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 23, 2024
ceb6724
Automatically updated Cargo*.lock
Oct 23, 2024
0e7d62d
Fix config library visibility
andrewbattat Oct 23, 2024
9c57123
Merge branch 'andrew/config-revamp-integration' of github.com:dfinity…
andrewbattat Oct 23, 2024
5c67331
Fix call to build-bootstrap-config-image
andrewbattat Oct 23, 2024
5da81fc
Fix config construction
andrewbattat Oct 23, 2024
af7ce6c
Fix pre-commit and buildifier
andrewbattat Oct 23, 2024
6e5969d
Fix ssh access
andrewbattat Oct 23, 2024
1b92686
Remove unnecessary process_nns_urls function
andrewbattat Oct 24, 2024
a6810fb
Clean up comments
andrewbattat Oct 24, 2024
5f67134
Add GenerateGuestosConfig comment
andrewbattat Oct 25, 2024
8bf4e30
Move guestos_config_json_path to be a separate parameter
andrewbattat Oct 25, 2024
0c0051b
Add hostname field to config types
andrewbattat Oct 25, 2024
b22fef7
rename inject config values and make bool
andrewbattat Oct 25, 2024
2294217
Update config.sh config references
andrewbattat Oct 25, 2024
a2d6ed0
Rename nns_public_key_exists and node_operator_private_key_exists and…
andrewbattat Oct 28, 2024
3ccd4bf
Update use_ssh_authorized_keys to bool
andrewbattat Oct 28, 2024
f8a367f
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 28, 2024
c6c7d67
Uncomment setupos.sh scripts
andrewbattat Oct 28, 2024
f7d1028
Fix reference to node_operator_private_key.pem
andrewbattat Oct 28, 2024
1c21cc5
Fix reference to ssh_authorized_keys
andrewbattat Oct 28, 2024
af1ad07
Convert ipv6_config_type to Enum
andrewbattat Oct 29, 2024
3148be6
Add generate_testnet_config validation tests
andrewbattat Oct 29, 2024
74f6eb7
Expand comment for GenerateTestnetConfig
andrewbattat Oct 29, 2024
a9135de
Add CONFIG_VERSION to track versions backwards compatibility
andrewbattat Oct 30, 2024
6830e55
Update config unit test
andrewbattat Oct 30, 2024
2921ed1
Add Configuration Update Protocol
andrewbattat Oct 30, 2024
02c5e3e
Update types.rs documentation
andrewbattat Oct 30, 2024
16ff02f
Remove unnecessary deployment.template unit tests
andrewbattat Oct 30, 2024
7181376
Update configuration guidance
andrewbattat Oct 30, 2024
0f19571
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Oct 31, 2024
8ca8583
Add generate_ic_boundary_tls_cert to GuestOSDevSettings
andrewbattat Oct 31, 2024
5c53903
Fix bootstrap.rs
andrewbattat Oct 31, 2024
be133cc
Fix ic-boundary-tls output paths
andrewbattat Oct 31, 2024
a725e93
Add generate_ic_boundary_tls_cert to config unit test
andrewbattat Nov 1, 2024
b098aac
Uncouple domain_name from ipv4_config
andrewbattat Nov 1, 2024
3f398e8
Update testing to fix calls to domain_name
andrewbattat Nov 1, 2024
d22f2ac
Fix TLS_KEY_PATH and TLS_CERT_PATH file permissions
andrewbattat Nov 1, 2024
ef59cfc
Fix reference to config domain_name
andrewbattat Nov 1, 2024
74a6b2b
Add guestos log-config
andrewbattat Nov 4, 2024
a22722f
Depend log-config-guestos.service on bootstrap-ic-node.service
andrewbattat Nov 4, 2024
af0af1f
Move config_version to *OSConfig structs
andrewbattat Nov 5, 2024
b41564c
Re-add deployment.json and config.ini copying to hostos config
andrewbattat Nov 5, 2024
4ccc351
Update config policy documentation
andrewbattat Nov 5, 2024
24469ae
Fix cargo clippy
andrewbattat Nov 5, 2024
2cf9743
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Nov 6, 2024
9af8e04
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Nov 6, 2024
72e2e8e
Fix copy_config_files
andrewbattat Nov 6, 2024
4edc4a7
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Nov 12, 2024
87ebfaf
Fix generate-ic-config.sh
andrewbattat Nov 12, 2024
1dc0b39
Fix generate-ic-config.service
andrewbattat Nov 12, 2024
ece61d6
Remove config.sh reference
andrewbattat Nov 12, 2024
e244247
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Nov 12, 2024
b6eb0a5
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Nov 14, 2024
2546a94
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Nov 14, 2024
a29cf53
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Nov 15, 2024
13c7f56
Add node_reward_type to config tool
andrewbattat Nov 15, 2024
c744a6c
Add node_reward_type regex check
andrewbattat Nov 15, 2024
afc6da0
Remove validate_node_reward
andrewbattat Nov 15, 2024
f876bce
Remove node_reward_type from static testnets
andrewbattat Nov 15, 2024
5c1d00a
Make node_reward_type an optional
andrewbattat Nov 15, 2024
8e2cf63
Add node_reward_type to farm and launch-single-vm config constructs
andrewbattat Nov 15, 2024
7ab4f30
Correct reference to NODE-1519
andrewbattat Nov 19, 2024
4edc622
Pass old hostOS config to guestos
andrewbattat Nov 19, 2024
d1b3552
fix build-bootstrap formatting
andrewbattat Nov 19, 2024
004c795
Fix build-bootstrap syntax
andrewbattat Nov 19, 2024
4f3e848
Fix build-bootsrap syntax
andrewbattat Nov 19, 2024
1a0a69b
Fix build-bootsrap syntax
andrewbattat Nov 19, 2024
cba4b83
Fix lingering issues with passing config to guestos
andrewbattat Nov 19, 2024
a55644b
Fix generate-guestos-config syntax
andrewbattat Nov 20, 2024
498a8c2
Remove unused generate_ic_boundary_tls_cert field
andrewbattat Nov 20, 2024
8fc55e0
Fix hostname config
andrewbattat Nov 20, 2024
74ba483
Fix hostname old config
andrewbattat Nov 20, 2024
4c18db7
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Nov 20, 2024
ad967b9
Rename use_nns_public_key and use_node_operator_private_key
andrewbattat Nov 20, 2024
8bab788
Update references to use_node_operator_private_key and use_nns_public…
andrewbattat Nov 20, 2024
b7c9681
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Nov 22, 2024
b4151b2
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Nov 22, 2024
32fa307
Add config_types crate to os_tools
andrewbattat Nov 22, 2024
ba38598
Automatically updated Cargo*.lock
Nov 22, 2024
d4633d9
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Nov 27, 2024
85cb29a
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Dec 4, 2024
8e487c1
Fix hostos and setupos tools
andrewbattat Dec 4, 2024
09e2a42
FIx guestos tool after merge
andrewbattat Dec 4, 2024
af98dc2
Fix crate imports in test driver
andrewbattat Dec 4, 2024
914c731
Fix path to config
andrewbattat Dec 4, 2024
ef0881e
Fix testing
andrewbattat Dec 4, 2024
62e2c2b
Fix launch-single-vm crate imports
andrewbattat Dec 4, 2024
4074f6d
Remove old config parsing in generate-guestos-config
andrewbattat Dec 4, 2024
6d99f3c
Fix generate-guestos-config
andrewbattat Dec 4, 2024
a8579b3
Remove FetchMacAddress command
andrewbattat Dec 4, 2024
1011790
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Dec 5, 2024
0390f07
Update configuration documentation
andrewbattat Dec 5, 2024
b0e1c8e
Add back node_reward_type to static testnet
andrewbattat Dec 5, 2024
d7249e0
Add back old config constants
andrewbattat Dec 5, 2024
7f0aac5
Remove duplicate release:config file install
andrewbattat Dec 5, 2024
4444e1c
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Dec 6, 2024
1c47e79
Remove mercury targets from unit tests
andrewbattat Dec 6, 2024
326bfcf
Add node-reward-type default to setupos-inject-config
andrewbattat Dec 6, 2024
f716d97
Allow empty hostname in GuestOS
andrewbattat Dec 6, 2024
be86b90
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Dec 6, 2024
8a9a31e
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Dec 9, 2024
79b77e3
Revert "Allow empty hostname in GuestOS"
andrewbattat Dec 9, 2024
a6641e2
Remove unused elasticsearch_hosts variables
andrewbattat Dec 9, 2024
0bbd810
Revert "Revert "Allow empty hostname in GuestOS""
andrewbattat Dec 9, 2024
89710a2
Keep passing nns_urls to build-bootstrap
andrewbattat Dec 9, 2024
be1e88f
Revert "Keep passing nns_urls to build-bootstrap"
andrewbattat Dec 9, 2024
2c42b36
Add check if new config already exists and is Testnet, do not update
andrewbattat Dec 9, 2024
8a82be7
Revert "Revert "Revert "Allow empty hostname in GuestOS"""
andrewbattat Dec 9, 2024
285bfad
Allow empty hostname in GuestOS
andrewbattat Dec 6, 2024
29ab6b4
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Dec 10, 2024
4bb974f
Fix generate-guestos-config.sh
andrewbattat Dec 10, 2024
0e8df98
Set testnet deployment environment for nested tests
andrewbattat Dec 10, 2024
2a06def
Fix service ordering
andrewbattat Dec 10, 2024
31a50bb
Update setup-nftables to use new config
andrewbattat Dec 10, 2024
d242f1c
Fix ipv6_prefix get_config_value
andrewbattat Dec 10, 2024
af902d9
Fix HSM deployment bug
andrewbattat Dec 11, 2024
93ec080
Update nested test DeploymentEnvironment
andrewbattat Dec 11, 2024
6fbd20f
Fix service dependencies
andrewbattat Dec 11, 2024
c893839
Fix documentation
andrewbattat Dec 11, 2024
730665f
Pass old config to pass downgrade tests
andrewbattat Dec 11, 2024
dd8364e
Fix ipv4 integration test bug
andrewbattat Dec 11, 2024
bca19fa
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Dec 13, 2024
ca851c3
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Dec 23, 2024
23ff24c
Use let-else expression
andrewbattat Dec 23, 2024
947c419
Remove unnecessary config import
andrewbattat Jan 8, 2025
d1307dd
Remove unnecessary SetupOSArgs
andrewbattat Jan 8, 2025
d087d07
Parameterize setupos_config_object_path
andrewbattat Jan 8, 2025
b149280
Parameterize hostos_config_object_path
andrewbattat Jan 8, 2025
4f76f6e
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Jan 8, 2025
cfb7fad
Update cargo.lock
andrewbattat Jan 8, 2025
c96591d
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Jan 8, 2025
7dcbd77
Fix pre-commit
andrewbattat Jan 8, 2025
8f56256
Remove unnecessary TODO
andrewbattat Jan 9, 2025
65b9693
Revert log-config changes
andrewbattat Jan 9, 2025
02ca245
Add newline to log-config.sh
andrewbattat Jan 9, 2025
3d7d57c
Separate hostos and guestos setup-hostname
andrewbattat Jan 9, 2025
caf320b
Move hostos setup-hostname.sh up
andrewbattat Jan 9, 2025
9efc624
Add newline to setup-hostname.sh guestos
andrewbattat Jan 9, 2025
ab57f9e
Fix setup-hostname.sh guestos
andrewbattat Jan 9, 2025
41fa04a
Fix setup-hostname
andrewbattat Jan 9, 2025
049cfe1
Fix generate-guestos-config
andrewbattat Jan 10, 2025
f56f887
Merge branch 'master' into andrew/config-revamp-integration
andrewbattat Jan 28, 2025
722b309
Normalize config.sh get_config_value
andrewbattat Jan 28, 2025
925138a
Separate domain_name from ipv4 parameters
andrewbattat Jan 28, 2025
6546849
Automatically updated Cargo*.lock
Jan 28, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Provision a node based on an injected "ic-bootstrap.tar" file. This script
# is meant to be run as a prerequisite before launching orchestrator/replica.
#
# The configuration format is described in guestos/docs/ConfigStore.adoc
#
# The tar file can be supplied using one of two methods:
# - as "ic-bootstrap.tar" stored on a (virtual) removable media attached
# on first boot
Expand Down
12 changes: 12 additions & 0 deletions ic-os/components/misc/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/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.node_operator_private_key_path')
function get_config_value() {
local CONFIG_FILE="/var/ic/config/config.json"
local key=$1
jq -r "${key}" "${CONFIG_FILE}"
}
33 changes: 33 additions & 0 deletions ic-os/components/setupos-scripts/check-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -o nounset
set -o pipefail

source /opt/ic/bin/config.sh
source /opt/ic/bin/functions.sh

SHELL="/bin/bash"
PATH="/sbin:/bin:/usr/sbin:/usr/bin"

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() {
check_config_file
}

main
11 changes: 7 additions & 4 deletions ic-os/components/setupos-scripts/check-hardware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
set -o nounset
set -o pipefail

source /opt/ic/bin/config.sh
source /opt/ic/bin/functions.sh

SHELL="/bin/bash"
PATH="/sbin:/bin:/usr/sbin:/usr/bin"

Expand Down Expand Up @@ -30,8 +33,6 @@ GEN2_MINIMUM_AGGREGATE_DISK_SIZE=32000000000000
GEN1_MINIMUM_DISK_SIZE=3200000000000
GEN1_MINIMUM_AGGREGATE_DISK_SIZE=32000000000000

CONFIG_DIR="/var/ic/config"

function check_generation() {
echo "* Checking Generation..."

Expand Down Expand Up @@ -247,7 +248,10 @@ function verify_disks() {

function verify_deployment_path() {
echo "* Verifying deployment path..."
if [[ ${GENERATION} == 2 ]] && [[ ! -f "${CONFIG_DIR}/node_operator_private_key.pem" ]]; then

local node_operator_key_path=$(get_config_value '.icos_settings.node_operator_private_key_path')

if [[ ${GENERATION} == 2 ]] && [[ ! -f "${node_operator_key_path}" ]]; then
echo -e "\n\n\n\n\n\n"
echo -e "\033[1;31mWARNING: Gen2 hardware detected but no Node Operator Private Key found.\033[0m"
echo -e "\033[1;31mGen2 hardware should be deployed using the Gen2 Node Deployment method.\033[0m"
Expand All @@ -261,7 +265,6 @@ function verify_deployment_path() {

# Establish run order
main() {
source /opt/ic/bin/functions.sh
log_start "$(basename $0)"
check_generation
verify_cpu
Expand Down
66 changes: 25 additions & 41 deletions ic-os/components/setupos-scripts/check-network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,19 @@
set -o nounset
set -o pipefail

source /opt/ic/bin/config.sh
source /opt/ic/bin/functions.sh

SHELL="/bin/bash"
PATH="/sbin:/bin:/usr/sbin:/usr/bin"

CONFIG="${CONFIG:=/var/ic/config/config.ini}"
DEPLOYMENT="${DEPLOYMENT:=/data/deployment.json}"

function read_variables() {
# Read limited set of keys. Be extra-careful quoting values as it could
# otherwise lead to executing arbitrary shell code!
while IFS="=" read -r key value; do
case "$key" in
"ipv6_prefix") ipv6_prefix="${value}" ;;
"ipv6_gateway") ipv6_gateway="${value}" ;;
"ipv4_address") ipv4_address="${value}" ;;
"ipv4_prefix_length") ipv4_prefix_length="${value}" ;;
"ipv4_gateway") ipv4_gateway="${value}" ;;
"domain") domain="${value}" ;;
esac
done <"${CONFIG}"
function read_config_variables() {
ipv6_prefix=$(get_config_value '.network_settings.ipv6_prefix')
ipv6_gateway=$(get_config_value '.network_settings.ipv6_gateway')
ipv4_address=$(get_config_value '.network_settings.ipv4_address')
ipv4_prefix_length=$(get_config_value '.network_settings.ipv4_prefix_length')
ipv4_gateway=$(get_config_value '.network_settings.ipv4_gateway')
domain=$(get_config_value '.network_settings.domain')
}

# WARNING: Uses 'eval' for command execution.
Expand Down Expand Up @@ -168,45 +162,36 @@ function ping_ipv6_gateway() {
echo " "
}

function assemble_nns_nodes_list() {
NNS_URL_STRING=$(/opt/ic/bin/fetch-property.sh --key=.nns.url --config=${DEPLOYMENT})
NNS_URL_LIST=$(echo $NNS_URL_STRING | sed 's@,@ @g')
}

function query_nns_nodes() {
echo "* Querying NNS nodes..."

i=0
success=0
nodes=$(echo ${NNS_URL_LIST} | wc -w)
# At least one of the provided URLs needs to work.
verify=1
for url in $(echo $NNS_URL_LIST); do
local nns_urls=($(get_config_value '.icos_settings.nns_urls' | jq -r '.[]'))
local success=false

for url in "${nns_urls[@]}"; do
# When running against testnets, we need to ignore self signed certs
# with `--insecure`. This check is only meant to confirm from SetupOS
# that NNS urls are reachable, so we do not mind that it is "weak".
curl --insecure --head --connect-timeout 3 --silent ${url} >/dev/null 2>&1
if [ "${?}" -ne 0 ]; then
echo " fail: ${url}"
else
if curl --insecure --head --connect-timeout 3 --silent "${url}" >/dev/null 2>&1; then
echo " okay: ${url}"
success=$((${success} + 1))
fi
i=$((${i} + 1))
if [ ${success} -ge ${verify} ]; then
echo " success"
success=true
break
elif [ ${i} -eq ${nodes} ]; then
log_and_halt_installation_on_error "1" "Unable to query enough healthy NNS nodes."
else
echo " fail: ${url}"
fi
done

if $success; then
echo " success"
else
log_and_halt_installation_on_error "1" "Unable to query enough healthy NNS nodes."
fi
}

# Establish run order
main() {
source /opt/ic/bin/functions.sh
log_start "$(basename $0)"
read_variables
read_config_variables
get_network_settings
print_network_settings

Expand All @@ -217,7 +202,6 @@ main() {
fi

ping_ipv6_gateway
assemble_nns_nodes_list
query_nns_nodes
log_end "$(basename $0)"
}
Expand Down
6 changes: 3 additions & 3 deletions ic-os/components/setupos-scripts/config.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Before=setupos.service
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/opt/ic/bin/output-wrapper.sh /dev/ttyS0 /opt/ic/bin/config.sh
StandardOutput=tty
StandardError=tty
ExecStart=/opt/ic/bin/config create-setupos-config
StandardOutput=journal+console
StandardError=journal+console

[Install]
WantedBy=multi-user.target
120 changes: 0 additions & 120 deletions ic-os/components/setupos-scripts/config.sh

This file was deleted.

2 changes: 1 addition & 1 deletion ic-os/components/setupos-scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function log_and_halt_installation_on_error() {
echo " ERROR"
echo "--------------------------------------------------------------------------------"
echo -e "\n\n"
echo "${log_message}"
echo -e "${log_message}"
echo -e "\n\n"
echo "--------------------------------------------------------------------------------"
echo " ERROR"
Expand Down
3 changes: 2 additions & 1 deletion ic-os/components/setupos-scripts/install-guestos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
set -o nounset
set -o pipefail

source /opt/ic/bin/functions.sh

SHELL="/bin/bash"
PATH="/sbin:/bin:/usr/sbin:/usr/bin"

Expand Down Expand Up @@ -34,7 +36,6 @@ function install_guestos() {

# Establish run order
main() {
source /opt/ic/bin/functions.sh
log_start "$(basename $0)"
install_guestos
log_end "$(basename $0)"
Expand Down
3 changes: 2 additions & 1 deletion ic-os/components/setupos-scripts/install-hostos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
set -o nounset
set -o pipefail

source /opt/ic/bin/functions.sh

SHELL="/bin/bash"
PATH="/sbin:/bin:/usr/sbin:/usr/bin"

Expand Down Expand Up @@ -101,7 +103,6 @@ function resize_partition() {

# Establish run order
main() {
source /opt/ic/bin/functions.sh
log_start "$(basename $0)"
install_hostos
configure_efi
Expand Down
3 changes: 2 additions & 1 deletion ic-os/components/setupos-scripts/setup-disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
set -o nounset
set -o pipefail

source /opt/ic/bin/functions.sh

SHELL="/bin/bash"
PATH="/sbin:/bin:/usr/sbin:/usr/bin"

Expand Down Expand Up @@ -60,7 +62,6 @@ function setup_storage() {

# Establish run order
main() {
source /opt/ic/bin/functions.sh
log_start "$(basename $0)"
purge_partitions
setup_storage
Expand Down
Loading
Loading