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