summaryrefslogtreecommitdiff
path: root/dracut-monitor_dd_progress
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2024-07-26 17:19:39 +0000
committerCoprDistGit <infra@openeuler.org>2024-07-26 17:19:39 +0000
commit5be00af7c80ed4972c1f3379e6db9937e1a8b7bd (patch)
tree7938404f19676c304f68d0d47e475fe4a1440452 /dracut-monitor_dd_progress
parentad07ec0c7538028e4d732f63e34d58150f5ffd42 (diff)
automatic import of kexec-tools
Diffstat (limited to 'dracut-monitor_dd_progress')
-rw-r--r--dracut-monitor_dd_progress28
1 files changed, 28 insertions, 0 deletions
diff --git a/dracut-monitor_dd_progress b/dracut-monitor_dd_progress
new file mode 100644
index 0000000..e139d33
--- /dev/null
+++ b/dracut-monitor_dd_progress
@@ -0,0 +1,28 @@
+#!/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