Changeset 290
- Timestamp:
- Mar 11, 2009, 7:51:54 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dasscm/dasscm
r289 r290 29 29 30 30 # Nagios return codes 31 my $RETURN_WARN = 1;32 my $RETURN_CRIT = 2;31 my $RETURN_WARN = 1; 32 my $RETURN_CRIT = 2; 33 33 my $RETURN_UNKNOWN = 3; 34 35 34 36 35 # documentation file (for usage) … … 278 277 } 279 278 280 281 279 # 282 280 # normalize path namens: … … 288 286 my $path = shift || ""; 289 287 290 if( $path =~ m|^/| ) { 288 if ( $path =~ m|^/| ) { 289 291 290 # full path 292 if( -d $path ) { 291 if ( -d $path ) { 292 293 293 # ensure, a directory ends with '/' 294 294 $path .= '/'; 295 295 } 296 } elsif( -d cwd() . '/' . $path ) { 297 # ensure, a directory ends with '/' 298 $path .= '/'; 296 } elsif ( -d cwd() . '/' . $path ) { 297 298 # ensure, a directory ends with '/' 299 $path .= '/'; 299 300 } 300 301 … … 304 305 return $path; 305 306 } 306 307 308 307 309 308 # … … 330 329 # herefore make sure, that if filename is a directory, 331 330 # it will end by "/" 332 $filename_prod = normalize_path( $filename_prod);331 $filename_prod = normalize_path($filename_prod); 333 332 334 333 ( my $basename, my $dirname_prod ) = fileparse($filename_prod); … … 340 339 341 340 my $dirname_repo = normalize_path( $DASSCM_REPO . "/" . $dirname_prod ); 342 my $filename_repo = normalize_path( "$dirname_repo/$basename");341 my $filename_repo = normalize_path("$dirname_repo/$basename"); 343 342 344 343 if ($verbose) { 345 344 print "filename_repo: " . $filename_repo . "\n"; 346 print "dirname_repo: " . $dirname_repo . "\n";345 print "dirname_repo: " . $dirname_repo . "\n"; 347 346 print "filename_prod: " . $filename_prod . "\n"; 348 print "dirname_prod: " . $dirname_prod . "\n"; 347 print "dirname_prod: " . $dirname_prod . "\n"; 349 348 print "basename: " . $basename . "\n"; 350 349 } … … 532 531 print @result; 533 532 if ( $rc_update != 0 ) { 534 error( "failed to update local repository ($update_path)");533 error("failed to update local repository ($update_path)"); 535 534 } elsif ( not $update_path ) { 536 535 … … 565 564 my $name = normalize_path($File::Find::name); 566 565 $name =~ s|^$dirname_repo||; 566 567 567 #print "($name)\n";# . $File::Find::dir . "\n"; 568 568 if ( not $name ) { 569 569 570 # name string is empty (top directory). 570 571 # do nothing … … 579 580 push( @links, $name ); 580 581 } elsif ( -d $_ ) { 582 581 583 #if( $name."/" eq dirname_repo ) { 582 # directories 583 push( @dirs, $name ); 584 # directories 585 push( @dirs, $name ); 586 584 587 #} 585 588 } elsif ( -f $_ ) { … … 590 593 push( @others, $name ); 591 594 } 592 }595 } 593 596 }, 594 597 ($filename_repo) … … 598 601 } 599 602 600 601 602 603 sub svn_revert( ;$ ) 603 604 { … … 616 617 my $path = shift || $DASSCM_REPO; 617 618 618 ( my $rc_update, my @result ) = run_command("$SVN status '$path'" 619 ( my $rc_update, my @result ) = run_command("$SVN status '$path'"); 619 620 620 621 if ( $rc_update != 0 ) { … … 622 623 error("failed to receive subversion repository information"); 623 624 } else { 624 foreach (@result) { 625 if ( s/^\? +//) {625 foreach (@result) { 626 if (s/^\? +//) { 626 627 chomp; 628 627 629 # if file is unknown to subversion (line starts with "?") 628 630 # remove it 629 631 print "removing $_\n"; 630 unlink( $_);632 unlink($_); 631 633 } 632 634 } … … 661 663 662 664 if ( -d $realfile ) { 665 663 666 # directory 664 if( !-d "$cvsworkfile" ) { 667 if ( !-d "$cvsworkfile" ) { 668 665 669 # real is directory, repository is not. This is a problem 666 670 $changedfiles{"$realfile"} = $cvsworkfile; … … 669 673 $removedfiles{"$realfile"} = $cvsworkfile; 670 674 } elsif ( !-r $realfile ) { 675 671 676 # don't have permission to read the file, 672 677 # can't check it … … 1129 1134 1130 1135 # return code for the shell 1131 my $return_code = $RETURN_OK;1136 my $return_code = $RETURN_OK; 1132 1137 my $return_string = "OK: no modified files"; 1133 1138 … … 1137 1142 # get modified files 1138 1143 ( my $refChangedFiles, my $refRemovedFiles, my $refUnknownFiles ) = 1139 getModifiedFiles( "/");1144 getModifiedFiles("/"); 1140 1145 my %changedfiles = %{$refChangedFiles}; 1141 1146 my %removedfiles = %{$refRemovedFiles}; … … 1144 1149 if ( %removedfiles or %changedfiles ) { 1145 1150 $return_string = "Warning: "; 1146 if( %changedfiles ) { 1147 $return_string .= "changed: " . join( ", ", ( keys %changedfiles ) ) . ". "; 1148 } 1149 if( %removedfiles ) { 1150 $return_string .= "removed: " . join( ", ", ( keys %removedfiles ) ) . ". "; 1151 if (%changedfiles) { 1152 $return_string .= 1153 "changed: " . join( ", ", ( keys %changedfiles ) ) . ". "; 1154 } 1155 if (%removedfiles) { 1156 $return_string .= 1157 "removed: " . join( ", ", ( keys %removedfiles ) ) . ". "; 1151 1158 } 1152 1159 if (%unknownfiles) { 1153 $return_string .= "unknown: " . join( ", ", ( keys %unknownfiles ) ) . ". "; 1160 $return_string .= 1161 "unknown: " . join( ", ", ( keys %unknownfiles ) ) . ". "; 1154 1162 } 1155 1163 $return_code = $RETURN_WARN; … … 1160 1168 #Unknown 1161 1169 1162 print $return_string . "\n";1170 print "$return_string\n"; 1163 1171 return $return_code; 1164 1172 } 1165 1166 1173 1167 1174 sub permissions() … … 1199 1206 } else { 1200 1207 1201 if( $command eq "permission" ) { 1208 if ( $command eq "permission" ) { 1209 1202 1210 # Pfad für Sicherungsdatei existiert nicht => schreiben auf stdout 1203 1211 # Alias Filehandle für stdout erzeugen 1204 1212 $return_code = $RETURN_WARN; 1205 *OUTFILE = *STDOUT;1213 *OUTFILE = *STDOUT; 1206 1214 } else { 1215 1207 1216 # TODO: improve this. Check for diff? 1208 1217 $return_code = $RETURN_CRIT; … … 1271 1280 } 1272 1281 1273 $DASSCM_PERMISSION_FILE = $config->{'DASSCM_PERMISSION_FILE'} || "/etc/permissions.d/dasscm.permission_backup"; 1282 $DASSCM_PERMISSION_FILE = $config->{'DASSCM_PERMISSION_FILE'} 1283 || "/etc/permissions.d/dasscm.permission_backup"; 1274 1284 1275 1285 # get command line options and store them in options hash … … 1323 1333 $return_code = check(); 1324 1334 } elsif (m/^permissions$/i) { 1325 $command = "permissions";1335 $command = "permissions"; 1326 1336 $return_code = permissions(); 1327 1337 } elsif (m/^cleanup$/i) {
Note:
See TracChangeset
for help on using the changeset viewer.