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