remove memleak patch because of issues with premature freeing of memory - i will...
[openwrt.git] / package / base-files / files / etc / functions.sh
index 4446931..ef28015 100755 (executable)
@@ -127,9 +127,9 @@ config_get_bool() {
        local _tmp
        config_get "_tmp" "$2" "$3"
        case "$_tmp" in
-               1|on|enabled) export ${NO_EXPORT:+-n} "$1=1";;
-               0|off|disabled) export ${NO_EXPORT:+-n} "$1=0";;
-               *) eval "$1=${4:-0}";;
+               1|on|true|enabled) export ${NO_EXPORT:+-n} "$1=1";;
+               0|off|false|disabled) export ${NO_EXPORT:+-n} "$1=0";;
+               *) eval "$1=$4";;
        esac
 }
 
@@ -146,14 +146,16 @@ config_set() {
 
 config_foreach() {
        local function="$1"
-       local type="$2"
+       [ "$#" -ge 1 ] && shift
+       local type="$1"
+       [ "$#" -ge 1 ] && shift
        local section cfgtype
        
        [ -z "$CONFIG_SECTIONS" ] && return 0
        for section in ${CONFIG_SECTIONS}; do
                config_get cfgtype "$section" TYPE
                [ -n "$type" -a "x$cfgtype" != "x$type" ] && continue
-               eval "$function \"\$section\""
+               eval "$function \"\$section\" \"\$@\""
        done
 }
 
@@ -215,3 +217,9 @@ jffs2_mark_erase() {
        }
        echo -e "\xde\xad\xc0\xde" | mtd -qq write - "$1"
 }
+
+uci_set_default() {
+       local PACKAGE="$1"
+       [ -e "/etc/config/$1" ] && return 0
+       cat > "/etc/config/$1"
+}
This page took 0.025402 seconds and 4 git commands to generate.