Skip to content
Draft
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
36 changes: 36 additions & 0 deletions scripts/sonic-console-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# sonic-udev-setup.sh
# Enables console mode and symlinks the platform udev rules file.
# Assumes 99-sonic-tty.rules and udevprefix.conf already exist in the platform directory.
# Must be run as root on a Debian-based system.
#

set -euo pipefail

PLATFORM_NAME=$(sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
PLATFORM_DIR="/usr/share/sonic/device/${PLATFORM_NAME}"
RULES_SRC="${PLATFORM_DIR}/99-sonic-tty.rules"
RULES_DEST="/etc/udev/rules.d/99-sonic-tty.rules"

# --- Ensure we are running as root ---
if [[ "$(id -u)" -ne 0 ]]; then
echo "Error: this script must be run as root." >&2
exit 1
fi

# --- Enable console ---
echo "Enabling console ..."
sudo config console enable
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need touch the config here? Or this suppose to be a kind of default config in BMC system? Do we need persist this config?


# --- Symlink udev rules ---
echo "Creating symlink ${RULES_DEST} -> ${RULES_SRC} ..."
ln -sf "${RULES_SRC}" "${RULES_DEST}"

# --- Reload udev rules ---
echo "Reloading udev rules ..."
udevadm control --reload-rules
udevadm trigger

echo "sonic udev setup complete."
echo " Rules symlinked: ${RULES_DEST} -> ${RULES_SRC}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this support this requirement that BMC should be able to log the console of the switch CPU all the time and export those logs ?
That is there has to be "read only" access (logging everything including the commands entered) and a "read/write" (normal console access)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The console logging can be implemented in elsewhere with socat proxy

Here we need a virtual tty device with 0666 permission opened so user can connect to a line without root permission.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit 40f4febf70f3217b844712c7fcea81377fc49fe6 has brought in the proposed mechanism here to #24898

Just an heads up.

Loading