
#!/bin/bash

source "./custom/defines.sh"

CONFIG="${DYNAMIC_CONFIG_DIR}/1580010.json"

setman-restore "tpxRxSettings" "1580010.json" > "$CONFIG"

if [ $? -ne 0 ]; then
    exit 1
fi

tmp="$(mktemp)"

jq '
  .ethernet |= map(
    if has("vlan") then . else . + { vlan: { Access: 1, Trunk: [] } } end
  )
' "$CONFIG" > "$tmp" && mv "$tmp" "$CONFIG"
