-
Notifications
You must be signed in to change notification settings - Fork 71
/
gen-hwcfg-disk.sh
executable file
·50 lines (45 loc) · 1.19 KB
/
gen-hwcfg-disk.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/sh
#
# gen-hwcfg-disk.sh
#
# Generates hwcfg file for all configured disks
#
if [ -x /sbin/ata_identify ]; then
ATA_ID=/sbin/ata_identify
elif [ -x /lib/klibc/bin/ata_identify ]; then
ATA_ID=/lib/klibc/bin/ata_identify
else
echo "ata_identify not found, please install udev"
exit 1
fi
hwcfg=/etc/sysconfig/hardware
if [ ! -d "$hwcfg" ]; then
echo "No hardware configuration directory found"
exit 1
fi
# IDE disks first
for ifname in /sys/block/hd*; do
id=$($ATA_ID /dev/${ifname##*/} 2> /dev/null)
if [ $? -eq 0 ]; then
filename="SATA_$id"
echo "Generate hwcfg file for $filename"
echo "DEVICE=${ifname##*/}" > ${hwcfg}/hwcfg-disk-id-${filename}
fi
done
# SCSI disks next
for ifname in /sys/block/sd*; do
if [ -d $ifname/device ]; then
read vendor < $ifname/device/vendor
if [ "$vendor" = "ATA" ]; then
# We need page 0x80 to get the serial number
page="-p 0x80"
else
page=
fi
scsi_id -g $page -s ${ifname#/sys} 2> /dev/null | while read vendor model serial; do
filename="${vendor}_${model}_${serial}"
echo "Generate hwcfg file for $filename"
echo "DEVICE=${ifname##*/}" > ${hwcfg}/hwcfg-disk-id-${filename}
done
fi
done