summaryrefslogtreecommitdiffstats
path: root/initramfs/stage3-stuff/etc/functions
diff options
context:
space:
mode:
Diffstat (limited to 'initramfs/stage3-stuff/etc/functions')
-rw-r--r--initramfs/stage3-stuff/etc/functions32
1 files changed, 32 insertions, 0 deletions
diff --git a/initramfs/stage3-stuff/etc/functions b/initramfs/stage3-stuff/etc/functions
index 9bb144d2..481ccf54 100644
--- a/initramfs/stage3-stuff/etc/functions
+++ b/initramfs/stage3-stuff/etc/functions
@@ -294,6 +294,38 @@ else
return 1
fi
}
+
+# tftp wrapper
+# usage tftp_get <path> <tftpdserver> [count]
+# count is optional - default is 3 - use -1 for indefinit
+function tftp_get () {
+ local file="$1"
+ local file_server="$2"
+ local download_successfull=false
+ local countdown="$3"
+
+ [ -z "$1" -o -z "$2" ] && \
+ echo "Usage: tftp_get <path> <server> [count]" &&
+ exit 0;
+
+ [ "$countdown" = "" ] && countdown=3
+
+ echo "tftp_get trying to get \"$file\" from \"$file_server\"..."
+
+ until ! [ $download_successfull ]
+ do
+ [ "$countdown" = "0" ] && return 0;
+ tftp -g -r $file -l /tmp/$(basename $file) $file_server
+ [ -s /tmp/$(basename $file) ] && download_successfull=true
+ (( countdown-- ))
+ sleep 0.2
+ ! [ "$countdown" = "0" ] && [ $download_successfull ] && \
+ echo "retry.."
+ done
+
+ return 1;
+}
+
fileget () {
# normally tftp would be used, alternatively use wget for ftp or http
# if local device file is specified - mount and unmount after copying