Skip to content

Code improvement to get the ASUS Router Model ID #1

@Martinski4GitHub

Description

@Martinski4GitHub

Here's an improvement in the "MerlinAutoUpdate.sh" shell script for getting the router model ID. Instead of the current syntax:

MODEL=$(nvram get model)

Use the following function:

##################################################
GetRouterModel()
{
local retCode=1 routerModelID="N/A"
local nvramModelKeys="odmpid productid wps_modelnum wps_device_name model"
for nvramKey in $nvramModelKeys
do
routerModelID="$(nvram get "$nvramKey")"
[ -n "$routerModelID" ] && retCode=0 && break
done
echo "$routerModelID" ; return "$retCode"
}

##################################################

EXAMPLE USAGE:

if ! MODEL="$(GetRouterModel)"
then echo "ERROR: UNKNOWN Router Model" ; exit 1 ; fi

The reason is that not all ASUS routers use or set the "model" NVRAM variable; most use either "odmpid" or "productid" variable to store the router model ID. Other keys in the list could be used as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions