X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/05adaa9794e41d02870a74a1ed7ba58cc59b9286..9e86b41ee9723d64e544156f1708310e9c023da7:/package/base-files/files/lib/config/uci.sh diff --git a/package/base-files/files/lib/config/uci.sh b/package/base-files/files/lib/config/uci.sh old mode 100755 new mode 100644 index 957c1bb7c..e0293363b --- a/package/base-files/files/lib/config/uci.sh +++ b/package/base-files/files/lib/config/uci.sh @@ -1,8 +1,8 @@ #!/bin/sh # Shell script defining macros for manipulating config files # -# Copyright (C) 2006 by Fokus Fraunhofer -# Copyright (C) 2006 by Felix Fietkau +# Copyright (C) 2006 Fokus Fraunhofer +# Copyright (C) 2006,2007 Felix Fietkau # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,21 +23,39 @@ uci_load() { config_load "$PACKAGE" local PACKAGE_BASE="$(basename "$PACKAGE")" [ -f "/tmp/.uci/${PACKAGE_BASE}" ] && { - . "/tmp/.uci/${PACKAGE_BASE}" + . "/tmp/.uci/${PACKAGE_BASE}" 2>/dev/null >/dev/null config_cb } } +uci_apply_defaults() {( + cd /etc/uci-defaults || return 0 + files="$(ls)" + [ -z "$files" ] && return 0 + mkdir -p /tmp/.uci + for file in $files; do + ( . "./$(basename $file)" ) && rm -f "$file" + done + uci commit +)} + +uci_call_awk() { + local CMD="$*" + awk -f $UCI_ROOT/lib/config/uci.awk -f - < "/tmp/.uci/$PACKAGE_BASE.new" && { mv -f "/tmp/.uci/$PACKAGE_BASE.new" "$CONFIG_FILENAME" && \ rm -f "/tmp/.uci/$PACKAGE_BASE" } ) - lock -u "/tmp/.uci/$PACKAGE_BASE.lock" + $LOCK -u "/tmp/.uci/$PACKAGE_BASE.lock" }