Skip to content
Merged
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
41 changes: 41 additions & 0 deletions live/live-root/etc/systemd/system/initrd-nmtui.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[Unit]
Description=Interactive network configuration in initrd
DefaultDependencies=no

# see https://man7.org/linux/man-pages/man7/dracut.bootup.7.html
# for the dependency order of the dracut services

# after NetworkManager is started and network configured
After=network-online.target
# after the console is initialized
After=systemd-vconsole-setup.service
# before running the pre-pivot dracut hooks (before the driver update),
# before the self-update and before displaying the Plymouth splash screen
Before=dracut-pre-pivot.service live-self-update.service plymouth-start.service

ConditionKernelCommandLine=live.net_config_tui=1

[Service]
Type=oneshot

# disable the kernel output on the console
ExecStartPre=dmesg --console-off
# disable the systemd status messages on the console
ExecStartPre=kill -SIGRTMIN+21 1

ExecStart=initrd-network-setup.sh

# enable back the kernel output on the console
ExecStartPost=dmesg --console-on
# enable back the systemd status messages on the console
ExecStartPost=kill -SIGRTMIN+20 1

Environment=TERM=linux

StandardInput=tty
StandardOutput=tty
TimeoutStartSec=infinity
RemainAfterExit=true

[Install]
WantedBy=initrd.target
114 changes: 114 additions & 0 deletions live/live-root/usr/bin/initrd-network-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#! /bin/bash

BACK_TITLE="System installation - network configuration"
# plain http is enough, we only check that the server is reachable via HEAD request
TEST_URL="http://www.suse.com"

# where to save the proxy configuration
proxy_file="/etc/cmdline.d/99-proxy-setup.conf"

