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