fix(console): switch conman from ser2net-telnet to direct serial access
The ser2net layer between conman and the serial devices was causing
stair-stepping in terminal output. conman's dev="host:port" uses telnet
protocol, but ser2net's accepter was raw TCP (no telnet mode). The telnet
NVT state machine in conman was stripping bare CR characters from device
output — particularly from Dell switches that use old-style \n\r (LF+CR)
line endings instead of standard \r\n. In telnet, a bare \r not followed
by \n or NUL is non-compliant and gets dropped, leaving bare \n that
causes stair-stepping in the raw-mode terminal.
Fix: conman now opens serial devices directly via the stable udev
symlinks (/dev/consoles/<name>) with seropts, eliminating the telnet
layer entirely. ser2net is stopped and disabled but remains installed
for emergency TCP access (documented workflow: stop conmand, start
ser2net, use telnet, then reverse).
Architecture change:
Before: device → serial → ser2net (raw TCP) → conman (telnet NVT) → terminal
After: device → serial → conman (direct) → terminal
Verified: 7/7 serial devices held by conmand, 7/7 log files capturing,
all \r bytes preserved in terminal output (confirmed via PTY capture).
💘 Generated with Crush
Assisted-by: Crush:glm-5.2
This commit is contained in:
+31
-32
@@ -133,35 +133,24 @@ while IFS= read -r line; do
|
||||
fi
|
||||
done < "$MAPPING_FILE"
|
||||
|
||||
# --- 5. Restart ser2net ---
|
||||
# --- 5. Stop ser2net (conman owns serial devices directly) ---
|
||||
echo ""
|
||||
echo "--- [5/7] Restarting ser2net ---"
|
||||
systemctl enable ser2net
|
||||
systemctl restart ser2net
|
||||
sleep 2
|
||||
|
||||
if systemctl is-active --quiet ser2net; then
|
||||
echo " ser2net is running."
|
||||
TS_IP=$(tailscale ip -4 2>/dev/null || echo "127.0.0.1")
|
||||
echo " Listening ports:"
|
||||
ss -tlnp | grep ser2net | grep -oE "${TS_IP}:[0-9]+" | sort -t: -k2 -n | sed 's/^/ /'
|
||||
else
|
||||
echo " WARNING: ser2net failed to start. Checking journal..."
|
||||
journalctl -u ser2net --no-pager -n 20
|
||||
fi
|
||||
echo "--- [5/7] Disabling ser2net ---"
|
||||
echo " conman now owns serial devices directly. ser2net must NOT run"
|
||||
echo " simultaneously (only one process can open a serial device at a time)."
|
||||
systemctl stop ser2net 2>/dev/null || true
|
||||
systemctl disable ser2net 2>/dev/null || true
|
||||
echo " ser2net stopped and disabled (available for emergency use)."
|
||||
|
||||
# --- 6. Enable + start conmand ---
|
||||
echo ""
|
||||
echo "--- [6/7] Starting conmand ---"
|
||||
|
||||
# conman package on Debian may not ship a systemd unit. Create one if missing.
|
||||
if ! systemctl cat conmand >/dev/null 2>&1; then
|
||||
echo " No systemd unit for conmand — creating one..."
|
||||
cat > /etc/systemd/system/conmand.service <<'CONMAND_UNIT'
|
||||
[Unit]
|
||||
# conman package on Debian may not ship a systemd unit. Create one if missing,
|
||||
# or update an existing one that still references ser2net.
|
||||
CONMAND_UNIT_BODY='[Unit]
|
||||
Description=ConMan (Console Manager)
|
||||
After=network.target ser2net.service
|
||||
Requires=ser2net.service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
@@ -170,10 +159,18 @@ Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
CONMAND_UNIT
|
||||
WantedBy=multi-user.target'
|
||||
|
||||
if ! systemctl cat conmand >/dev/null 2>&1; then
|
||||
echo " No systemd unit for conmand — creating one..."
|
||||
echo "$CONMAND_UNIT_BODY" > /etc/systemd/system/conmand.service
|
||||
systemctl daemon-reload
|
||||
echo " Created /etc/systemd/system/conmand.service"
|
||||
elif systemctl cat conmand 2>/dev/null | grep -q 'ser2net'; then
|
||||
echo " conmand unit has ser2net dependency — updating..."
|
||||
echo "$CONMAND_UNIT_BODY" > /etc/systemd/system/conmand.service
|
||||
systemctl daemon-reload
|
||||
echo " Updated /etc/systemd/system/conmand.service (removed ser2net dep)"
|
||||
fi
|
||||
|
||||
# Kill any manually-started conmand first
|
||||
@@ -200,17 +197,19 @@ fi
|
||||
echo ""
|
||||
echo "--- [7/7] Setup complete ---"
|
||||
echo ""
|
||||
echo " ser2net TCP ports (connect directly):"
|
||||
echo " telnet <tailscale-ip> 2001 # pfv-core-sw01"
|
||||
echo " telnet <tailscale-ip> 2002 # pfv-tor3-mgmt"
|
||||
echo " ..."
|
||||
echo " conman owns serial devices directly (no ser2net in the data path)."
|
||||
echo ""
|
||||
echo " conman consoles (with logging):"
|
||||
echo " conman -f pfv-core-sw01"
|
||||
echo " conman -q # query status"
|
||||
echo " Connect from any Tailscale workstation:"
|
||||
echo " conman -d pfv-tsys4:7890 -f pfv-core-sw01"
|
||||
echo " conman -d pfv-tsys4:7890 -q # list consoles"
|
||||
echo ""
|
||||
echo " Emergency direct serial (must stop conmand first):"
|
||||
echo " systemctl stop conmand"
|
||||
echo " screen /dev/consoles/pfv-core-sw01"
|
||||
echo " systemctl start conmand"
|
||||
echo ""
|
||||
echo " To regenerate after changing mapping.txt:"
|
||||
echo " bash generate-config.sh"
|
||||
echo " udevadm trigger"
|
||||
echo " systemctl restart ser2net conmand"
|
||||
echo " systemctl restart conmand"
|
||||
echo "============================================"
|
||||
|
||||
Reference in New Issue
Block a user