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
50 [ $?
-ne 3 -a $?
-ne 2 ] && {
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
89 [ lock
= "${package##*.}" ] && continue # ignore .lock files
99 strtok
"$*" PACKAGE . CONFIG
$SEP DUMMY
105 for package
in ${PACKAGE:-$(cd $UCI_ROOT/etc/config; ls)}; do
109 if [ -z "$CONFIG" -o .
"$CONFIG" = .
"$2" ]; then
112 append
"${CONFIG_SECTION}_VARS" "$1"
123 for section
in $SECTION; do
124 config_get
type "$section" TYPE
125 [ -z "$type" ] && continue
126 echo "$package.$section=$type"
127 eval "VARS=\"\${${section}_VARS}\""
129 config_get val
"$section" "$var"
131 echo "$package.$section.$var=$val"
132 config_set
"$section" "$var" ""
135 config_set
"$section" TYPE
""
145 uci_validate
"$1" ||
exit "$?"
150 show
) echo "$0 show [<package>[.<config>]]";;
151 get
) echo "$0 get <package>.<config>.<option>";;
152 set) echo "$0 set <package>.<config>[.<option>]=<value>";;
153 del
) echo "$0 del <package>.<config>[.<option>]";;
154 rename
) echo "$0 rename <package> <config> <name>";;
155 commit
) echo "$0 commit [<package> ... ]";;
156 validate
) echo "$0 validate <package>";;
158 echo "Syntax: $0 <command> <arguments...>"
173 if [ $# -eq 0 ] ; then
182 del
) do_remove
"$@";;
183 rename
) do_rename
"$@";;
186 commit
) do_commit
"$@";;
187 validate
) do_validate
"$@";;