Chinaunix首页 | 论坛 | 博客
  • 博客访问: 208359
  • 博文数量: 35
  • 博客积分: 2691
  • 博客等级: 少校
  • 技术积分: 527
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-11 09:42
文章分类

全部博文(35)

文章存档

2012年(5)

2010年(6)

2009年(2)

2008年(22)

我的朋友

分类:

2009-12-24 10:13:53

 

#!/bin/sh


if [ $# -ne 7 ];then

    echo "startTask: fail(Param Error)"
    exit 1
fi

SRCPATH=/dev/$2
BLOCK=$(($4*1024*1024))
DISKSIZE=$5
DISKTYPE=$6
DISKTANKER=$7

if [ "$DISKTYPE" = "DISKGENERAL" ]; then
    DESTPATH=/dev/$3
    echo $3 | grep "hd" 2>&1> /dev/null
    if [ $? == 0 ]; then
        hdparm -d 1X66 -m 64 -c 3 $DESTPATH
    fi
    /home/kdcs/bin/kdcs $SRCPATH $DESTPATH $DISKSIZE 2>&1> /dev/null &
elif [ "$DISKTYPE" = "DISKFILE" ]; then
    DESTPATH=/dev/$3/$1
    mkdir -p $DESTPATH
    /home/kdcs/bin/kdcs $SRCPATH $DESTPATH $DISKSIZE $BLOCK 2>&1> /dev/null &
elif [ "$DISKTYPE" = "DISKCOUNTER" ]; then
    /home/kdcs/bin/mount_disk_tanker $DISKTANKER
    if [ $? != 0 ]; then
        echo "startTask: fail(DiskTanker Mount Failed)"
        exit 1;
    fi
    DESTPATH=/home/kdcs/data/$3/$1
    mkdir -p $DESTPATH
    /home/kdcs/bin/kdcs $SRCPATH $DESTPATH $DISKSIZE $BLOCK 2>&1> /dev/null &
else
    echo "startTask: fail(Param Error)"
    exit 1
fi

echo "startTask: success"
echo -e "\t \t \t \t \n"

#############################


#!/bin/bash


CONFIGFILE="/home/kdcs/config/kdcs.conf"

CMD=`basename $0`
CMD=`echo $CMD|awk -F \. '{print $1}'`
echo "$CMD:"
DISKTO=`cat $CONFIGFILE |grep disk_typeto|awk -F \" '{print $2}'`
SLOTLISTTO=`cat $CONFIGFILE |grep slot_to|grep value |awk -F \" '{print $2}'`
DISKFROM=`cat $CONFIGFILE |grep disk_typefrom|awk -F \" '{print $2}'`
SLOTLISTFROM=`cat $CONFIGFILE |grep slot_from|grep value |awk -F \" '{print $2}'`

#SEQ=1
if [ "
$DISKFROM" = "IDE" ] || [ "$DISKFROM" = "SCSI" ] || [ "$DISKFROM" = "SAS" ] || [ "$DISKFROM" = "SATA" ] || [ "$DISKFROM" = "USB" ] || [ "$DISKFROM" = "IEE1394" ]; then
    for SLOT in $SLOTLISTFROM; do
        DISK=`ls -l /dev/disk/by-path/$SLOT 2>/dev/null|awk -F "
->" '{print $2}'|awk -F / '{print $3}'`
#        DISK=$SLOT
        DISKMODEL=`udevinfo -q all -n $DISK 2>/dev/null |grep ID_MODEL \
            |awk -F \= '{print $2}'`
        DISKSERIAL=`udevinfo -q all -n $DISK 2>/dev/null |grep ID_SERIAL= \
            |awk -F \= '{print $2}' `
        DISKPLACE=`udevinfo -q all -n $DISK 2>/dev/null |grep P:|awk '{print $2}'`
        if [ -z "
$DISKPLACE" ];then
            continue;
        fi
        DISKSIZE=`cat /sys$DISKPLACE/size 2>/dev/null`
        if [ -n "
$DISKSIZE" ]; then
            DISKSIZE=$(($DISKSIZE*512))
        fi
        echo "
DISK:1,$DISK,$DISKMODEL,$DISKSERIAL,$DISKSIZE"
#        SEQ=`expr $SEQ + 1`
    done    
fi


if [ "
$DISKTO" = "IDE" ] || [ "$DISKTO" = "SCSI" ] || [ "$DISKTO" = "SAS" ] || [ "$DISKTO" = "SATA" ] || [ "$DISKTO" = "USB" ] ;then
    for SLOT in $SLOTLISTTO; do
        DISK=`ls -l /dev/disk/by-path/$SLOT 2>/dev/null|awk -F "
->" '{print $2}'|awk -F / '{print $3}'`
#        DISK=$SLOT
        DISKMODEL=`udevinfo -q all -n $DISK 2>/dev/null |grep ID_MODEL \
            |awk -F \= '{print $2}'`
        DISKSERIAL=`udevinfo -q all -n $DISK 2>/dev/null |grep ID_SERIAL= \
            |awk -F \= '{print $2}' `
        DISKPLACE=`udevinfo -q all -n $DISK 2>/dev/null |grep P:|awk '{print $2}'`
        if [ -z "
$DISKPLACE" ]; then
            continue
        fi
        DISKSIZE=`cat /sys$DISKPLACE/size 2>/dev/null`
        if [ -n "
$DISKSIZE" ]; then
            DISKSIZE=$(($DISKSIZE*512))
        fi
        echo "
DISK:2,$DISK,$DISKMODEL,$DISKSERIAL,$DISKSIZE"
#        SEQ=`expr $SEQ + 1`
    done
fi

echo -e "
\t \t \t \t \n


阅读(922) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~