
- This instruction extends the functionality of UCI.
- Follow the automated section for quick setup.
- Validate and compare UCI configurations.
- Wrap UCI calls to provide a seamless invocation method.
- Rely on UCI to validate configurations.
- Rely on diff to identify configuration changes.
¶ Commands
| Sub-command |
Description |
validate [<confs>] |
Validate UCI configurations. |
diff <oldconf> [<newconf>] |
Compare UCI configurations, requires diffutils. |
# Configure profile
mkdir -p /etc/profile.d
cat << "EOF" > /etc/profile.d/uci.sh
uci() {
local UCI_CMD="${1}"
case "${UCI_CMD}" in
(validate|diff) uci_"${@}" ;;
(*) command uci "${@}" ;;
esac
}
uci_validate() {
local UCI_CONF="${@:-/etc/config/*}"
for UCI_CONF in ${UCI_CONF}
do if ! uci show "${UCI_CONF}" > /dev/null
then echo "${UCI_CONF}"
fi
done
}
uci_diff() {
local UCI_OCONF="${1:?}"
local UCI_NCONF="${2:-${1}-opkg}"
local UCI_OTEMP="$(mktemp -t uci.XXXXXX)"
local UCI_NTEMP="$(mktemp -t uci.XXXXXX)"
uci export "${UCI_OCONF}" > "${UCI_OTEMP}"
uci export "${UCI_NCONF}" > "${UCI_NTEMP}"
diff -a -b -d -y "${UCI_OTEMP}" "${UCI_NTEMP}"
rm -f "${UCI_OTEMP}" "${UCI_NTEMP}"
}
EOF
. /etc/profile.d/uci.sh
# Install packages
opkg update
opkg install diffutils
# Validate UCI configurations
uci validate
# Compare UCI configurations
opkg newconf
uci diff dhcp
wget -U "" -O uci-extras.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/uci_extras?codeblock=0"
. ./uci-extras.sh