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