blob: 512e43fccc0fa35467e28359b56870d9478c4b3c [file] [log] [blame]
Denys Vlasenkoe306c112013-03-30 16:23:12 +01001#!/bin/sh
2
3# Seconds to try to reread partition table
4cnt=60
5
6exec </dev/null
7exec >"/tmp/${0##*/}.$$.out"
8exec 2>&1
9
10(
11echo "Running: $0"
12echo "Env:"
13env | sort
14
15while sleep 1; test $cnt != 0; do
Denys Vlasenko2df1c642013-04-02 13:26:24 +020016 echo "Trying to reread partition table on $DEVNAME ($cnt)"
Denys Vlasenkoe306c112013-03-30 16:23:12 +010017 : $((cnt--))
Denys Vlasenko2df1c642013-04-02 13:26:24 +020018 # If device node doesn't exist, it means the device was removed.
19 # Stop trying.
Denys Vlasenkoe306c112013-03-30 16:23:12 +010020 test -e "$DEVNAME" || { echo "$DEVNAME doesn't exist, aborting"; exit 1; }
21 #echo "$DEVNAME exists"
Denys Vlasenko2df1c642013-04-02 13:26:24 +020022 if blockdev --rereadpt "$DEVNAME"; then
23 echo "blockdev --rereadpt succeeded"
24 exit 0
25 fi
Denys Vlasenkoe306c112013-03-30 16:23:12 +010026 echo "blockdev --rereadpt failed, exit code: $?"
27done
Denys Vlasenko2df1c642013-04-02 13:26:24 +020028echo "Timed out"
Denys Vlasenkoe306c112013-03-30 16:23:12 +010029) &