-
Notifications
You must be signed in to change notification settings - Fork 1.5k
WIP agent: present questionnare in interactive mode #6560
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
data/data/agent/files/usr/local/bin/get-interactive-config.sh
This file contains hidden or 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,96 @@ | ||
| #!/bin/bash | ||
|
|
||
| function connectivity_check() { | ||
| declare target | ||
|
|
||
| target="$1" | ||
|
|
||
| (>&2 echo "Pinging ${target} to check the validity of the current network configuration") | ||
| if ping -c 4 "$NODE_ZERO_IP"; then | ||
| (>&2 echo "Successfully pinged ${target}.") | ||
| return 0 | ||
| else | ||
| (>&2 echo "Failed to ping ${target}.") | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| function print_addressing_info() { | ||
| declare with_prefix | ||
|
|
||
| with_prefix="${1:-true}" | ||
| echo "Currently configured addresses" | ||
| if $with_prefix; then | ||
| ip -j a show | jq -r '. | map({name: .ifname, addresses: [.addr_info[] | .local + "/" + (.prefixlen | tostring)]}) | .[] | select(.addresses | length > 0) | select( .name != "lo") | .name + ": " + (.addresses | join(" "))' | ||
| else | ||
| ip -j a show | jq -r '. | map({name: .ifname, addresses: [.addr_info[] | .local]}) | .[] | select(.addresses | length > 0) | select( .name != "lo") | .name + ": " + (.addresses | join(" "))' | ||
| fi | ||
| } | ||
|
|
||
| NODE_ZERO=false | ||
| while true; do | ||
| read -e -p "Do you wish for this node to be the one that runs the installation service (Only one node may perform this function)? (Y)es/(N)o: " NODE0_ANSWER | ||
| if [[ "$NODE0_ANSWER" =~ ^[Yy](es)?$ ]]; then | ||
| NODE_ZERO=true | ||
| break | ||
| elif [[ "$NODE0_ANSWER" =~ ^[Nn](o)?$ ]]; then | ||
| (>&2 echo "This node will not run the installation service.") | ||
| break | ||
| else | ||
| (>&2 echo "Invalid answer.") | ||
| fi | ||
| done | ||
|
|
||
| if $NODE_ZERO; then | ||
| print_addressing_info | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The print_addressing_info is only displayed for Node0. The other nodes don't show their currently configured ip address. So it is unclear whether the nmtui should be used. |
||
| while true; do | ||
| read -e -p "Do you wish to enter NetworkManager terminal user interface to change the network configuration? (Y)es/(N)o: " ANSWER | ||
| if [[ "$ANSWER" =~ ^[Yy](es)?$ ]]; then | ||
| nmtui | ||
| print_addressing_info | ||
| elif [[ "$ANSWER" =~ ^[Nn](o)?$ ]]; then | ||
| echo "Other nodes should give one of the following addresses as the rendezvous IP" | ||
| print_addressing_info false | ||
| break | ||
| else | ||
| (>&2 echo "Answer not in (Y)es/(N)o") | ||
| fi | ||
| done | ||
| exit 0 | ||
| else | ||
| CONFIRMED=false | ||
| until $CONFIRMED; do | ||
| read -e -p "Please, enter the rendezvous IP address: " NODE_ZERO_IP | ||
| read -e -p "Please, enter the rendezvous IP address again to confirm: " CONFIRMATION | ||
| if [[ "$NODE_ZERO_IP" == "$CONFIRMATION" ]]; then | ||
| CONFIRMED=true | ||
| else | ||
| (>&2 echo "Confirmation failed") | ||
| fi | ||
| done | ||
| fi | ||
|
|
||
| SHOULD_CONFIGURE=true | ||
| while $SHOULD_CONFIGURE; do | ||
| while true; do | ||
| if connectivity_check "$NODE_ZERO_IP"; then | ||
| SHOULD_CONFIGURE=false | ||
| fi | ||
| read -e -p "Do you wish to enter NetworkManager terminal user interface to change the network configuration? (Y)es/(N)o: " ANSWER | ||
| if [[ "$ANSWER" =~ ^[Yy](es)?$ ]]; then | ||
| SHOULD_CONFIGURE=true # Setting to true in case the connectivity_check had passed but we chose to configure anyway | ||
| nmtui | ||
| if connectivity_check "$NODE_ZERO_IP"; then | ||
| SHOULD_CONFIGURE=false | ||
| fi | ||
| break | ||
| elif [[ "$ANSWER" =~ ^[Nn](o)?$ ]]; then | ||
| if ! $SHOULD_CONFIGURE; then | ||
| break | ||
| fi | ||
| (>&2 echo "No valid network configuration found") | ||
| else | ||
| (>&2 echo "Answer not in (Y)es/(N)o") | ||
| fi | ||
| done | ||
| done | ||
19 changes: 19 additions & 0 deletions
19
data/data/agent/systemd/units/get-interactive-config.service
This file contains hidden or 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,19 @@ | ||
| [Unit] | ||
| Description=Get interactive user configuration at boot | ||
| After=network-pre.target NetworkManager.service | ||
| Before=network.target network.service | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| TTYPath=/dev/tty15 | ||
| ExecStartPre=/usr/bin/chvt 15 | ||
| ExecStart=/usr/local/bin/get-interactive-config.sh | ||
| ExecStartPost=/usr/bin/chvt 1 | ||
| TimeoutStartSec=0 | ||
| StandardInput=tty | ||
| TTYVHangup=yes | ||
| TTYVTDisallocate=yes | ||
|
|
||
| [Install] | ||
| WantedBy=default.target | ||
| RequiredBy=sshd.service systemd-logind.service [email protected] |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming we need to add something here that checks if node0 is defined in the ISO. If it is defined and connectivity check passes, then the following loops should be skipped after a predetermined amount timeout (according to https://issues.redhat.com/browse/AGENT-455)