1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-27 17:13:11 +02:00

uci: allow shell scripts to override the config dir (patch by cshore)

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19351 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
nbd 2010-01-27 04:59:14 +00:00
parent a4466d369d
commit 6dd7336b5a

View File

@ -30,7 +30,7 @@ uci_load() {
export ${NO_EXPORT:+-n} CONFIG_SECTION=
fi
DATA="$(/sbin/uci ${LOAD_STATE:+-P /var/state} -S -n export "$PACKAGE" 2>/dev/null)"
DATA="$(/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} ${LOAD_STATE:+-P /var/state} -S -n export "$PACKAGE" 2>/dev/null)"
RET="$?"
[ "$RET" != 0 -o -z "$DATA" ] || eval "$DATA"
unset DATA
@ -41,9 +41,9 @@ uci_load() {
uci_set_default() {
local PACKAGE="$1"
/sbin/uci -q show "$1" > /dev/null && return 0
/sbin/uci import "$1"
/sbin/uci commit "$1"
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q show "$1" > /dev/null && return 0
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} import "$1"
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit "$1"
}
uci_revert_state() {
@ -51,7 +51,7 @@ uci_revert_state() {
local CONFIG="$2"
local OPTION="$3"
/sbin/uci -P /var/state revert "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state revert "$PACKAGE${CONFIG:+.$CONFIG}${OPTION:+.$OPTION}"
}
uci_set_state() {
@ -61,7 +61,7 @@ uci_set_state() {
local VALUE="$4"
[ "$#" = 4 ] || return 0
/sbin/uci -P /var/state set "$PACKAGE.$CONFIG${OPTION:+.$OPTION}=$VALUE"
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state set "$PACKAGE.$CONFIG${OPTION:+.$OPTION}=$VALUE"
}
uci_set() {
@ -70,7 +70,7 @@ uci_set() {
local OPTION="$3"
local VALUE="$4"
/sbin/uci set "$PACKAGE.$CONFIG.$OPTION=$VALUE"
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG.$OPTION=$VALUE"
}
uci_add() {
@ -81,7 +81,7 @@ uci_add() {
if [ -z "$CONFIG" ]; then
export ${NO_EXPORT:+-n} CONFIG_SECTION="$(/sbin/uci add "$PACKAGE" "$TYPE")"
else
/sbin/uci set "$PACKAGE.$CONFIG=$TYPE"
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} set "$PACKAGE.$CONFIG=$TYPE"
export ${NO_EXPORT:+-n} CONFIG_SECTION="$CONFIG"
fi
}
@ -91,7 +91,7 @@ uci_rename() {
local CONFIG="$2"
local VALUE="$3"
/sbin/uci rename "$PACKAGE.$CONFIG=$VALUE"
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} rename "$PACKAGE.$CONFIG=$VALUE"
}
uci_remove() {
@ -99,10 +99,10 @@ uci_remove() {
local CONFIG="$2"
local OPTION="$3"
/sbin/uci del "$PACKAGE.$CONFIG${OPTION:+.$OPTION}"
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} del "$PACKAGE.$CONFIG${OPTION:+.$OPTION}"
}
uci_commit() {
local PACKAGE="$1"
/sbin/uci commit $PACKAGE
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} commit $PACKAGE
}