2 # Shell script for interacting with config files
4 # Copyright (C) 2006 by Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
5 # Copyright (C) 2006 by 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
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 /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 ""
141 show) echo "$0 show [<package>[.<config>]]";;
142 get) echo "$0 get <package>.<config>.<option>";;
143 set) echo "$0 set <package>.<config>[.<option>]=<value>";;
144 del) echo "$0 del <package>.<config>[.<option>]";;
145 rename) echo "$0 rename <package> <config> <name>";;
146 commit) echo "$0 commit [<package> ... ]";;
148 echo "Syntax: $0 <command> <arguments...>"
162 if [ $# -eq 0 ] ; then
171 del) do_remove "$@";;
172 rename) do_rename "$@";;
175 commit) do_commit "$@";;