From 14d85d16d8f94117824949dd65c0d73599f37149 Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Wed, 24 Sep 2008 15:13:49 +0000 Subject: * added tftp wrapper function git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2242 95ad53e4-c205-0410-b2fa-d234c58c8868 --- initramfs/stage3-stuff/etc/functions | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'initramfs/stage3-stuff/etc/functions') 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 [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 [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 -- cgit v1.2.3-55-g7522