893e0b
#!/bin/sh
893e0b
893e0b
SRC_FILE_MB=$1
893e0b
893e0b
while true
893e0b
do
893e0b
    DD_PID=`pidof dd`
893e0b
    if [ -n "$DD_PID" ]; then
893e0b
        break
893e0b
    fi
893e0b
done
893e0b
893e0b
while true
893e0b
do
893e0b
    sleep 5
893e0b
    if [ ! -d /proc/$DD_PID ]; then
893e0b
        break
893e0b
    fi
893e0b
893e0b
    kill -s USR1 $DD_PID
893e0b
    CURRENT_SIZE=`tail -n 1 /tmp/dd_progress_file | sed "s/[^0-9].*//g"`
893e0b
    [ -n "$CURRENT_SIZE" ] && {
893e0b
        CURRENT_MB=$(($CURRENT_SIZE / 1048576))
893e0b
        echo -e "Copied $CURRENT_MB MB / $SRC_FILE_MB MB\r"
893e0b
    }
893e0b
done
893e0b
893e0b
rm -f /tmp/dd_progress_file