Removed /usr/local from CDPATH
[clearscm.git] / clearadm / processfilesystem.cgi
1 #!/usr/local/bin/perl
2
3 =pod
4
5 =head1 NAME $RCSfile: processfilesystem.cgi,v $
6
7 Delete a filesystem
8
9 =head1 VERSION
10
11 =over
12
13 =item Author
14
15 Andrew DeFaria <Andrew@ClearSCM.com>
16
17 =item Revision
18
19 $Revision: 1.4 $
20
21 =item Created:
22
23 Mon Oct 25 11:10:47 PDT 2008
24
25 =item Modified:
26
27 $Date: 2011/02/14 14:52:40 $
28
29 =back
30
31 =head1 SYNOPSIS
32
33  Usage processfileystem.cgi: [-u|sage] [-ve|rbose] [-d|ebug]
34                              action=[edit|delete]
35                              system=<system> filesystem=<filesystem>
36
37  Where:
38    -u|sage:    Displays usage
39    -ve|rbose:  Be verbose
40    -d|ebug:    Output debug messages
41    
42    action:     "edit" or "delete" to edit or delete the filesystem
43    system:     System
44    filesystem: Filesystem to delete
45
46 =head2 DESCRIPTION
47
48 This script edits or deletes a filessystem from Clearadm
49
50 =cut
51
52 use strict;
53 use warnings;
54
55 use FindBin;
56 use Getopt::Long;
57 use CGI qw (:standard :cgi-lib *table start_Tr end_Tr);
58 use CGI::Carp 'fatalsToBrowser';
59
60 use lib "$FindBin::Bin/lib", "$FindBin::Bin/../lib";
61
62 use Clearadm;
63 use ClearadmWeb;
64 use Display;
65 use Utils;
66
67 my $VERSION  = '$Revision: 1.4 $';
68   ($VERSION) = ($VERSION =~ /\$Revision: (.*) /);
69   
70 my $clearadm;
71
72 # Main
73 GetOptions (
74   usage      => sub { Usage },
75   verbose    => sub { set_verbose },
76   debug      => sub { set_debug },
77 ) or Usage 'Invalid parameter';
78
79 # Announce ourselves
80 verbose "$FindBin::Script v$VERSION";
81
82 $clearadm = Clearadm->new;
83
84 my %opts = Vars;
85
86 my $title = 'Process Filesystem: '
87           . ucfirst $opts{system}
88           . ":$opts{filesystem}";
89
90 heading $title;
91
92 unless ($opts{'delete.x'} or $opts{'edit.x'} or $opts{action}) {
93   displayError 'Action not defined!';
94   footing;
95   exit 1;
96 } # unless
97
98 unless ($opts{system}) {
99   displayError 'System not defined!';
100   footing;
101   exit 1;
102 } # unless
103
104 unless ($opts{filesystem}) {
105   displayError 'System not defined!';
106   footing;
107   exit 1;
108 } # unless
109
110 my ($err, $msg);
111
112 if ($opts{'delete.x'}) {
113   ($err, $msg) = $clearadm->DeleteFilesystem ($opts{system}, $opts{filesystem});
114    
115   if ($msg !~ /Records deleted/) {
116     displayError "Unable to delete $opts{system}:$opts{filesystem}\n$msg";
117   } else {
118     display h1 {
119       class => 'center'
120     }, 'Filesystem ' . ucfirst $opts{system} . ":$opts{filesystem} deleted";
121   } # if
122 } elsif ($opts{'edit.x'}) {
123   display h1 {
124     class => 'center'
125   }, 'Edit Filesystem: ', ucfirst $opts{system} . ":$opts{filesystem}";
126
127   editFilesystem ($opts{system}, $opts{filesystem});
128 } elsif ($opts{action} eq 'Post') {
129   delete $opts{action};
130   delete $opts{'edit.x'}
131     if $opts{'edit.x'};
132   delete $opts{'edit.y'}
133     if $opts{'edit.y'};
134   
135   ($err, $msg) = $clearadm->UpdateFilesystem (
136     $opts{system},
137     $opts{filesystem},
138     %opts
139   );
140   
141   if ($err) {
142     displayError "$msg (Status: $err)";
143   } else {
144     display h1 {class => 'center'}, ucfirst $opts{system} . ":$opts{filesystem} updated";
145     
146     displayFilesystem ($opts{system});
147   } # if
148 } else {
149   displayError "Unknown action - $opts{action}";
150 } # if
151
152 footing;
153
154 =pod
155
156 =head1 CONFIGURATION AND ENVIRONMENT
157
158 DEBUG: If set then $debug is set to this level.
159
160 VERBOSE: If set then $verbose is set to this level.
161
162 TRACE: If set then $trace is set to this level.
163
164 =head1 DEPENDENCIES
165
166 =head2 Perl Modules
167
168 L<CGI>
169
170 L<CGI::Carp|CGI::Carp>
171
172 L<FindBin>
173
174 L<Getopt::Long|Getopt::Long>
175
176 =head2 ClearSCM Perl Modules
177
178 =begin man 
179
180  Clearadm
181  ClearadmWeb
182  Display
183  Utils
184
185 =end man
186
187 =begin html
188
189 <blockquote>
190 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/Clearadm.pm">Clearadm</a><br>
191 <a href="http://clearscm.com/php/scm_man.php?file=clearadm/lib/ClearadmWeb.pm">ClearadmWeb</a><br>
192 <a href="http://clearscm.com/php/scm_man.php?file=lib/Display.pm">Display</a><br>
193 <a href="http://clearscm.com/php/scm_man.php?file=lib/Utils.pm">Utils</a><br>
194 </blockquote>
195
196 =end html
197
198 =head1 BUGS AND LIMITATIONS
199
200 There are no known bugs in this script
201
202 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
203
204 =head1 LICENSE AND COPYRIGHT
205
206 Copyright (c) 2010, ClearSCM, Inc. All rights reserved.
207
208 =cut