From 91e23468129ebe074ccc411cd2733413543944c3 Mon Sep 17 00:00:00 2001 From: samunders-core Date: Tue, 25 Jun 2019 21:58:03 +0200 Subject: [PATCH] decrease code amount by reusing tftp_mget function --- livekitlib | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/livekitlib b/livekitlib index 2c61a60..11a01ed 100644 --- a/livekitlib +++ b/livekitlib @@ -446,6 +446,18 @@ mount_data_http() } +# stdin = files to get +# $1 = server +# $2 = destination directory +# +tftp_mget() +{ + while read FNAME; do + tftp -b 1486 -g -r "$FNAME" -l "$2/$FNAME" "$1" + done +} + + # Download data from tftp # $1 = target (store downloaded files there) # @@ -472,7 +484,7 @@ download_data_pxe() if [ $? -ne 0 ]; then echo "Error downloading from http://$SERVER:$PORT, trying TFTP" >&2 PROTOCOL=tftp - tftp -g -r PXEFILELIST -l "$1/PXEFILELIST" $SERVER + echo PXEFILELIST | tftp_mget "$SERVER" "$1" fi echo "* Downloading files from the list" >&2 @@ -484,7 +496,7 @@ download_data_pxe() else JOBS=3 for i in `seq 0 $((JOBS-1))`; do - awk "$i == NR % $JOBS"'{print("* "$0" ...") > "/dev/stderr";system("tftp -b 1486 -g -r "$0" -l '"$1/$LIVEKITNAME/"'"$0" '"$SERVER"'")}' < "$1/PXEFILELIST" & + awk "NR % $JOBS == $i {print}" < "$1/PXEFILELIST" | tftp_mget "$SERVER" "$1/$LIVEKITNAME" & done wait fi