kexec-tools/dracut-monitor_dd_progress
Dave Young e779fc632b monitor-dd-progress fix
stdout if line buffered, thus even it's redirect to stderr, it will not show
on console automaticly. Because monitor_dd_progress is only for rawdump
currently, so I think we can just use "echo" instead of "echo -n".

Another problem is sometimes CURRENT_SIZE does not get value when it's used
in $(($CURRENT_SIZE / 1048576)), fix this issue as well.

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: WANG Chao <chaowang@redhat.com>
2013-06-25 16:45:59 +08:00

29 lines
482 B
Bash

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