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