[WIP] feat: toggle jg928a ports

Before this commit, I used uncommitted code that used an <<EOF or
<<'EOF' heredef block.

This did not work well, because for some reason, ubus call poe manage
would occasionally send a Ctrl+c, stopping the script. Again, no clue
how.

Notable items here:

- s function, which wraps arguments for ssh

  This is a really nice function. Gemini 2.5 Pro provides a good
  explanation for how the printf '%q ' bit works; tl;dr it builds a
  string prepared for a single shell interpolation and dequoting.

- run all shell commands standalone

  ... one-by-one prevents the Ctrl+c issue.

- not documented: limit /etc/config/poe on the remote switch

  ... to only four ports. The new /etc/config/poe generated-default
  contains too many ports for ubus call poe manage to operate quickly.
  By only listing the four needed ports, ubus call poe manage runs very
  quickly now -- afaict the ubox queue does not get long since there are
  only four ports described to manage.
This commit is contained in:
2025-07-26 12:21:45 -04:00
parent c21ee66c1b
commit e428d989d3

15
toggle_jg928a_port.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
function s {
ssh root@jg928a "$(printf '%q ' "$@")"
}
echo before: | tr '\n' '\t'
s ubus call poe info
s ubus call poe manage '{"port": "lan16", "enable": false}'
sleep 2;
echo after shutoff: | tr '\n' '\t';
s ubus call poe info;
s ubus call poe manage '{"port": "lan16", "enable": true}'
sleep 2;