Skip to content
Closed
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
96 changes: 96 additions & 0 deletions data/data/agent/files/usr/local/bin/get-interactive-config.sh
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
}

Copy link
Contributor

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)

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
Copy link
Contributor

Choose a reason for hiding this comment

The 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 data/data/agent/systemd/units/get-interactive-config.service
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]
1 change: 1 addition & 0 deletions pkg/asset/agent/image/ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func (a *Ignition) Generate(dependencies asset.Parents) error {
"assisted-service-pod.service",
"assisted-service.service",
"create-cluster-and-infraenv.service",
"get-interactive-config.service",
"node-zero.service",
"multipathd.service",
"selinux.service",
Expand Down
1 change: 1 addition & 0 deletions pkg/asset/agent/image/ignition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ func defaultGeneratedFiles() []string {
"/usr/local/bin/agent-gather",
"/usr/local/bin/extract-agent.sh",
"/usr/local/bin/get-container-images.sh",
"/usr/local/bin/get-interactive-config.sh",
"/usr/local/bin/set-hostname.sh",
"/usr/local/bin/start-agent.sh",
"/usr/local/bin/start-cluster-installation.sh",
Expand Down