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