2 # Shell script defining macros for manipulating config files
4 # Copyright (C) 2006 by Fokus Fraunhofer <carsten.tittel@fokus.fraumhofer.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
22 config_load
"$PACKAGE"
23 local PACKAGE_BASE
="$(basename "$PACKAGE")"
24 [ -f "/tmp/.uci/${PACKAGE_BASE}" ] && {
25 .
"/tmp/.uci/${PACKAGE_BASE}"
33 awk -f /lib
/config
/uci-update.
awk -f - <<EOF
35 config = read_file("$FILENAME")
45 local PACKAGE_BASE
="$(basename "$PACKAGE")"
49 echo "$UPDATE" >> "/tmp/.uci/${PACKAGE_BASE}"
58 ( # spawn a subshell so you don't mess up the current environment
60 config_get
type "$CONFIG" TYPE
62 ) || uci_add_update
"$PACKAGE" "CONFIG_SECTION='$CONFIG'${N}option '$OPTION' '$VALUE'"
70 uci_add_update
"$PACKAGE" "config '$TYPE' '$CONFIG'"
78 uci_add_update
"$PACKAGE" "config_rename '$CONFIG' '$VALUE'"
86 if [ -z "$OPTION" ]; then
87 uci_add_update
"$PACKAGE" "config_clear '$CONFIG'"
89 uci_add_update
"$PACKAGE" "config_unset '$CONFIG' '$OPTION'"
95 local PACKAGE_BASE
="$(basename "$PACKAGE")"
98 lock
"/tmp/.uci/$PACKAGE_BASE.lock"
99 [ -f "/tmp/.uci/$PACKAGE_BASE" ] && (
104 append updatestr
"config = update_config(config, \"@$2=$1\")" "$N"
107 append updatestr
"config = update_config(config, \"$CONFIG_SECTION.$1=$2\")" "$N"
110 append updatestr
"config = update_config(config, \"&$1=$2\")" "$N"
113 append updatestr
"config = update_config(config, \"-$1.$2\")" "$N"
116 append updatestr
"config = update_config(config, \"-$1\")" "$N"
119 .
"/tmp/.uci/$PACKAGE_BASE"
121 # completely disable handlers so that they don't get in the way
129 config_load
"$PACKAGE" || CONFIG_FILENAME
="$ROOT/etc/config/$PACKAGE_BASE"
130 uci_do_update
"$CONFIG_FILENAME" "$updatestr" > "/tmp/.uci/$PACKAGE_BASE.new" && {
131 mv -f "/tmp/.uci/$PACKAGE_BASE.new" "$CONFIG_FILENAME" && \
132 rm -f "/tmp/.uci/$PACKAGE_BASE"
135 lock
-u "/tmp/.uci/$PACKAGE_BASE.lock"
This page took 0.059809 seconds and 5 git commands to generate.