From 4e7fded1c43fd7396e9c442eaf30454fd2bc736c Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 27 Jan 2010 04:59:14 +0000 Subject: uci: allow shell scripts to override the config dir (patch by cshore) SVN-Revision: 19351 --- package/uci/files/lib/config/uci.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'package/uci') diff --git a/package/uci/files/lib/config/uci.sh b/package/uci/files/lib/config/uci.sh index 38f3097..851a0d7 100644 --- a/package/uci/files/lib/config/uci.sh +++ b/package/uci/files/lib/config/uci.sh @@ -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 } -- cgit v1.1