summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-03-31 15:35:33 +0200
committerChristian Breunig <christian@breunig.cc>2026-04-09 20:54:06 +0200
commit51922535b79529d603c3b7d52cde9da54c069d42 (patch)
tree2bcaca4b3877a598a5f2f0229ac0329cb87f3ab6 /src/op_mode
parentd2ad852ab4393862e9f27b2bc3bd7d382feb4c5a (diff)
downloadvyos-1x-51922535b79529d603c3b7d52cde9da54c069d42.tar.gz
vyos-1x-51922535b79529d603c3b7d52cde9da54c069d42.zip
serial: T8375: use boot activation script to define a serial console on the CLI
Required during first-boot of a system. We have images form amd64 and arm64 CPUs which also tend to have different serial interfaces (ttyS vs. ttyAMA). The images which are installed have the correct serial setting for GRUB (ttyS0 or ttyAMA0) and the activation script will probe the Kernel command-line. If a serial interface is defined, we will include it in the VyOS CLI configuration.
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/image_installer.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/op_mode/image_installer.py b/src/op_mode/image_installer.py
index db9647782..fb3cdda9e 100755
--- a/src/op_mode/image_installer.py
+++ b/src/op_mode/image_installer.py
@@ -42,8 +42,10 @@ from psutil import disk_partitions
from vyos.base import Warning
from vyos.configtree import ConfigTree
+from vyos.config_mgmt import unsaved_commits
from vyos.defaults import base_dir
from vyos.defaults import directories
+from vyos.flavor import get_image_serial_console
from vyos.remote import download
from vyos.system import disk
from vyos.system import grub
@@ -69,7 +71,6 @@ from vyos.utils.process import cmd
from vyos.utils.process import run
from vyos.utils.process import rc_cmd
from vyos.version import get_version_data
-from vyos.config_mgmt import unsaved_commits
# define text messages
MSG_ERR_NOT_LIVE: str = 'The system is already installed. Please use "add system image" instead.'
@@ -143,16 +144,17 @@ ISO_DOWNLOAD_PATH: str = ''
external_download_script: str = f'{base_dir}/simple-download.py'
external_latest_image_url_script: str = f'{base_dir}/latest-image-url.py'
+(flavor_sercon_type, flavor_sercon_num, flavor_sercon_speed) = get_image_serial_console()
+
# default boot variables
DEFAULT_BOOT_VARS: dict[str, str] = {
'timeout': '5',
'console_type': 'tty',
- 'console_num': '0',
- 'console_speed': '115200',
+ 'console_num': flavor_sercon_num,
+ 'console_speed': flavor_sercon_speed,
'bootmode': 'normal'
}
-
def bytes_to_gb(size: int) -> float:
"""Convert Bytes to GBytes, rounded to 1 decimal number
@@ -767,12 +769,13 @@ def console_hint() -> str:
path = '/dev/tty'
name = Path(path).name
- if name in ['ttyS0', 'ttyAMA0']:
+ if name in ['ttyS0']:
return 'S'
+ elif name in ['ttyAMA0']:
+ return 'A'
else:
return 'K'
-
def cleanup(mounts: list[str] = [], remove_items: list[str] = []) -> None:
"""Clean up after installation
@@ -921,10 +924,14 @@ def install_image() -> None:
print(MSG_WARN_PASSWORD_CONFIRM)
# ask for default console
+ console_dict: dict[str, str] = {'K': 'tty'}
+ if flavor_sercon_type:
+ tmp: str = flavor_sercon_type[-1] # get "S" from "ttyS" and "A" from "ttyAMA"
+ console_dict.update({tmp: flavor_sercon_type})
+
console_type: str = ask_input(MSG_INPUT_CONSOLE_TYPE,
default=console_hint(),
- valid_responses=['K', 'S'])
- console_dict: dict[str, str] = {'K': 'tty', 'S': 'ttyS'}
+ valid_responses=console_dict.keys())
config_boot_list = [f'{DIR_CONFIG}/config.boot',
'/opt/vyatta/etc/config.boot.default']