Imported Upstream version 2.4.4p3
[debian/amanda] / client-src / amhpfixdevs.sh
1
2 eval '(exit $?0)' && eval 'exec perl -x -S $0 ${1+"$@"}'
3         & eval 'exec perl -x -S $0 $argv:q'
4                 if 0;
5
6 #!perl
7
8 # Check whether we're on a HP-UX system.
9 $uname=`uname`;
10 chomp $uname;
11 if ( $uname ne "HP-UX" ) {
12         print "Sorry, this script only works for HP-UX systems!\n";
13         exit 1;
14 }
15
16 # Check whether the user is root.
17 $id=`id -un`;
18 chomp $id;
19 if ( $id ne "root" ) {
20         print "Sorry, this script needs to be run by the superuser!\n";
21         exit 1;
22 }
23
24 # Determine all volume groups and the logical volumes in these volume groups.
25 print "\n\nScanning volume groups...\n";
26 open(LV, "vgdisplay -v 2>/dev/null |") or
27   die "$0: unable to open vgdisplay pipe: $!\n";
28 while ( <LV> ) {
29         if ( m!^(VG Name\s+/dev/)(.*)! ) {
30                 print "\n" if $v;
31                 $v = $2;
32                 print "The volume group $v contains the following logical volumes:\n";
33         }
34         elsif ( m!(\s+LV Name\s+/dev/$v/)(.*)! ) {
35                 print "\t$2\n";
36                 $vg{$v} .= "$2 ";
37         }
38 }
39 close LV or
40   warn "$0: error in closing vgdisplay pipe: $!\n";
41
42 # Now fix the device entries for all logical volumes.
43 print "\n\nFixing device entries...\n";
44 foreach $v ( keys(%vg) ) {
45         foreach $w ( split(/[\s]+/, $vg{$v} ) ) {
46                 # First the link for the block device.
47                 if ( ! -e "/dev/dsk/${v}_$w" ) {
48                         print "Creating link for /dev/dsk/${v}_$w...";
49                         if ( ! symlink("/dev/$v/$w", "/dev/dsk/${v}_$w") ) {
50                                 print "FAILED\n";
51                                 next;
52                         }
53                         print "done\n";
54                 }
55
56                 # Now the link for the raw devive.
57                 if ( ! -e "/dev/rdsk/${v}_$w" ) {
58                         print "Creating link for /dev/rdsk/${v}_$w...";
59                         if ( ! symlink("/dev/$v/r$w", "/dev/rdsk/${v}_$w") ) {
60                                 print "FAILED\n";
61                                 next;
62                         }
63                         print "done\n";
64                 }
65         }
66 }