2 # Shell script for interacting with config files
4 # Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
5 # Copyright (C) 2006,2007 Felix Fietkau <nbd@openwrt.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 .
$UCI_ROOT/etc
/functions.sh
22 include
$UCI_ROOT/lib
/config
32 strtok
"$*" PACKAGE . CONFIG . OPTION
$SEP DUMMY
40 config_get
"$CONFIG" "$OPTION"
49 strtok
"$1" PACKAGE . CONFIG
= VALUE
55 strtok
"$CONFIG" CONFIG . OPTION
58 uci_add
"$PACKAGE" "$VALUE" "$CONFIG"
60 uci_set
"$PACKAGE" "$CONFIG" "$OPTION" "$VALUE"
78 strtok
"$*" PACKAGE . CONFIG . OPTION
$SEP DUMMY
79 [ $?
-ne 3 -a $?
-ne 2 ] && {
83 uci_remove
"$PACKAGE" "$CONFIG" ${OPTION:+"$OPTION"}
88 for package
in ${PACKAGE:-$(cd /tmp/.uci; ls)}; do
98 strtok
"$*" PACKAGE . CONFIG
$SEP DUMMY
104 for package
in ${PACKAGE:-$(cd $UCI_ROOT/etc/config; ls)}; do
108 if [ -z "$CONFIG" -o "$CONFIG" = "$2" ]; then
111 append
"${CONFIG_SECTION}_VARS" "$1"
122 for section
in $SECTION; do
123 config_get
type "$section" TYPE
124 [ -z "$type" ] && continue
125 echo "$package.$section=$type"
126 eval "VARS=\"\${${section}_VARS}\""
128 config_get val
"$section" "$var"
130 echo "$package.$section.$var=$val"
131 config_set
"$section" "$var" ""
134 config_set
"$section" TYPE
""
144 uci_validate
"$1" ||
exit "$?"
149 show
) echo "$0 show [<package>[.<config>]]";;
150 get
) echo "$0 get <package>.<config>.<option>";;
151 set) echo "$0 set <package>.<config>[.<option>]=<value>";;
152 del
) echo "$0 del <package>.<config>[.<option>]";;
153 rename
) echo "$0 rename <package> <config> <name>";;
154 commit
) echo "$0 commit [<package> ... ]";;
155 validate
) echo "$0 validate <package>";;
157 echo "Syntax: $0 <command> <arguments...>"
172 if [ $# -eq 0 ] ; then
181 del
) do_remove
"$@";;
182 rename
) do_rename
"$@";;
185 commit
) do_commit
"$@";;
186 validate
) do_validate
"$@";;