OpenWRT's scripting interface for network configuration primarily utilizes shell script wrapper functions around the commotion command-line client in order to interact with commotiond. Those functions are included in https://github.com/opentechinstitute/commotiond/blob/master/openwrt/lib/functions/commotion.sh (installed as /lib/functions/commotion.sh on a node). Currently the functions are written assuming that they're using the old-format output from the daemon, as opposed to the new key-value JSON format. These functions need to be updated against the new output format and new commands.
Output is of an arbitrary key-value format:
{ "key": "value", "key": "value" }
with unique keys. Exact output per command is still being determined. Also, unlike before, the commotion client returns true or false correctly depending on whether the command succeeds. So for some commands, it may be as easy as running the command and interpreting $? in order to echo "Command succeeded!" or "Command failed!". Output can be parsed through grep, sed and the like, but ideal would be proper JSON parsing. OpenWRT has a shell script JSON parser in a shell library called jsn.sh or something similar, which they use for parsing JSON output.
The shell functions should retain their current output format to the extent possible so as to keep from having to update things in other Commotion scripts that utilize the functions. We shouldn't need to add any additional commands unless needed, even though commotiond now supports additional ones. Below is a list of all commotiond commands:
up -same as before
down -same as before
status -same as before
state -same as before
profiles -replaces list_profiles
set -allows you to set profile values
get -allows you to get profile values
save -allows you to save a profile to a new file in the
profiles.d directory
new -allows you to create a new profile
delete -allows you to delete a profile
ipgen -allows you to generate an arbitrary IP
address from the nodeid
nodeid -run without arguments, prints the nodeid. Can also set the
nodeid.
OpenWRT's scripting interface for network configuration primarily utilizes shell script wrapper functions around the commotion command-line client in order to interact with commotiond. Those functions are included in https://github.com/opentechinstitute/commotiond/blob/master/openwrt/lib/functions/commotion.sh (installed as /lib/functions/commotion.sh on a node). Currently the functions are written assuming that they're using the old-format output from the daemon, as opposed to the new key-value JSON format. These functions need to be updated against the new output format and new commands.
Output is of an arbitrary key-value format:
with unique keys. Exact output per command is still being determined. Also, unlike before, the commotion client returns true or false correctly depending on whether the command succeeds. So for some commands, it may be as easy as running the command and interpreting $? in order to echo "Command succeeded!" or "Command failed!". Output can be parsed through grep, sed and the like, but ideal would be proper JSON parsing. OpenWRT has a shell script JSON parser in a shell library called jsn.sh or something similar, which they use for parsing JSON output.
The shell functions should retain their current output format to the extent possible so as to keep from having to update things in other Commotion scripts that utilize the functions. We shouldn't need to add any additional commands unless needed, even though commotiond now supports additional ones. Below is a list of all commotiond commands:
up -same as before
down -same as before
status -same as before
state -same as before
profiles -replaces list_profiles
set -allows you to set profile values
get -allows you to get profile values
save -allows you to save a profile to a new file in the
profiles.d directory
new -allows you to create a new profile
delete -allows you to delete a profile
ipgen -allows you to generate an arbitrary IP
address from the nodeid
nodeid -run without arguments, prints the nodeid. Can also set the
nodeid.