52b39fa99aa2e9304236e2f3c39f9c4a475db816
[clearscm.git] / clients / Ameriquest / bin / ccverify.pl
1 #!/usr/bin/perl -w
2 #################################################################################
3 #
4 # File:         ccverify.pl
5 # Description:  Verify that Rational Clearcase was installed correctly
6 # Author:       Andrew@DeFaria.com
7 # Created:      Mon Mar 15 08:48:24 PST 2004
8 # Language:     None
9 #
10 # (c) Copyright 2004, Andrew@DeFaria.com, all rights reserved.
11 #
12 ################################################################################
13 use strict;
14
15 my $ccverify    = "1.0";
16 my $logpath     = "\\\\rtnlprod02\\viewstore\\PMO\\CM_TOOLS\\log";
17 my $hostname    = `hostname`; chomp $hostname;
18 my $logfile     = "$logpath\\$hostname.log";
19 my $status      = 0;
20 my $tag         = "ccverify";
21
22 open LOGFILE, ">>$logfile"
23   or die "Unable to open logfile: $logfile - $!\n";
24
25 sub logmsg {
26   my $message = shift;
27
28   print "$message\n";
29   print LOGFILE "$message\n";
30 } # logmsg
31
32 sub mktag {
33   my $tag       = shift;
34
35   my $status    = system "cleartool lsvob \\$tag > NUL 2>&1";
36
37   if ($status ne 0) {
38     return system "cleartool mktag -vob -tag \\$tag \\\\rtnlprod01\\vobstore\\$tag.vbs > NUL 2>&1";
39   } # if
40 } # mktag
41
42 sub rmtag {
43   my $tag = shift;
44
45   return system "cleartool rmtag -vob \\$tag > NUL 2>&1";
46 } # rmtag
47
48 sub rmview {
49   my $tag = shift;
50
51   return system "cleartool rmview -force -tag $tag > NUL 2>&1";
52 } # rmview
53
54 sub mkview {
55   my $tag = shift;
56
57   my $status = system "cleartool lsview -short $tag > NUL 2>&1";
58
59   if ($status ne 0) {
60     return system "cleartool mkview -tag $tag -stgloc -auto > NUL 2>&1";
61   } else {
62     rmview $tag;
63     return system "cleartool mkview -tag $tag -stgloc -auto > NUL 2>&1";
64   } # if
65 } # mkview
66
67 sub mount_vob {
68   my $tag = shift;
69
70   mktag $tag;
71
72   return system "cleartool mount \\$tag > NUL 2>&1";
73 } # mount_vob
74
75 sub umount_vob {
76   my $tag = shift;
77
78   my $status =  system "cleartool umount \\$tag > NUL 2>&1";
79
80   rmtag $tag;
81
82   return $status;
83 } # umount_vob
84
85 my $version             = `cleartool -ver`;
86 my $primary_group       = $ENV {CLEARCASE_PRIMARY_GROUP};
87
88 my @hostinfo = `cleartool hostinfo -long`;
89 my $region = "Not Set";
90
91 foreach (@hostinfo) {
92   chomp;
93   if (/\s*Registry region:\s*(\S*)/) {
94     $region = $1;
95     last;
96   } # if
97 } # foreach
98
99 logmsg "CCVerify Version $ccverify";
100 logmsg "Verifying Clearcase installation on $hostname (" . scalar (localtime) . ")\n";
101 logmsg "Clearcase Version Information\n";
102 logmsg "$version\n";
103
104 if (!defined $primary_group) {
105   $primary_group = "<not set>";
106   $status++;
107 } # if
108
109 logmsg "Clearcase Primary Group:\t$primary_group";
110 logmsg "Clearcase Region:\t\t$region\n";
111
112 if (mkview ($tag) eq 0) {
113   logmsg "Created a dynamic view named $tag";
114 } else {
115   $status++;
116   logmsg "Unable to create the $tag dynamic view!";
117 } # if
118
119 if (mount_vob ($tag) eq 0) {
120   logmsg "Mounted the vob \\$tag";
121 } else {
122   $status++;
123   logmsg "Unable to mount the vob \\$tag";
124 } # if
125
126 if (umount_vob ($tag) eq 0) {
127   logmsg "Unmounted the vob \\$tag";
128 } else {
129   $status++;
130   logmsg "Unable to unmount vob \\$tag";
131 } # if
132
133 if (rmview ($tag) eq 0) {
134   logmsg "Removed view $tag";
135 } else {
136   $status++;
137   logmsg "Unable to remove view $tag";
138 } # if
139
140 if ($status eq 0) {
141   logmsg
142 "\n--------------------------------------------
143 Clearcase installed and functioning properly
144 --------------------------------------------\n";
145 } else {
146   logmsg
147 "\n------------------------------------------------
148 Clearcase NOT installed and functioning properly
149 ------------------------------------------------\n";
150 } # if
151
152 exit $status;