1#!/bin/sh /etc/rc.common 2CONFIG=/bin/config 3 4start() { 5 cat /proc/partitions | grep "sd" | awk '{print $4}' > /tmp/storage_device_info 6 if [ $? == 0 ]; then 7 while read LINE 8 do 9 if [ `length $LINE` == '4' ]; then 10 continue 11 fi 12 hdparm -i /dev/$LINE | grep Model > /dev/null 13 if [ $? == 0 ]; then 14 SATA=$LINE 15 echo "$SATA" > /tmp/SATA_SerialNo 16 SATA_SerialNo=`hdparm -i /dev/$LINE | grep SerialNo | awk -F = '{print $4}' | sed 's/[[:space:]]*$//' | sed 's/^[[:space:]]*//'` 17 echo "$SATA_SerialNo" >> /tmp/SATA_SerialNo 18 $CONFIG set sata_diskname=$SATA 19 $CONFIG set sata_serial_no="$SATA_SerialNo" 20 $CONFIG commit 21 break 22 fi 23 done < /tmp/storage_device_info 24 25 if [ ! -f /tmp/SATA_SerialNo ]; then 26 $CONFIG unset sata_diskname 27 $CONFIG unset sata_serial_no 28 $CONFIG commit 29 fi 30 31 rm /tmp/storage_device_info 32 fi 33 34 if [ "x$($CONFIG get sata_diskname)" != "x" ]; then 35 count=1 36 partition_count_max=`$CONFIG get sata_partition_count` 37 if [ "x$partition_count_max" != "x" ]; then 38 while [ $count -le $partition_count_max ] 39 do 40 if [ "x$($CONFIG get sata_partition$count)" != "x" ]; then 41 $CONFIG unset sata_partition$count 42 fi 43 count=`expr $count + 1` 44 done 45 fi 46 $CONFIG set sata_partition_count=0 47 $CONFIG set sata_partition_status=0 48 $CONFIG commit 49 fi 50} 51 52start 53 54