Merge commit 'origin/zrlang'
This commit is contained in:
@@ -83,13 +83,13 @@ setArgument(){
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! "${ACTIVELIST}" ];then
|
||||
if [ -z "${ACTIVELIST}" ];then
|
||||
ACTIVENUM=0
|
||||
else
|
||||
ACTIVENUM=`echo $ACTIVELIST | tr , ' ' | wc -w`
|
||||
fi
|
||||
|
||||
if [ ! "${SPARELIST}" ]; then
|
||||
if [ -z "${SPARELIST}" ]; then
|
||||
SPARENUM=0
|
||||
else
|
||||
SPARENUM=`echo $SPARELIST | tr , ' ' | wc -w`
|
||||
@@ -147,7 +147,7 @@ testBeforeMkraid(){
|
||||
# used"
|
||||
for i in ${DEVICELIST}
|
||||
do
|
||||
if mdadm -Ds -v | grep -w $i ; then
|
||||
if mdadm -Ds -v | grep -w $i >>${DEV_LOG} 2>>${DEV_LOG} ; then
|
||||
info "incorrect active and spare devices name, maybe it has been used"
|
||||
return 6
|
||||
fi
|
||||
@@ -164,7 +164,7 @@ testBeforeMkraid(){
|
||||
testAfterCreate(){
|
||||
#test "(7) create or assimble raid device lose"
|
||||
if [ "${1}" != "0" ];then
|
||||
info "create or assimble $RAIDNAME lose" >>${LOGDIR}${LOGFILE} 2>>${LOGDIR}${LOGFILE}
|
||||
info "create or assimble $RAIDNAME lose"
|
||||
return 7
|
||||
fi
|
||||
return 0
|
||||
@@ -182,10 +182,10 @@ usage(){
|
||||
echo "According to the arguments,this shell make raid by create mode. Before make it, there is some testing for the arguments, and the ERRNO will be setted to the approprate value. This shell support RAID0 1 5 and 10 at present. "
|
||||
echo""
|
||||
echo "ARGUMENT:
|
||||
<raidname> -- RAID devices name, example \"/dev/mdX\"
|
||||
<raidlevel> -- RAID level, example \"0, 1, 5, 10\"
|
||||
<activelist> -- the RAID active member's list, the interval symbol must be ',',example \"/dev/sda1,/dev/sdb1,/dev/sdc1,/dev/hda1 ... \"
|
||||
<sparelist> -- the RAID spare member's list, this is not must. the interval symbol same as activelist"
|
||||
<raidname> -- RAID devices name, example /dev/mdX
|
||||
<raidlevel> -- RAID level, example 0, 1, 5, 10
|
||||
<activelist> -- the RAID active member list, the interval symbol must be ',',example /dev/sda1,/dev/sdb1,/dev/sdc1,/dev/hda1 ...
|
||||
<sparelist> -- the RAID spare member list, this is not must. the interval symbol same as activelist"
|
||||
echo ""
|
||||
echo "RETURN VALUE:
|
||||
7 create or assimble raid device lose
|
||||
@@ -195,15 +195,14 @@ usage(){
|
||||
3 the raid name has exist
|
||||
2 this levelY need more devices
|
||||
1 error argument to the mkraid from user
|
||||
0 make raid allright
|
||||
The ERRNO will be setted to the approprate value and the return value will be return. The raid confgure message will output on stdout."
|
||||
0 make raid allright"
|
||||
echo ""
|
||||
echo "EXAMPLE:
|
||||
If you want to make raid1 named the /dev/md0 with two active devices named /dev/sda1 /dev/sdb1 and one spare device named /dev/sdc1, you can write for this:"
|
||||
echo ""
|
||||
echo " mkraid -n /dev/md0 -l 1 -a /dev/sda1,/dev/sdb1 -s /dev/sdc1"
|
||||
echo ""
|
||||
echo "But if you want to make raid0 with spare devices, there will be some mistake and exit with 5. Other mistake please watch by yourself."
|
||||
echo "But if you want to make raid0 with spare devices, there will be some mistake and exiting with 5. Other mistake please watch by yourself."
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Report bugs to <zrlang@linx-info.com>"
|
||||
@@ -226,7 +225,7 @@ else
|
||||
op_x="-x$SPARENUM"
|
||||
fi
|
||||
|
||||
echo yes | mdadm -C -q $RAIDNAME -l$RAIDLEVEL -n$ACTIVENUM $op_x $DEVICELIST >>${DEV_LOG} 2>>${DEV_LOG}
|
||||
yes| mdadm -C -q $RAIDNAME -l$RAIDLEVEL -n$ACTIVENUM $op_x $DEVICELIST >>${DEV_LOG} 2>>${DEV_LOG}
|
||||
testAfterCreate $?; erv
|
||||
|
||||
info "make $RAIDNAME allright"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./functions
|
||||
if [ $1 == "--help" -o $1 == "-h" ];then
|
||||
echo "mkraidconf.sh [-h|--help] <conf_path>"
|
||||
echo " This shell make the raid's configure file, the command follow the path of the file, for example /mnt/etc/mdadm.conf. If in the cdrom suggest to use /mnt/etc/mdadm.conf, and in the disk suggest to use /etc/mdadm.conf.Other path you can try, but it may be not work conveniently for the mdadm."
|
||||
@@ -8,18 +8,23 @@ if [ $1 == "--help" -o $1 == "-h" ];then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n $1 ]; then
|
||||
echo "error argument, please look the usage by --help or -h"
|
||||
if [ -z $1 ]; then
|
||||
info "empty argument, please look the usage by --help or -h"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CONDIR=`dirname $1`
|
||||
if [ ! -d $CONDIR ]; then
|
||||
mkdir -p $CONDIR
|
||||
mkdir -p $CONDIR >>${DEV_LOG} 2>>${DEV_LOG}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "error argument, please look the usage by --help or -h"
|
||||
info "make directory ${CONDIR} lose, please look the usage by --help or -h"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
mdadm -Ds -v > $1
|
||||
|
||||
mdadm -Ds -v > $1 2>>${DEV_LOG}
|
||||
if [ $? -eq 0 ];then
|
||||
info "make $1 allright"
|
||||
else
|
||||
info "make $1 lose"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user