6ebfb73ae440195a61f22b0f1e861231d87bffaf
1 # Shell script compatibility wrappers for /sbin/uci
3 # Copyright (C) 2008-2010 OpenWrt.org
4 # Copyright (C) 2008 Felix Fietkau <nbd@nbd.name>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 if [ -z "$CONFIG_APPEND" ]; then
29 for VAR
in $CONFIG_LIST_STATE; do
30 export ${NO_EXPORT:+-n} CONFIG_
${VAR}=
31 export ${NO_EXPORT:+-n} CONFIG_
${VAR}_LENGTH
=
33 export ${NO_EXPORT:+-n} CONFIG_LIST_STATE
=
34 export ${NO_EXPORT:+-n} CONFIG_SECTIONS
=
35 export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS
=0
36 export ${NO_EXPORT:+-n} CONFIG_SECTION
=
39 DATA
="$(/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${LOAD_STATE:+-P /var/state} -S -n export "$PACKAGE" 2>/dev/null)"
41 [ "$RET" != 0 -o -z "$DATA" ] ||
eval "$DATA"
44 ${CONFIG_SECTION:+config_cb}
50 /sbin
/uci
${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q show
"$PACKAGE" > /dev
/null
&& return 0
51 /sbin
/uci
${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} import
"$PACKAGE"
52 /sbin
/uci
${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
"$PACKAGE"
60 /sbin
/uci
${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state revert "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
69 [ "$#" = 4 ] || return 0
70 /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set "$PACKAGE.
$CONFIG${OPTION:+.$OPTION}=$VALUE"
74 uci_revert_state "$1" "$2" "$3"
75 uci_set_state "$1" "$2" "$3" "$4"
84 /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.
$CONFIG.
$OPTION=$VALUE"
93 /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} add_list "$PACKAGE.
$CONFIG.
$OPTION=$VALUE"
97 uci_get "$1" "$2" "$3" "$4" "/var
/state
"
107 /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${STATE:+-P $STATE} -q get "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
109 [ "$RET" -ne 0 ] && [ -n "$DEFAULT" ] && echo "$DEFAULT"
118 if [ -z "$CONFIG" ]; then
119 export ${NO_EXPORT:+-n} CONFIG_SECTION
="$(/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} add "$PACKAGE" "$TYPE")"
121 /sbin
/uci
${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG=$TYPE"
122 export ${NO_EXPORT:+-n} CONFIG_SECTION
="$CONFIG"
132 /sbin
/uci
${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} rename "$PACKAGE.$CONFIG${VALUE:+.$OPTION}=${VALUE:-$OPTION}"
140 /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} del "$PACKAGE.
$CONFIG${OPTION:+.$OPTION}"
149 /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} del_list "$PACKAGE.
$CONFIG.
$OPTION=$VALUE"
157 /sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} revert "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
162 /sbin
/uci
${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit
$PACKAGE