[LEDE-DEV] [PATCH] base-files: sysupgrade. Added the ability to use URL as source

adron at yapic.net adron at yapic.net
Mon Jul 4 05:17:10 PDT 2016


From: Sergey Sergeev <adron at yapic.net>

I did not encapsulate the logic in get_image() because too much code
(like dd if=...) expects to work with the file instead of url. And
use get_image would lead to repeated data reloads from url.

Signed-off-by: Sergey Sergeev <adron at yapic.net>
---
 package/base-files/files/sbin/sysupgrade | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
index 2f441f8..3c0ddbe 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -101,6 +101,27 @@ EOF
 # prevent messages from clobbering the tarball when using stdout
 [ "$CONF_BACKUP" = "-" ] && export VERBOSE=0
 
+wget_if_URL(){
+	local url="$1"
+	local url_repl_file="/tmp/sysupgrade-URL.bin"
+	case "$url" in
+		http://*|https://*|ftp://*) break ;;
+		*) return 1 ;;
+	esac
+	rm -f $url_repl_file
+	wget "$url" -O "$url_repl_file" || {
+		echo "Wget return error $? for url '$url'"
+		echo "Exiting"
+		rm -f $url_repl_file
+		exit 1
+	}
+	ARGV=${ARGV/"$url"/"$url_repl_file"}
+	return 0
+}
+
+# if URL was specified then download image file throw wget
+wget_if_URL "$ARGV"
+
 add_uci_conffiles() {
 	local file="$1"
 	( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \
-- 
1.9.1




More information about the Lede-dev mailing list