contrib/meshwizard: Fix getting of mac address when the interface is not up yet,...
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / functions.sh
index 5e0e1941854053e11a491c15647baa1be5c60cbc..f8271498adae0ed34e73c9d6b7c36dfefbc95ecf 100644 (file)
@@ -12,17 +12,25 @@ uci_remove_list_element() {
        done
 }
 
-set_defaults() {
-       for def in $(env |grep "^$1"); do
-               option=${def/$1/}
-               uci set $2.$option
-               echo "    ${option/=/: }"
+# Takes 2 arguments
+# $1 = text to be displayed in the output for this section
+# $2 = section (optional)
+uci_commitverbose() {
+       echo "+ $1"
+       uci changes $2 | while read line; do
+               echo "    $line"
        done
+       uci commit $2
 }
 
-# 1 argument: section to remove
-section_cleanup() {
-       uci -q delete $1 && msg_cleanup $1 || msg_cleanup_error $1
+set_defaults() {
+       for def in $(env |grep "^$1" | sed 's/ /_/g'); do
+               option="${def/$1/}"
+               a="$(echo $option |cut -d '=' -f1)"
+               b="$(echo $option |cut -d '=' -f2)"
+               b="${b//_/ }"
+               uci set $2.$a="$b"
+       done
 }
 
 # 3 arguements: 1=config name 2=oldname 3=newname
@@ -30,18 +38,6 @@ section_rename() {
        uci -q rename $1.$2=$3 && msg_rename $1.$2 $1.$3 || msg_rename_error $1.2 $1.$3
 }
 
-msg_start() {
-       echo "  Starting configuration of $1"
-}
-
-msg_cleanup() {
-       echo "    Cleanup: Removed section $1."
-}
-
-msg_cleanup_error() {
-       echo -e "    \033[1mWarning:\033[0m Cleanup of $1 failed."
-}
-
 msg_missing_value() {
        echo -e "    \033[1mWarning:\033[0m Configuration option for $2 is missing in $1."
 }