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