Commit 398172e2 authored by Alessandro Rubini's avatar Alessandro Rubini

/wr/bin: added change_dot-config and documented it

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 9a376bca
......@@ -805,7 +805,11 @@ The main components are:
@end table
The most important tools in @file{userspace/tools} are the following:
@sc{wrs} user space includes also some tools and scripts. Tools
are build from source files in @file{userspace/tools} while the
scripts are copied directly from @file{userspace/rootfs_override/wr/bin}.
The following tools and scripts are provided:
@table @file
......@@ -832,7 +836,7 @@ The most important tools in @file{userspace/tools} are the following:
The program is a simple program for talking with serial ports.
@item wr_phytool
A tool to read and write PHY registers in the switch
A tool to read and write PHY registers in the switch.
@item wr_mon
A simple monitor of White Rabbit status. It prints to @i{stdout}
......@@ -874,6 +878,20 @@ The most important tools in @file{userspace/tools} are the following:
for each port and for the RTU daemon. The @t{--help} option
lists all configuration items of the tool.
@item apply_dot-config
The script is used to apply @t{dot-config} settings to the
current configuration files. It is run at boot time before
any service is started. The @t{dot-config} mechanism is
documented in the @i{@sc{wrs} Users' Manual}.
@item change_dot-config
This script changes the current @t{dot-config} file. It is
designed to be the back-end of the web interface, when changing
configuration items. The script does nothing to @i{apply}
the changes, and it only performs editing.
It is the responsibility of the caller to ensure the proper
service is restarted with the new configuration.
@item sdb-read
The tool, copied from the @t{fpga-config-space} project,
is documented in the next section,
......
#!/bin/sh
# Change a configuration item in dot-config. "=n" is special and it means
# the option is being unset. "=y" remains unquoted, all the rest is quoted.
# We still lack support for integers, not used in wrs' .config so far.
dotconfig="/wr/etc/dot-config"
for action in "$*"; do
# We accept both CONFIG_THIS= and THIS=
item="CONFIG_$(echo $action | cut -d= -f 1 | sed 's/^CONFIG_//')"
value=$(echo $action | cut -d= -f 2)
if [ "$value" = "n" ]; then
line="# $item is not set"
else
if [ "$value" = "y" ]; then
line="${item}=y"
else
line="${item}=\"$value\""
fi
fi
# now, a config item may be a substring of another one: careful
sed -i -e "/^${item}=/d" -e "/# ${item} is/d" $dotconfig
echo $line >> $dotconfig
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment