iopsys-feed/obuspc/files/etc/uci-defaults/99-fix-agent-endpoint
Vivek Kumar Dutta 33b331d724
obuspc: Disable on extender DUT
- uci-default script to detect based on env variable `netmode=extender`
  to disable obuspc.
2023-08-24 17:21:36 +05:30

37 lines
699 B
Bash

#!/bin/sh
. /lib/functions.sh
# exit if running in an extender
enabled="$(uci -q get uspc.global.enabled)"
if [ "$enabled" -eq 0 ]; then
return 0;
fi
get_oui_from_db()
{
db -q get device.deviceinfo.ManufacturerOUI
}
get_serial_from_db()
{
db -q get device.deviceinfo.SerialNumber
}
fix_agent_endpoint()
{
local AgentEndpointID serial oui user pass
# Get endpoint id from obuspa config first
config_load obuspa
config_get AgentEndpointID localagent EndpointID ""
if [ -z "${AgentEndpointID}" ]; then
serial=$(get_serial_from_db)
oui=$(get_oui_from_db)
AgentEndpointID="os::${oui}-${serial//+/%2B}"
fi
uci -q set uspc.agent.EndpointID="${AgentEndpointID}"
}
fix_agent_endpoint