]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/aix/inventory.sh
Vendor import of OpenSSH 7.7p1.
[FreeBSD/FreeBSD.git] / contrib / aix / inventory.sh
1 #!/bin/sh
2 #
3 # inventory.sh
4 #
5 # Originally written by Ben Lindstrom, modified by Darren Tucker to use perl
6 # This file is placed into the public domain.
7 #
8 # This will produce an AIX package inventory file, which looks like:
9 #
10 # /usr/local/bin:
11 #          class=apply,inventory,openssh
12 #          owner=root
13 #          group=system
14 #          mode=755
15 #          type=DIRECTORY
16 # /usr/local/bin/slogin:
17 #          class=apply,inventory,openssh
18 #          owner=root
19 #          group=system
20 #          mode=777
21 #          type=SYMLINK
22 #          target=ssh
23 # /usr/local/share/Ssh.bin:
24 #          class=apply,inventory,openssh
25 #          owner=root
26 #          group=system
27 #          mode=644
28 #          type=FILE
29 #          size=VOLATILE
30 #          checksum=VOLATILE
31
32 find . ! -name . -print | perl -ne '{
33         chomp;
34         if ( -l $_ ) {
35                 ($dev,$ino,$mod,$nl,$uid,$gid,$rdev,$sz,$at,$mt,$ct,$bsz,$blk)=lstat;
36         } else {
37                 ($dev,$ino,$mod,$nl,$uid,$gid,$rdev,$sz,$at,$mt,$ct,$bsz,$blk)=stat;
38         }
39
40         # Start to display inventory information
41         $name = $_;
42         $name =~ s|^.||;        # Strip leading dot from path
43         print "$name:\n";
44         print "\tclass=apply,inventory,openssh\n";
45         print "\towner=root\n";
46         print "\tgroup=system\n";
47         printf "\tmode=%lo\n", $mod & 07777;    # Mask perm bits
48         
49         if ( -l $_ ) {
50                 # Entry is SymLink
51                 print "\ttype=SYMLINK\n";
52                 printf "\ttarget=%s\n", readlink($_);
53         } elsif ( -f $_ ) {
54                 # Entry is File
55                 print "\ttype=FILE\n";
56                 print "\tsize=$sz\n";
57                 print "\tchecksum=VOLATILE\n";
58         } elsif ( -d $_ ) {
59                 # Entry is Directory
60                 print "\ttype=DIRECTORY\n";
61         }
62 }'