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