summaryrefslogtreecommitdiff
path: root/contrib/aix/inventory.sh
blob: 78df0d16e7a7ddb09ac9c59c156a2d580a4bda25 (plain)
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
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
#
# inventory.sh
#
# Originall written by Ben Lindstrom, modified by Darren Tucker to use perl
#
# This will produced and AIX package inventory file, which looks like:
#
# /usr/local/bin:
#          class=apply,inventory,openssh
#          owner=root
#          group=system
#          mode=755
#          type=DIRECTORY
# /usr/local/bin/slogin:
#          class=apply,inventory,openssh
#          owner=root
#          group=system
#          mode=777
#          type=SYMLINK
#          target=ssh
# /usr/local/share/Ssh.bin:
#          class=apply,inventory,openssh
#          owner=root
#          group=system
#          mode=644
#          type=FILE
#          size=VOLATILE
#          checksum=VOLATILE

find . ! -name . -print | perl -ne '{
	chomp;
	if ( -l $_ ) {
		($dev,$ino,$mod,$nl,$uid,$gid,$rdev,$sz,$at,$mt,$ct,$bsz,$blk)=lstat;
	} else {
		($dev,$ino,$mod,$nl,$uid,$gid,$rdev,$sz,$at,$mt,$ct,$bsz,$blk)=stat;
	}

	# Start to display inventory information
	$name = $_;
	$name =~ s|^.||;	# Strip leading dot from path
	print "$name:\n";
	print "\tclass=apply,inventory,openssh\n";
	print "\towner=root\n";
	print "\tgroup=system\n";
	printf "\tmode=%lo\n", $mod & 07777;	# Mask perm bits
	
	if ( -l $_ ) {
		# Entry is SymLink
		print "\ttype=SYMLINK\n";
		printf "\ttarget=%s\n", readlink($_);
	} elsif ( -f $_ ) {
		# Entry is File
		print "\ttype=FILE\n";
		print "\tsize=$sz\n";
		print "\tchecksum=VOLATILE\n";
	} elsif ( -d $_ ) {
		# Entry is Directory
		print "\ttype=DIRECTORY\n";
	} 
}'