# read the current proxy value
# get the configured network proxy (empty string if not configured)
# see ../lib/dracut/modules.d/98dracut-menu/dracut-cmdline-menu.sh
# get the last found, it has the highest priority
PROXY=$(grep "\bproxy=" /proc/cmdline /etc/cmdline.d/* | tail -n 1 | sed "s/.*\bproxy=\([^ \t]*\).*/\1/")
if [ -n "$PROXY" ]; then
export http_proxy="$PROXY"
export https_proxy="$PROXY"
fi

while :; do
# repeat getting the config if it is empty (NM not ready yet)
for i in {1..5}; do
# delete the included help text at the end
summary=$(nmcli | sed '/^Use "nmcli device show"/,$d')
# break the loop if we have a non-empty summary without "connecting" status
if [ -n "$summary" ] && [[ "$summary" != *"connecting"* ]]; then
break
else
echo "Reading network configuration..."
sleep 2
fi
done

# list all devices
summary=$(
cat <<EOF
Network Devices
---------------
$(nmcli d)

Details
-------
$summary
EOF
)

if [ -n "$http_proxy" ]; then
# hide the password in the proxy URL
proxy_label=$(echo "$http_proxy" | sed 's|://.*@|://*******@|')
else
proxy_label="<Not configured>"
fi
summary="$summary\n\nProxy configuration:\n server: $proxy_label"

# terminal size might change during runtime, evaluate it in each iteration
term_width=$(tput cols 2>/dev/null || echo 80)
term_height=$(tput lines 2>/dev/null || echo 24)
# set to 80% of terminal size
width=$((term_width * 80 / 100))
height=$((term_height * 80 / 100))

dialog --clear --no-collapse --backtitle "$BACK_TITLE" --title "Current network configuration" \
--ok-label "Continue" \
--extra-button --extra-label "Edit" \
--help-button --help-label "Test connection" \
--cr-wrap --msgbox "\n$summary" "$height" "$width"

# the exit value refers to the pressed button
button=$?

# test button pressed
if [ $button -eq 2 ]; then
dialog --backtitle "$BACK_TITLE" --title "Network connection test" --infobox "\nTesting network connectivity...\nPlease wait." 7 50

# simple connectivity test
out=$(curl --head --silent --show-error --connect-timeout 20 --max-time 10 --retry 2 --retry-connrefused -o /dev/null "$TEST_URL" 2>&1)
if [ $? -eq 0 ]; then
label="The network connectivity test succeeded."
dialog --clear --backtitle "$BACK_TITLE" --title "Network Test Result" --msgbox "\n$label" 7 50
else
label="Network connectivity test failed!\nCheck the network configuration."
# remove duplicate errors from retries
details=$(echo "$out" | uniq)
label="$label\n\nDetails:\n$details"

dialog --clear --backtitle "$BACK_TITLE" --title "Network Test Result" --msgbox "\n$label" 12 70
fi
# continue button or Esc (255) pressed, leave the script
elif [ $button -eq 0 ] || [ $button -eq 255 ]; then
# clear possible dialog leftovers on the screen
clear
exit 0
# edit button pressed, run the network configuration
else
nmtui

proxy_address=$(dialog --clear --no-cancel --backtitle "$BACK_TITLE" --title "HTTP proxy address" \
--stdout --inputbox "Enter the HTTP proxy URL (e.g. http://proxy.example.com:3128)\nor leave empty to not use any proxy." \
10 70 "$http_proxy")

exit_status=$?
if [ $exit_status -eq 0 ]; then
if [ -z "$proxy_address" ]; then
unset http_proxy
unset https_proxy
rm -f "$proxy_file"
else
echo "proxy=$proxy_address" >"$proxy_file"
export http_proxy="$proxy_address"
export https_proxy="$proxy_address"
fi
fi
fi
done
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# automatically configure network and start NetworkManager when live.net_config_tui=1

. /lib/dracut-lib.sh

# generate Dracut command line options
FILE="/etc/cmdline.d/initrd-nmtui.conf"

# only if interactive network config requested
if getargbool 0 live.net_config_tui; then
# and network not disabled
if getargbool 1 rd.neednet; then
echo "rd.neednet=1" >"$FILE"
# use DHCP if there is no network configuration provided by user
if ! getarg "ip="; then
echo "ip=dhcp" >>"$FILE"
fi
fi
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# module-setup.sh for NetworkManger TUI configuration
# see https://www.man7.org/linux/man-pages/man7/dracut.modules.7.html

# called by dracut
check() {
# always include this dracut module in the initramfs
return 0
}

# called by dracut
depends() {
echo network
return 0
}

installkernel() {
return 0
}

# install hook for dracut
install() {
# install the hook for processing the boot parameters and enabling network support in dracut
inst_hook cmdline 99 "$moddir/initrd-nmtui-cmdline.sh"

# install the systemd service and the self-update script to the initramfs
inst_multiple "$systemdsystemconfdir"/initrd-nmtui.service initrd-network-setup.sh dialog nmtui nmcli kill tput clear

# enable the self-update service in the initramfs
$SYSTEMCTL -q --root "$initdir" enable initrd-nmtui.service
}
6 changes: 6 additions & 0 deletions live/src/agama-installer.changes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Tue Jan 6 16:21:35 UTC 2026 - Ladislav Slezák <lslezak@suse.com>
- Hide the data sharing notification in the Firefox browser
(bsc#1252961)

-------------------------------------------------------------------
Mon Dec 1 20:49:41 UTC 2025 - Ladislav Slezák <lslezak@suse.com>

- Added new boot option "live.net_config=1" to interactively
configure network settings (gh#agama-project/agama#2923)

-------------------------------------------------------------------
Wed Nov 12 15:42:29 UTC 2025 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down
1 change: 1 addition & 0 deletions live/src/agama-installer.kiwi
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<package name="blog" arch="s390x" />
<package name="libblogger2" arch="s390x" />
<package name="NetworkManager"/>
<package name="NetworkManager-tui"/>
<package name="agama"/>
<package name="agama-yast"/>
<package name="agama-web-ui"/>
Expand Down
2 changes: 1 addition & 1 deletion live/src/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ mkdir /etc/cmdline.d
echo "root=live:LABEL=$label" >/etc/cmdline.d/10-liveroot.conf
echo "root_disk=live:LABEL=$label" >>/etc/cmdline.d/10-liveroot.conf
echo 'install_items+=" /etc/cmdline.d/10-liveroot.conf "' >/etc/dracut.conf.d/10-liveroot-file.conf
echo 'add_dracutmodules+=" dracut-menu agama-cmdline agama-dud live-self-update "' >>/etc/dracut.conf.d/10-liveroot-file.conf
echo 'add_dracutmodules+=" dracut-menu agama-cmdline agama-dud live-self-update initrd-nmtui "' >>/etc/dracut.conf.d/10-liveroot-file.conf

# decrease the kernel logging on the console, use a dracut module to do it early in the boot process
echo 'add_dracutmodules+=" agama-logging "' > /etc/dracut.conf.d/10-agama-logging.conf
Expand Down