2013-03-30 15:23:12 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Seconds to try to reread partition table
|
|
|
|
cnt=60
|
|
|
|
|
|
|
|
exec </dev/null
|
|
|
|
exec >"/tmp/${0##*/}.$$.out"
|
|
|
|
exec 2>&1
|
|
|
|
|
|
|
|
(
|
|
|
|
echo "Running: $0"
|
|
|
|
echo "Env:"
|
|
|
|
env | sort
|
|
|
|
|
|
|
|
while sleep 1; test $cnt != 0; do
|
2013-04-02 11:26:24 +00:00
|
|
|
echo "Trying to reread partition table on $DEVNAME ($cnt)"
|
2013-03-30 15:23:12 +00:00
|
|
|
: $((cnt--))
|
2013-04-02 11:26:24 +00:00
|
|
|
# If device node doesn't exist, it means the device was removed.
|
|
|
|
# Stop trying.
|
2013-03-30 15:23:12 +00:00
|
|
|
test -e "$DEVNAME" || { echo "$DEVNAME doesn't exist, aborting"; exit 1; }
|
|
|
|
#echo "$DEVNAME exists"
|
2013-04-02 11:26:24 +00:00
|
|
|
if blockdev --rereadpt "$DEVNAME"; then
|
|
|
|
echo "blockdev --rereadpt succeeded"
|
|
|
|
exit 0
|
|
|
|
fi
|
2013-03-30 15:23:12 +00:00
|
|
|
echo "blockdev --rereadpt failed, exit code: $?"
|
|
|
|
done
|
2013-04-02 11:26:24 +00:00
|
|
|
echo "Timed out"
|
2013-03-30 15:23:12 +00:00
|
|
|
) &
|