Created
April 20, 2011 06:33
-
-
Save tagomoris/930505 to your computer and use it in GitHub Desktop.
Run "check" about specified md device if it's status is "idle"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TARGET_MD=$1 | |
### call md verifying when idle. | |
###### | |
# HOW TO USE | |
### md_sync_call.sh md0 | |
error_exit() { | |
echo $* | |
exit 1 | |
} | |
is_root_user() { | |
UNAME=`whoami` | |
if [ $UNAME != "root" ]; then | |
error_exit "md_sync_call.sh: requested operation requires superuser privilege" | |
fi | |
return 0 | |
} | |
md_exists() { | |
if [ -d /sys/block/$TARGET_MD ]; then | |
return 0 | |
fi | |
error_exit "md_sync_call.sh: no such md:" $TARGET_MD | |
} | |
in_idle() { | |
MD_STATE=`cat /sys/block/$TARGET_MD/md/sync_action` | |
if [ $MD_STATE != "idle" ]; then | |
error_exit "md_sync_call.sh: target md" $TARGET_MD "is not in idle:" $MD_STATE | |
fi | |
return 0 | |
} | |
call_check() { | |
echo "check" > /sys/block/$TARGET_MD/md/sync_action | |
return 0 | |
} | |
is_root_user | |
md_exists | |
in_idle | |
call_check | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment