b0f6cb291ea6b844f52f8bc0dfe5085ae787e5f5
1 uci_remove_list_element
() {
4 local list
="$(uci get $option)"
9 if [ "$elem" != "$value" ]; then
10 uci add_list
$option=$elem
15 # string_contains(string, substring)
17 # Returns 0 if the specified string contains the specified substring,
18 # otherwise returns 1.
22 if test "${string#*$substring}" != "$string"
24 return 0 # $substring is in $string
26 return 1 # $substring is not in $string
31 # $1 = text to be displayed in the output for this section
32 # $2 = section (optional)
35 uci changes
$2 |
while read line
; do
42 for def
in $
(env |
grep "^$1" |
sed 's/ /_/g'); do
44 a
="$(echo $option |cut -d '=' -f1)"
45 b
="$(echo $option |cut -d '=' -f2-)"
47 string_contains
"$a" "_LENGTH" && continue
48 string_contains
"$a" "_ITEM" && {
49 # special threatment for lists. use add_list and remove the
50 # item index (_ITEMx).
51 uci add_list
$2.
${a//_ITEM[0-9]*/}="$b"
58 # 3 arguments: 1=config name 2=oldname 3=newname
60 uci
-q rename
$1.
$2=$3 && msg_rename
$1.
$2 $1.
$3 || msg_rename_error
$1.
$2 $1.
$3
64 echo -e " \033[1mWarning:\033[0m Configuration option for $2 is missing in $1."
72 echo " \033[1mError: \033[0mThere was a problem."
76 echo " Renamed unnamed section $1 to $2."
80 echo " \033[1mWarning:\033[0m Could not rename $1 to $2."
84 restore_factory_defaults
() {
85 echo "+ Restore default config as requested with cleanup=1"
86 cp -f /rom
/etc
/config
/* /etc
/config
/
87 rm /etc
/config
/wireless
88 wifi detect
> /etc
/config
/wireless
89 rm /etc
/config
/network
90 if [ -f /etc
/init.d
/defconfig
]; then
92 /etc
/init.d
/defconfig start
93 [ -f /rom
/etc
/uci-defaults
/network
] && sh
/rom
/etc
/uci-defaults
/network
95 sh
/rom
/etc
/uci-defaults
/02_network
100 # checks if an item is in a list
103 for word
in $list; do
104 [ $word = "$item" ] && return 0
112 is_in_list
"$list" "$item" && echo $list
113 if [ -z "$list" ]; then