[186] | 1 | #!/usr/bin/perl -w
|
---|
| 2 |
|
---|
| 3 | # $Id: dasscm 926 2010-07-30 16:45:47Z joergs $
|
---|
| 4 |
|
---|
| 5 | use strict;
|
---|
| 6 |
|
---|
[208] | 7 | use Env
|
---|
[235] | 8 | qw($DASSCM_PROD $DASSCM_REPO $USER $DASSCM_USERNAME $DASSCM_USER $DASSCM_PASSWORD $SHELL);
|
---|
[186] | 9 | use Cwd;
|
---|
[907] | 10 | use Getopt::Long;
|
---|
[186] | 11 | use File::Basename;
|
---|
[209] | 12 | use File::Compare;
|
---|
[891] | 13 | ## used system("cp -a"), because File::Copy does not keep permissions
|
---|
| 14 | ##use File::Copy;
|
---|
[237] | 15 | use File::Find;
|
---|
[186] | 16 | use File::stat;
|
---|
| 17 | use File::Path;
|
---|
[214] | 18 | use Term::ReadKey;
|
---|
[239] | 19 |
|
---|
[894] | 20 | use Data::Dumper;
|
---|
[186] | 21 |
|
---|
[189] | 22 | #####################################################################
|
---|
| 23 | #
|
---|
[186] | 24 | # global
|
---|
[189] | 25 | #
|
---|
[205] | 26 |
|
---|
[253] | 27 | # shell exit codes
|
---|
[252] | 28 | my $RETURN_OK = 0;
|
---|
| 29 | my $RETURN_NOK = 1;
|
---|
| 30 |
|
---|
[277] | 31 | # Nagios return codes
|
---|
[290] | 32 | my $RETURN_WARN = 1;
|
---|
| 33 | my $RETURN_CRIT = 2;
|
---|
[277] | 34 | my $RETURN_UNKNOWN = 3;
|
---|
| 35 |
|
---|
[238] | 36 | # documentation file (for usage)
|
---|
| 37 | my $doc_file = "/usr/share/doc/packages/dasscm/dasscm_howto.txt";
|
---|
| 38 |
|
---|
[884] | 39 | my $config_file = "/etc/dasscm.conf";
|
---|
| 40 | my $config = get_config($config_file);
|
---|
[252] | 41 |
|
---|
[894] | 42 | my @OPTIONS_GLOBAL = ( 'help', 'verbose' );
|
---|
| 43 |
|
---|
[884] | 44 | my %COMMANDS = (
|
---|
[889] | 45 | 'help' => 'help',
|
---|
| 46 | 'login' => 'login',
|
---|
| 47 | 'init' => 'init',
|
---|
| 48 | 'ls' => 'ls',
|
---|
| 49 | 'update' => 'update',
|
---|
| 50 | 'up' => 'update',
|
---|
| 51 | 'add' => 'add',
|
---|
| 52 | 'commit' => 'commit',
|
---|
| 53 | 'checkin' => 'commit',
|
---|
| 54 | 'ci' => 'commit',
|
---|
| 55 | 'revert' => 'revert',
|
---|
| 56 | 'blame' => 'blame',
|
---|
| 57 | 'diff' => 'diff',
|
---|
| 58 | 'status' => 'status',
|
---|
| 59 | 'st' => 'status',
|
---|
| 60 | 'check' => 'check',
|
---|
| 61 | 'permissions' => 'permissions',
|
---|
| 62 | 'cleanup' => 'cleanup',
|
---|
| 63 | 'complete' => 'complete',
|
---|
| 64 | 'complete_path' => 'complete_path',
|
---|
[887] | 65 | 'complete_repopath' => 'complete_repopath',
|
---|
[916] | 66 | 'plugins' => 'plugins',
|
---|
[884] | 67 | );
|
---|
| 68 |
|
---|
| 69 | # desc: description (eg. for usage)
|
---|
| 70 | # params: parameters
|
---|
| 71 | # CMD
|
---|
| 72 | # USER
|
---|
[891] | 73 | # PATH_PROD
|
---|
| 74 | # PATH_REPO
|
---|
[889] | 75 | # require:
|
---|
[884] | 76 | # WRITE commands that require write access (and therefore a login)
|
---|
| 77 | my %COMMAND_DEFINITIONS = (
|
---|
| 78 | 'help' => {
|
---|
[914] | 79 | 'desc' => ["print help and usage information"],
|
---|
[889] | 80 | 'params' => ["CMD"],
|
---|
[884] | 81 | 'function' => \&help,
|
---|
| 82 | },
|
---|
| 83 | 'login' => {
|
---|
[914] | 84 | 'desc' => ["user login to Subversion repositoty"],
|
---|
[889] | 85 | 'params' => ["USER"],
|
---|
[884] | 86 | 'function' => \&login
|
---|
| 87 | },
|
---|
| 88 | 'init' => {
|
---|
[889] | 89 | 'desc' => [
|
---|
| 90 | "initialize local subversion checkout.",
|
---|
| 91 | "This is the first thing to do (after configuring $config_file)"
|
---|
| 92 | ],
|
---|
| 93 | 'params' => [],
|
---|
[884] | 94 | 'function' => \&init
|
---|
| 95 | },
|
---|
| 96 | 'ls' => {
|
---|
[914] | 97 | 'desc' => ["list file from repository"],
|
---|
[891] | 98 | 'params' => ["PATH_REPO"],
|
---|
[884] | 99 | 'function' => \&ls
|
---|
| 100 | },
|
---|
| 101 | 'update' => {
|
---|
[914] | 102 | 'desc' => [
|
---|
| 103 | "update local repository checkout",
|
---|
| 104 | "Normally, this is done automatically"
|
---|
| 105 | ],
|
---|
[891] | 106 | 'params' => ["PATH_REPO"],
|
---|
[884] | 107 | 'function' => \&update
|
---|
| 108 | },
|
---|
| 109 | 'add' => {
|
---|
[914] | 110 | 'desc' => [
|
---|
| 111 | "add a file to the subversion repository",
|
---|
| 112 | "Unlike the native svn command,",
|
---|
| 113 | "dasscm adds and immediatly submits a file to the subversion repository"
|
---|
| 114 | ],
|
---|
[891] | 115 | 'params' => ["PATH_PROD"],
|
---|
[893] | 116 | 'options' => [ 'verbose', 'message=s' ],
|
---|
[889] | 117 | 'require' => ["WRITE"],
|
---|
[884] | 118 | 'function' => \&add
|
---|
| 119 | },
|
---|
| 120 | 'commit' => {
|
---|
[914] | 121 | 'desc' => ["commit a changed file to the subversion repository"],
|
---|
[895] | 122 | ## TODO: only modified files
|
---|
[891] | 123 | 'params' => ["PATH_REPO"],
|
---|
[893] | 124 | 'options' => [ 'verbose', 'message=s' ],
|
---|
[889] | 125 | 'require' => ["WRITE"],
|
---|
[884] | 126 | 'function' => \&commit
|
---|
| 127 | },
|
---|
| 128 | 'revert' => {
|
---|
[914] | 129 | 'desc' => [
|
---|
| 130 | "revert local changes back to version from the repository (see diff)"
|
---|
| 131 | ],
|
---|
[891] | 132 | 'params' => ["PATH_REPO"],
|
---|
[884] | 133 | 'function' => \&revert
|
---|
| 134 | },
|
---|
| 135 | 'blame' => {
|
---|
[914] | 136 | 'desc' => ['like "svn blame"'],
|
---|
[891] | 137 | ## TODO: only files from PATH_REPO
|
---|
| 138 | 'params' => ["PATH_REPO"],
|
---|
[884] | 139 | 'function' => \&blame
|
---|
| 140 | },
|
---|
| 141 | 'diff' => {
|
---|
[914] | 142 | 'desc' => [
|
---|
| 143 | 'display the differences between files on the system and the repository'
|
---|
| 144 | ],
|
---|
[891] | 145 | 'params' => ["PATH_REPO"],
|
---|
[884] | 146 | 'function' => \&diff
|
---|
| 147 | },
|
---|
| 148 | 'status' => {
|
---|
[914] | 149 | 'desc' => [
|
---|
| 150 | 'display status information about modified and deleted files.',
|
---|
| 151 | 'If no path is given "/" is assumed',
|
---|
| 152 | '(in contract to "svn" with assumes ".")'
|
---|
| 153 | ],
|
---|
[891] | 154 | 'params' => ["PATH_REPO"],
|
---|
[884] | 155 | 'function' => \&status
|
---|
| 156 | },
|
---|
| 157 | 'check' => {
|
---|
[889] | 158 | 'desc' => ["perform Nagios NRPE conform check"],
|
---|
| 159 | 'params' => [],
|
---|
[884] | 160 | 'function' => \&check
|
---|
| 161 | },
|
---|
| 162 | 'permissions' => {
|
---|
[914] | 163 | 'desc' =>
|
---|
[918] | 164 | ["internal, print permissions for all files in the repository"],
|
---|
[889] | 165 | 'params' => [],
|
---|
[884] | 166 | 'function' => \&permissions
|
---|
| 167 | },
|
---|
| 168 | 'cleanup' => {
|
---|
[914] | 169 | 'desc' => ["internal, used to clean repository checkout"],
|
---|
[889] | 170 | 'params' => [],
|
---|
[884] | 171 | 'function' => \&cleanup
|
---|
| 172 | },
|
---|
| 173 | 'complete' => {
|
---|
[914] | 174 | 'desc' => ["internal, used for bash completion"],
|
---|
[889] | 175 | 'params' => ["CMD"],
|
---|
[884] | 176 | 'function' => \&complete
|
---|
| 177 | },
|
---|
[887] | 178 | 'complete_path' => {
|
---|
[914] | 179 | 'desc' => ["internal, used for bash completion"],
|
---|
[889] | 180 | 'params' => [],
|
---|
[887] | 181 | 'function' => \&complete_path
|
---|
| 182 | },
|
---|
| 183 | 'complete_repopath' => {
|
---|
[914] | 184 | 'desc' => ["internal, used for bash completion"],
|
---|
[889] | 185 | 'params' => [],
|
---|
[887] | 186 | 'function' => \&complete_repopath
|
---|
| 187 | },
|
---|
[916] | 188 | 'plugins' => {
|
---|
| 189 | 'desc' => ["internal, perform plugins"],
|
---|
| 190 | 'params' => [],
|
---|
| 191 | 'function' => \&perform_plugins
|
---|
| 192 | },
|
---|
| 193 |
|
---|
[884] | 194 | );
|
---|
| 195 |
|
---|
[215] | 196 | # configuration file
|
---|
[205] | 197 | my $DASSCM_LOCAL_REPOSITORY_BASE;
|
---|
| 198 | my $DASSCM_REPOSITORY_NAME;
|
---|
[916] | 199 | my $DASSCM_PLUGIN_RESULTS_PATH;
|
---|
[205] | 200 | my $DASSCM_SVN_REPOSITORY;
|
---|
[247] | 201 | my $DASSCM_CHECKOUT_USERNAME;
|
---|
| 202 | my $DASSCM_CHECKOUT_PASSWORD;
|
---|
[922] | 203 | my $DASSCM_GID;
|
---|
[918] | 204 | my @DASSCM_ADDITIONAL_FILES;
|
---|
[205] | 205 |
|
---|
[238] | 206 | # current directory at program start
|
---|
| 207 | my $StartDirectory = cwd();
|
---|
| 208 |
|
---|
[268] | 209 | my $diff = "diff --exclude .svn ";
|
---|
[205] | 210 | my $SVN = "svn ";
|
---|
| 211 | my $svnOptions = "";
|
---|
| 212 | my $svnCheckoutCredentials = "";
|
---|
| 213 | my $svnPasswordCredentials = "";
|
---|
[275] | 214 |
|
---|
[268] | 215 | # flag. Set to true by svn_update
|
---|
| 216 | # This prevents, that svn_update is called multiple times
|
---|
| 217 | my $svnRepositoryIsUptodate = 0;
|
---|
[205] | 218 |
|
---|
[196] | 219 | # command line options get stored in options hash
|
---|
[205] | 220 | my %options = ();
|
---|
| 221 |
|
---|
[197] | 222 | # subcommand, that gets executed (add, commit, ...)
|
---|
[196] | 223 | my $command;
|
---|
[186] | 224 |
|
---|
[205] | 225 | my $verbose = 0;
|
---|
| 226 |
|
---|
[189] | 227 | #####################################################################
|
---|
| 228 | #
|
---|
[186] | 229 | # util functions
|
---|
[189] | 230 | #
|
---|
[187] | 231 | sub usage()
|
---|
| 232 | {
|
---|
[283] | 233 | print '$Id: dasscm 926 2010-07-30 16:45:47Z joergs $';
|
---|
| 234 | print "\n\n";
|
---|
[205] | 235 | print "usage: dasscm <subcommand> [options] [args]\n";
|
---|
| 236 | print "\n";
|
---|
| 237 | print "dasscm is intended to help versioning configuration files\n";
|
---|
| 238 | print "\n";
|
---|
| 239 | print "Available subcommands:\n";
|
---|
[889] | 240 | foreach my $i ( sort keys(%COMMAND_DEFINITIONS) ) {
|
---|
| 241 | print " ", $i, " ", join( " ", get_command_possible_params($i) ),
|
---|
| 242 | "\n";
|
---|
[884] | 243 | foreach my $line ( get_command_desc($i) ) {
|
---|
[889] | 244 | print " " x 20, $line, "\n";
|
---|
[884] | 245 | }
|
---|
| 246 | }
|
---|
[205] | 247 | print "\n";
|
---|
[800] | 248 | print "If dasscm is not yet configured, read $doc_file\n";
|
---|
[187] | 249 | }
|
---|
| 250 |
|
---|
[233] | 251 | sub warning(@)
|
---|
| 252 | {
|
---|
| 253 | print "Warning: " . join( "\n ", @_ ) . "\n";
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | sub error(@)
|
---|
| 257 | {
|
---|
| 258 | print "Error: " . join( "\n ", @_ ) . "\n";
|
---|
| 259 | }
|
---|
| 260 |
|
---|
| 261 | sub fatalerror(@)
|
---|
| 262 | {
|
---|
[239] | 263 | error(@_);
|
---|
| 264 |
|
---|
[233] | 265 | #print "Exiting\n";
|
---|
[239] | 266 | exit 1;
|
---|
[233] | 267 | }
|
---|
| 268 |
|
---|
[238] | 269 | #
|
---|
| 270 | # reading config file and return key/value pairs as hash
|
---|
| 271 | #
|
---|
[234] | 272 | sub get_config
|
---|
| 273 | {
|
---|
[239] | 274 | my $file = $_[0];
|
---|
[234] | 275 |
|
---|
[239] | 276 | if ( !$file ) {
|
---|
[234] | 277 | fatalerror( "failed to open config file" . $file );
|
---|
| 278 | }
|
---|
| 279 |
|
---|
| 280 | my $data = {};
|
---|
| 281 |
|
---|
| 282 | # try to open config file
|
---|
| 283 | if ( !open( FH, $file ) ) {
|
---|
| 284 | fatalerror( "failed to open config file" . $file );
|
---|
| 285 | } else {
|
---|
| 286 | while (<FH>) {
|
---|
| 287 | chomp;
|
---|
| 288 | if (/^#/) {
|
---|
| 289 | next;
|
---|
| 290 | }
|
---|
| 291 | if ( $_ =~ /=/g ) {
|
---|
[239] | 292 |
|
---|
[238] | 293 | # splitting in 2 fields at maximum
|
---|
[234] | 294 | my ( $option, $value ) = split( /=/, $_, 2 );
|
---|
| 295 | $option =~ s/^\s+//g;
|
---|
| 296 | $option =~ s/\s+$//g;
|
---|
| 297 | $option =~ s/\"+//g;
|
---|
| 298 | $value =~ s/^\s+//g;
|
---|
| 299 | $value =~ s/\s+$//g;
|
---|
| 300 | $value =~ s/\"+//g;
|
---|
| 301 |
|
---|
| 302 | if ( length($option) ) {
|
---|
| 303 | $data->{$option} = $value;
|
---|
| 304 | }
|
---|
| 305 | }
|
---|
| 306 | }
|
---|
| 307 | }
|
---|
| 308 | close(FH);
|
---|
| 309 |
|
---|
| 310 | return $data;
|
---|
| 311 | }
|
---|
| 312 |
|
---|
[270] | 313 | #
|
---|
| 314 | # check and evaluate environment variables
|
---|
| 315 | #
|
---|
[186] | 316 | sub check_env()
|
---|
| 317 | {
|
---|
[205] | 318 |
|
---|
| 319 | # DASSCM_PROD
|
---|
| 320 | if ( !$DASSCM_PROD ) {
|
---|
| 321 | $DASSCM_PROD = "/";
|
---|
| 322 | }
|
---|
| 323 |
|
---|
| 324 | if ( !-d $DASSCM_PROD ) {
|
---|
| 325 | die "DASSCM_PROD ($DASSCM_PROD) is not set to a directory.\n";
|
---|
| 326 | }
|
---|
| 327 | if ($verbose) { print "DASSCM_PROD: " . $DASSCM_PROD . "\n"; }
|
---|
| 328 |
|
---|
| 329 | # DASSCM_REPOSITORY_NAME
|
---|
[208] | 330 | if ( !$DASSCM_REPOSITORY_NAME ) {
|
---|
| 331 | die
|
---|
| 332 | "Variable DASSCM_REPOSITORY_NAME is not defined.\nIt needs to be a unique name.\nNormally the full qualified host name is used.\nUse file $config_file to configure it.\n";
|
---|
| 333 | }
|
---|
[205] | 334 |
|
---|
| 335 | # DASSCM_REPO
|
---|
| 336 | if ( !$DASSCM_REPO ) {
|
---|
| 337 | if ( $DASSCM_LOCAL_REPOSITORY_BASE && $DASSCM_REPOSITORY_NAME ) {
|
---|
| 338 | $DASSCM_REPO =
|
---|
| 339 | $DASSCM_LOCAL_REPOSITORY_BASE . "/" . $DASSCM_REPOSITORY_NAME;
|
---|
| 340 | } else {
|
---|
| 341 | die
|
---|
| 342 | "Envirnonment variable DASSCM_REPO not set.\nSet DASSCM_REPO to the directory of the versioning system checkout for this machine.\n";
|
---|
| 343 | }
|
---|
| 344 | }
|
---|
[887] | 345 | $DASSCM_REPO = normalize_path($DASSCM_REPO);
|
---|
[215] | 346 | if ($verbose) { print "DASSCM_REPO: " . $DASSCM_REPO . "\n"; }
|
---|
[205] | 347 |
|
---|
| 348 | #
|
---|
[248] | 349 | # subversion checkout user
|
---|
| 350 | #
|
---|
[252] | 351 | if ( !$DASSCM_CHECKOUT_USERNAME ) {
|
---|
| 352 | fatalerror(
|
---|
[248] | 353 | "variable DASSCM_CHECKOUT_USERNAME is not defined.",
|
---|
[252] | 354 | "Use file $config_file to configure it."
|
---|
| 355 | );
|
---|
[248] | 356 | }
|
---|
| 357 |
|
---|
[252] | 358 | if ( !$DASSCM_CHECKOUT_PASSWORD ) {
|
---|
| 359 | fatalerror(
|
---|
[248] | 360 | "variable DASSCM_CHECKOUT_PASSWORD is not defined.",
|
---|
[252] | 361 | "Use file $config_file to configure it."
|
---|
| 362 | );
|
---|
[248] | 363 | }
|
---|
| 364 |
|
---|
| 365 | #
|
---|
[239] | 366 | # check if local repository directory exist
|
---|
[235] | 367 | # (if not creating by init)
|
---|
[205] | 368 | #
|
---|
| 369 | if ( $command ne "init" ) {
|
---|
| 370 | if ( not -d $DASSCM_REPO ) {
|
---|
[916] | 371 | fatalerror(
|
---|
[918] | 372 | "Can't access local repository DASSCM_REPO",
|
---|
| 373 | "($DASSCM_REPO)",
|
---|
| 374 | "Check configuration and execute",
|
---|
| 375 | "dasscm init"
|
---|
[916] | 376 | );
|
---|
[205] | 377 | }
|
---|
[208] | 378 |
|
---|
[205] | 379 | #
|
---|
| 380 | # user settings
|
---|
| 381 | #
|
---|
[208] | 382 |
|
---|
[205] | 383 | # DASSCM_USER is legacy. Use DASSCM_USERNAME instead
|
---|
[208] | 384 | if ( !$DASSCM_USERNAME ) {
|
---|
| 385 | $DASSCM_USERNAME = $DASSCM_USER;
|
---|
[205] | 386 | }
|
---|
| 387 |
|
---|
| 388 | # user root is not allowed for checkins.
|
---|
| 389 | # if user is root, DASSCM_USER has to be set,
|
---|
| 390 | # otherwise USER can be used
|
---|
| 391 | if ( "$USER" eq "root" ) {
|
---|
[252] | 392 | if ( ( not $DASSCM_USERNAME )
|
---|
[889] | 393 | and ( get_command_requires_write($command) ) )
|
---|
[252] | 394 | {
|
---|
| 395 |
|
---|
| 396 | #( $command ne "login" ) and ( $command ne "status" ) ) {
|
---|
| 397 | fatalerror(
|
---|
| 398 | "Envirnonment variable DASSCM_USERNAME not set.",
|
---|
| 399 | "Set DASSCM_USERNAME to your subversion user account or",
|
---|
| 400 | "use 'dasscm login'"
|
---|
| 401 | );
|
---|
[205] | 402 | }
|
---|
| 403 | $svnOptions .= " --no-auth-cache ";
|
---|
| 404 | } elsif ( !$DASSCM_USERNAME ) {
|
---|
| 405 | $DASSCM_USERNAME = $USER;
|
---|
| 406 | }
|
---|
| 407 |
|
---|
| 408 | #
|
---|
| 409 | # password
|
---|
| 410 | #
|
---|
[208] | 411 | if ($DASSCM_PASSWORD) {
|
---|
[267] | 412 | $svnPasswordCredentials = " --password '$DASSCM_PASSWORD' ";
|
---|
[205] | 413 | }
|
---|
| 414 | }
|
---|
| 415 |
|
---|
| 416 | #$svnOptions .= " --username $DASSCM_USERNAME "
|
---|
[922] | 417 |
|
---|
| 418 | #
|
---|
| 419 | # prepare file permissions
|
---|
| 420 | # (read-write access for group "dasscm",
|
---|
| 421 | # if this group exists)
|
---|
| 422 | #
|
---|
| 423 | (my $gname, my $gpw, $DASSCM_GID, my $members) = getgrnam( "dasscm" );
|
---|
| 424 | if( $DASSCM_GID ) {
|
---|
| 425 | umask 0007
|
---|
| 426 | }
|
---|
[186] | 427 | }
|
---|
| 428 |
|
---|
[270] | 429 | #
|
---|
| 430 | # has been intendend,
|
---|
| 431 | # to check addtitional parameters.
|
---|
| 432 | # Currently not used.
|
---|
| 433 | #
|
---|
[186] | 434 | sub check_parameter(@)
|
---|
| 435 | {
|
---|
| 436 | }
|
---|
| 437 |
|
---|
[884] | 438 | sub get_command_uniform_name( $ )
|
---|
| 439 | {
|
---|
| 440 | my $command_abbrivation = $_[0];
|
---|
[889] | 441 | if ( defined( $COMMANDS{$command_abbrivation} ) ) {
|
---|
[884] | 442 | return $COMMANDS{$command_abbrivation};
|
---|
| 443 | }
|
---|
| 444 | return;
|
---|
| 445 | }
|
---|
| 446 |
|
---|
| 447 | sub get_command_desc( $ )
|
---|
| 448 | {
|
---|
[889] | 449 | my $command = get_command_uniform_name( $_[0] );
|
---|
| 450 | my @desc = ();
|
---|
| 451 | if ( $command && defined( $COMMAND_DEFINITIONS{$command}{'desc'} ) ) {
|
---|
| 452 | @desc = @{ $COMMAND_DEFINITIONS{$command}{'desc'} };
|
---|
[884] | 453 | }
|
---|
| 454 | return @desc;
|
---|
| 455 | }
|
---|
| 456 |
|
---|
| 457 | sub get_command_function( $ )
|
---|
| 458 | {
|
---|
[889] | 459 | my $command = get_command_uniform_name( $_[0] );
|
---|
[884] | 460 | my $func;
|
---|
[889] | 461 | if ( $command && defined( $COMMAND_DEFINITIONS{$command}{'function'} ) ) {
|
---|
[884] | 462 | $func = $COMMAND_DEFINITIONS{$command}{'function'};
|
---|
| 463 | }
|
---|
| 464 | return $func;
|
---|
| 465 | }
|
---|
| 466 |
|
---|
| 467 | sub get_command_possible_params( $ )
|
---|
| 468 | {
|
---|
[889] | 469 | my $command = get_command_uniform_name( $_[0] );
|
---|
| 470 | my @params = ();
|
---|
| 471 | if ( $command && defined( $COMMAND_DEFINITIONS{$command}{'params'} ) ) {
|
---|
| 472 | @params = @{ $COMMAND_DEFINITIONS{$command}{'params'} };
|
---|
[884] | 473 | }
|
---|
| 474 | return @params;
|
---|
| 475 | }
|
---|
| 476 |
|
---|
[893] | 477 | sub get_command_possible_options( $ )
|
---|
| 478 | {
|
---|
| 479 | my $command = get_command_uniform_name( $_[0] );
|
---|
| 480 | my @params = ();
|
---|
| 481 | if ( $command && defined( $COMMAND_DEFINITIONS{$command}{'options'} ) ) {
|
---|
| 482 | @params = @{ $COMMAND_DEFINITIONS{$command}{'options'} };
|
---|
| 483 | }
|
---|
| 484 | return @params;
|
---|
| 485 | }
|
---|
| 486 |
|
---|
[884] | 487 | sub get_command_requirements( $ )
|
---|
| 488 | {
|
---|
[889] | 489 | my $command = get_command_uniform_name( $_[0] );
|
---|
[884] | 490 | my @requirements = ();
|
---|
[889] | 491 | if ( $command && defined( $COMMAND_DEFINITIONS{$command}{'require'} ) ) {
|
---|
| 492 | @requirements = @{ $COMMAND_DEFINITIONS{$command}{'require'} };
|
---|
[884] | 493 | }
|
---|
| 494 | return @requirements;
|
---|
| 495 | }
|
---|
| 496 |
|
---|
| 497 | sub get_command_requires_write( $ )
|
---|
| 498 | {
|
---|
[889] | 499 | return grep( /^WRITE$/, get_command_requirements( $_[0] ) );
|
---|
[884] | 500 | }
|
---|
| 501 |
|
---|
[238] | 502 | #
|
---|
[287] | 503 | # normalize path namens:
|
---|
| 504 | # - directories should end with "/"
|
---|
| 505 | # - use only single "/"
|
---|
| 506 | #
|
---|
| 507 | sub normalize_path($)
|
---|
| 508 | {
|
---|
| 509 | my $path = shift || "";
|
---|
| 510 |
|
---|
[290] | 511 | if ( $path =~ m|^/| ) {
|
---|
| 512 |
|
---|
[287] | 513 | # full path
|
---|
[290] | 514 | if ( -d $path ) {
|
---|
| 515 |
|
---|
[287] | 516 | # ensure, a directory ends with '/'
|
---|
| 517 | $path .= '/';
|
---|
| 518 | }
|
---|
[290] | 519 | } elsif ( -d cwd() . '/' . $path ) {
|
---|
| 520 |
|
---|
| 521 | # ensure, a directory ends with '/'
|
---|
| 522 | $path .= '/';
|
---|
[287] | 523 | }
|
---|
| 524 |
|
---|
| 525 | # remove double (triple) slashes (/)
|
---|
| 526 | $path =~ s|/[/]*|/|g;
|
---|
| 527 |
|
---|
[887] | 528 | # remove self reference path
|
---|
| 529 | $path =~ s|/./|/|g;
|
---|
| 530 |
|
---|
[287] | 531 | return $path;
|
---|
| 532 | }
|
---|
| 533 |
|
---|
| 534 | #
|
---|
[239] | 535 | # generate from (relative) filename
|
---|
[238] | 536 | # all required file and directory names:
|
---|
| 537 | # $basename, $dirname_prod, $dirname_repo,
|
---|
| 538 | # $filename_prod, $filename_repo
|
---|
| 539 | #
|
---|
[187] | 540 | sub get_filenames(@)
|
---|
| 541 | {
|
---|
[250] | 542 | my $filename_prod = $_[0] || ".";
|
---|
[237] | 543 |
|
---|
[238] | 544 | # make filename absolut
|
---|
[205] | 545 | if ( !( $filename_prod =~ m/^\// ) ) {
|
---|
[270] | 546 | $filename_prod = cwd() . '/' . $filename_prod;
|
---|
[205] | 547 | }
|
---|
[187] | 548 |
|
---|
[889] | 549 | # file must be readable.
|
---|
| 550 | # The only exceptions are,
|
---|
[887] | 551 | # - if the file parameter is to be completed or
|
---|
| 552 | # - if a file should be reverted
|
---|
| 553 | if ( $command ne "revert" && $command !~ m/^complete/ ) {
|
---|
[800] | 554 | if ( not -r $filename_prod ) {
|
---|
| 555 | fatalerror( $filename_prod . " is not accessable" );
|
---|
| 556 | }
|
---|
[233] | 557 | }
|
---|
[205] | 558 |
|
---|
[274] | 559 | # dirname buggy: eg. "/etc/" is reduced to "/",
|
---|
| 560 | # "/etc" is used as filename
|
---|
| 561 | # herefore make sure, that if filename is a directory,
|
---|
| 562 | # it will end by "/"
|
---|
[290] | 563 | $filename_prod = normalize_path($filename_prod);
|
---|
[238] | 564 |
|
---|
[270] | 565 | ( my $basename, my $dirname_prod ) = fileparse($filename_prod);
|
---|
| 566 |
|
---|
[801] | 567 | # normalize path.
|
---|
[800] | 568 | # not done for reverting, because in this case, the directory may not exist
|
---|
| 569 | # and the correct path should already be stored in the repository
|
---|
| 570 | if ( $command ne "revert" ) {
|
---|
[801] | 571 |
|
---|
[800] | 572 | # uses chdir to determine real directory in a unique way
|
---|
[801] | 573 | chdir $dirname_prod
|
---|
| 574 | or fatalerror( "failed to access directory $dirname_prod: " . $! );
|
---|
[800] | 575 | $dirname_prod = normalize_path( cwd() );
|
---|
| 576 | chdir $StartDirectory;
|
---|
| 577 | }
|
---|
[238] | 578 |
|
---|
[287] | 579 | my $dirname_repo = normalize_path( $DASSCM_REPO . "/" . $dirname_prod );
|
---|
[290] | 580 | my $filename_repo = normalize_path("$dirname_repo/$basename");
|
---|
[287] | 581 |
|
---|
[214] | 582 | if ($verbose) {
|
---|
[287] | 583 | print "filename_repo: " . $filename_repo . "\n";
|
---|
[290] | 584 | print "dirname_repo: " . $dirname_repo . "\n";
|
---|
[287] | 585 | print "filename_prod: " . $filename_prod . "\n";
|
---|
[290] | 586 | print "dirname_prod: " . $dirname_prod . "\n";
|
---|
[287] | 587 | print "basename: " . $basename . "\n";
|
---|
[214] | 588 | }
|
---|
[205] | 589 |
|
---|
| 590 | return (
|
---|
| 591 | $basename, $dirname_prod, $dirname_repo,
|
---|
| 592 | $filename_prod, $filename_repo
|
---|
| 593 | );
|
---|
[187] | 594 | }
|
---|
| 595 |
|
---|
[271] | 596 | sub copy_file_to_repository( $ )
|
---|
| 597 | {
|
---|
| 598 | my $filename = shift;
|
---|
[256] | 599 |
|
---|
[271] | 600 | (
|
---|
| 601 | my $basename,
|
---|
| 602 | my $dirname_prod,
|
---|
| 603 | my $dirname_repo,
|
---|
| 604 | my $filename_prod,
|
---|
| 605 | my $filename_repo
|
---|
[801] | 606 | ) = get_filenames($filename);
|
---|
[271] | 607 |
|
---|
[802] | 608 | #copy( $filename_prod, $filename_repo )
|
---|
[889] | 609 | ( my $rc, my @result ) =
|
---|
| 610 | run_command("cp -a \"$filename_prod\" \"$filename_repo\"");
|
---|
| 611 | if ( $rc != 0 ) {
|
---|
[802] | 612 | error( "failed to copy $filename_prod to repository: ", @result );
|
---|
| 613 | }
|
---|
| 614 |
|
---|
| 615 | # return success
|
---|
| 616 | return $rc == 0;
|
---|
[271] | 617 | }
|
---|
| 618 |
|
---|
[802] | 619 | sub copy_file_from_repository_to_system( $ )
|
---|
| 620 | {
|
---|
| 621 | my $filename = shift;
|
---|
| 622 |
|
---|
| 623 | (
|
---|
| 624 | my $basename,
|
---|
| 625 | my $dirname_prod,
|
---|
| 626 | my $dirname_repo,
|
---|
| 627 | my $filename_prod,
|
---|
| 628 | my $filename_repo
|
---|
| 629 | ) = get_filenames($filename);
|
---|
| 630 |
|
---|
[889] | 631 | ( my $rc, my @result ) =
|
---|
| 632 | run_command("cp -a \"$filename_repo\" \"$filename_prod\"");
|
---|
| 633 | if ( $rc != 0 ) {
|
---|
[802] | 634 | error( "failed to copy $filename_repo to $filename_prod: ", @result );
|
---|
| 635 | }
|
---|
| 636 |
|
---|
| 637 | # return success
|
---|
| 638 | return $rc == 0;
|
---|
| 639 | }
|
---|
| 640 |
|
---|
[256] | 641 | #
|
---|
| 642 | # creates a file with permissions
|
---|
| 643 | #
|
---|
[215] | 644 | sub generatePermissionList
|
---|
[209] | 645 | {
|
---|
| 646 |
|
---|
[215] | 647 | # generieren der Zeilen für Permission-Savefile
|
---|
| 648 | my @files = @_;
|
---|
| 649 | my @permlist = ();
|
---|
| 650 | foreach my $file (@files) {
|
---|
[227] | 651 | $file = "/" . $file;
|
---|
[239] | 652 | if ( -e $file ) {
|
---|
| 653 | my $info = stat($file) || die "failed to stat $file: aborting";
|
---|
| 654 | my $mode = get_type( $info->mode ) & 07777;
|
---|
[227] | 655 | my $modestring = sprintf( "%04o", $mode );
|
---|
[278] | 656 | my $uidnumber = $info->uid;
|
---|
| 657 | my $uid = getpwuid($uidnumber) || $uidnumber;
|
---|
| 658 | my $gidnumber = $info->gid;
|
---|
| 659 | my $gid = getgrgid($gidnumber) || $gidnumber;
|
---|
[227] | 660 | push(
|
---|
| 661 | @permlist,
|
---|
| 662 | sprintf( "%-55s %-17s %4d",
|
---|
[278] | 663 | $file, "${uid}:${gid}", $modestring )
|
---|
[227] | 664 | );
|
---|
| 665 | }
|
---|
[215] | 666 | }
|
---|
| 667 | return @permlist;
|
---|
| 668 | }
|
---|
[209] | 669 |
|
---|
[215] | 670 | sub get_type
|
---|
| 671 | {
|
---|
[209] | 672 |
|
---|
[215] | 673 | # Funktion übernommen aus /usr/bin/chkstat
|
---|
| 674 | my $S_IFLNK = 0120000; # symbolic link
|
---|
| 675 | my $S_IFREG = 0100000; # regular file
|
---|
| 676 | my $S_IFDIR = 0040000; # directory
|
---|
| 677 | my $S_IFCHAR = 0020000; # character device
|
---|
| 678 | my $S_IFBLK = 0060000; # block device
|
---|
| 679 | my $S_IFFIFO = 0010000; # fifo
|
---|
| 680 | my $S_IFSOCK = 0140000; # socket
|
---|
| 681 | my $S_IFMT = 0170000; # type of file
|
---|
[209] | 682 |
|
---|
[215] | 683 | my $S_m;
|
---|
| 684 | if ( ( $_[0] & $S_IFMT ) == $S_IFLNK ) { $S_m = $_[0] - $S_IFLNK; }
|
---|
| 685 | elsif ( ( $_[0] & $S_IFMT ) == $S_IFREG ) { $S_m = $_[0] - $S_IFREG; }
|
---|
| 686 | elsif ( ( $_[0] & $S_IFMT ) == $S_IFDIR ) { $S_m = $_[0] - $S_IFDIR; }
|
---|
| 687 | elsif ( ( $_[0] & $S_IFMT ) == $S_IFCHAR ) { $S_m = $_[0] - $S_IFCHAR; }
|
---|
| 688 | elsif ( ( $_[0] & $S_IFMT ) == $S_IFBLK ) { $S_m = $_[0] - $S_IFBLK; }
|
---|
| 689 | elsif ( ( $_[0] & $S_IFMT ) == $S_IFFIFO ) { $S_m = $_[0] - $S_IFFIFO; }
|
---|
| 690 | elsif ( ( $_[0] & $S_IFMT ) == $S_IFSOCK ) { $S_m = $_[0] - $S_IFSOCK; }
|
---|
| 691 | $S_m;
|
---|
[209] | 692 | }
|
---|
| 693 |
|
---|
[186] | 694 | sub run_command
|
---|
| 695 | {
|
---|
[205] | 696 | my $command = shift;
|
---|
[186] | 697 |
|
---|
[926] | 698 | if ($verbose) {
|
---|
| 699 | print "executing command: " . $command . "\n";
|
---|
| 700 | }
|
---|
[186] | 701 |
|
---|
[926] | 702 | my @result;
|
---|
| 703 | if( open( RESULT, $command . ' 2>&1 |' ) ) {
|
---|
| 704 | @result = <RESULT>;
|
---|
| 705 | close(RESULT);
|
---|
| 706 | }
|
---|
[205] | 707 | my $retcode = $? >> 8;
|
---|
[186] | 708 |
|
---|
[926] | 709 | if ($verbose) {
|
---|
| 710 | print @result;
|
---|
| 711 | if( $retcode ) { print "return code: " . $retcode . "\n"; }
|
---|
| 712 | }
|
---|
[186] | 713 |
|
---|
[205] | 714 | return ( $retcode, @result );
|
---|
[186] | 715 | }
|
---|
| 716 |
|
---|
[205] | 717 | sub run_interactive
|
---|
| 718 | {
|
---|
[186] | 719 |
|
---|
[208] | 720 | if ($verbose) {
|
---|
[205] | 721 | print "run_interactive:" . join( " ", @_ ) . "\n";
|
---|
| 722 | }
|
---|
[196] | 723 |
|
---|
[205] | 724 | system(@_);
|
---|
| 725 | if ( $? == -1 ) {
|
---|
| 726 | printf "failed to execute: $!\n";
|
---|
| 727 | } elsif ( $? & 127 ) {
|
---|
| 728 | printf "child died with signal %d, %s coredump\n", ( $? & 127 ),
|
---|
| 729 | ( $? & 128 ) ? 'with' : 'without';
|
---|
| 730 | } elsif ( $? >> 8 != 0 ) {
|
---|
| 731 | printf "child exited with value %d\n", $? >> 8;
|
---|
| 732 | }
|
---|
| 733 | return ( $? >> 8 );
|
---|
| 734 | }
|
---|
| 735 |
|
---|
[916] | 736 | #
|
---|
| 737 | # en- or disable echo mode.
|
---|
| 738 | # used for reading passwords from STDIN
|
---|
| 739 | #
|
---|
| 740 | sub setEchoMode( $ )
|
---|
| 741 | {
|
---|
| 742 | my $mode = shift;
|
---|
[918] | 743 | if ($mode) {
|
---|
| 744 | run_command("stty echo");
|
---|
[916] | 745 | } else {
|
---|
[918] | 746 | run_command("stty -echo");
|
---|
[916] | 747 | }
|
---|
| 748 | }
|
---|
| 749 |
|
---|
| 750 | sub write_array_to_file( $@ )
|
---|
| 751 | {
|
---|
| 752 | my $filename = shift;
|
---|
[918] | 753 | my @array = @_;
|
---|
[916] | 754 |
|
---|
[922] | 755 | if ( -e $filename && !-w $filename ) {
|
---|
| 756 | warning( "failed to write to $filename:", "permission denied" );
|
---|
| 757 | return;
|
---|
| 758 | }
|
---|
| 759 |
|
---|
[918] | 760 | if ( !-w dirname($filename) ) {
|
---|
[922] | 761 | warning( "failed to write to $filename:", "directory does not exist" );
|
---|
[916] | 762 | return;
|
---|
| 763 | }
|
---|
| 764 |
|
---|
| 765 | # directory exists => write
|
---|
[918] | 766 | if ( !open( OUTFILE, ">$filename" ) ) {
|
---|
| 767 | warning("failed to open $filename: $!");
|
---|
[916] | 768 | return;
|
---|
| 769 | }
|
---|
| 770 |
|
---|
| 771 | foreach my $line (@array) {
|
---|
| 772 | print OUTFILE "$line";
|
---|
| 773 | }
|
---|
| 774 | close(OUTFILE);
|
---|
| 775 |
|
---|
[922] | 776 | # if group dasscm exists,
|
---|
| 777 | # create plugin results with group membership dasscm
|
---|
| 778 | if( $DASSCM_GID ) {
|
---|
| 779 | chown( -1, $DASSCM_GID, $filename );
|
---|
| 780 | }
|
---|
| 781 |
|
---|
[916] | 782 | return 1;
|
---|
| 783 | }
|
---|
| 784 |
|
---|
| 785 | sub perform_plugins()
|
---|
| 786 | {
|
---|
| 787 | check_env();
|
---|
| 788 |
|
---|
| 789 | my @plugin_results = ();
|
---|
| 790 |
|
---|
| 791 | # get all defined plugins.
|
---|
| 792 | # Plugin definitions starting with DASSCM_PLUGIN_
|
---|
[918] | 793 | my @plugins = grep( /^DASSCM_PLUGIN_CMD_/, keys( %{$config} ) );
|
---|
[916] | 794 |
|
---|
| 795 | for my $plugin (@plugins) {
|
---|
[918] | 796 | my $plugin_name = substr( $plugin, length("DASSCM_PLUGIN_CMD_") );
|
---|
| 797 | my $plugin_test = $config->{ 'DASSCM_PLUGIN_TEST_' . $plugin_name };
|
---|
[916] | 798 | if ($verbose) { print "Plugin $plugin_name: "; }
|
---|
[926] | 799 | # all plugins are executed with LANG settings C
|
---|
| 800 | # bash -c is used, to supress all output
|
---|
| 801 | # (otherwise there are problem with && commands)
|
---|
| 802 | ( my $rc_test, my @result_test ) = run_command( "LANG=C bash -c " . $plugin_test);
|
---|
[918] | 803 | if ( $rc_test != 0 ) {
|
---|
[916] | 804 | if ($verbose) { print "skipped\n"; }
|
---|
| 805 | } else {
|
---|
| 806 | if ($verbose) { print "$config->{$plugin}\n"; }
|
---|
| 807 | ( my $rc, my @result ) = run_command( $config->{$plugin} );
|
---|
[918] | 808 | if ( $rc != 0 ) {
|
---|
| 809 | warning("failed to run plugin $plugin");
|
---|
[916] | 810 | } else {
|
---|
[918] | 811 | my $plugin_result_file =
|
---|
| 812 | $DASSCM_PLUGIN_RESULTS_PATH . "/" . $plugin_name;
|
---|
[916] | 813 | write_array_to_file( $plugin_result_file, @result );
|
---|
| 814 | push @plugin_results, $plugin_result_file;
|
---|
| 815 | }
|
---|
| 816 | }
|
---|
| 817 | }
|
---|
| 818 | return @plugin_results;
|
---|
| 819 | }
|
---|
| 820 |
|
---|
[247] | 821 | sub svn_check_credentials( $$;$$ )
|
---|
[196] | 822 | {
|
---|
[205] | 823 | my $username = shift;
|
---|
| 824 | my $password = shift;
|
---|
| 825 |
|
---|
[252] | 826 | # check silently are allow user interaction?
|
---|
[247] | 827 | my $interactive = shift || 0;
|
---|
[220] | 828 |
|
---|
[247] | 829 | # default: exit program, if repository is not accessable
|
---|
| 830 | # (do not exit for 'init')
|
---|
| 831 | my $fatalerror = shift || 1;
|
---|
| 832 |
|
---|
| 833 | print "checking credentials ";
|
---|
| 834 |
|
---|
[239] | 835 | if ( !$username ) {
|
---|
| 836 | fatalerror("no username given");
|
---|
[238] | 837 | }
|
---|
| 838 |
|
---|
[239] | 839 | if ( !$password ) {
|
---|
| 840 | fatalerror("no password given");
|
---|
[238] | 841 | }
|
---|
| 842 |
|
---|
[247] | 843 | print "for " . $username . "@" . $DASSCM_SVN_REPOSITORY . ": ";
|
---|
| 844 |
|
---|
[220] | 845 | # Options for "svn info" are not supported by subversion 1.0.0 (SLES9),
|
---|
| 846 | # therefore switching to "svn status"
|
---|
| 847 | # ( my $rc_update, my @result ) =
|
---|
| 848 | # run_command(
|
---|
| 849 | # "$SVN info --non-interactive --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY"
|
---|
| 850 | # );
|
---|
| 851 | #print @result;
|
---|
| 852 |
|
---|
[247] | 853 | my $rc_update;
|
---|
[252] | 854 | if ($interactive) {
|
---|
[801] | 855 | $rc_update = run_interactive(
|
---|
[267] | 856 | "$SVN ls --no-auth-cache --username '$username' --password '$password' $DASSCM_SVN_REPOSITORY"
|
---|
[801] | 857 | );
|
---|
[247] | 858 | } else {
|
---|
[801] | 859 | ( $rc_update, my @result ) = run_command(
|
---|
[267] | 860 | "$SVN ls --non-interactive --no-auth-cache --username '$username' --password '$password' $DASSCM_SVN_REPOSITORY"
|
---|
[801] | 861 | );
|
---|
[252] | 862 |
|
---|
[247] | 863 | if ( $rc_update != 0 ) {
|
---|
| 864 | print "\n", @result;
|
---|
[252] | 865 | if ($fatalerror) {
|
---|
[247] | 866 | fatalerror();
|
---|
| 867 | }
|
---|
| 868 | return;
|
---|
| 869 | }
|
---|
[205] | 870 | }
|
---|
| 871 |
|
---|
[247] | 872 | # return success
|
---|
| 873 | return $rc_update == 0;
|
---|
[196] | 874 | }
|
---|
| 875 |
|
---|
[205] | 876 | sub svn_update( ;$ )
|
---|
| 877 | {
|
---|
[270] | 878 | my $update_path = shift || "";
|
---|
| 879 |
|
---|
[797] | 880 | # return value
|
---|
| 881 | my $update_ok = 1;
|
---|
| 882 |
|
---|
[270] | 883 | # use this flag to do only one update per run
|
---|
[275] | 884 | if ( !$svnRepositoryIsUptodate ) {
|
---|
[801] | 885 | ( my $rc_update, my @result ) = run_command(
|
---|
[275] | 886 | "$SVN update --non-interactive $svnCheckoutCredentials '$DASSCM_REPO/$update_path'"
|
---|
[801] | 887 | );
|
---|
[268] | 888 | print @result;
|
---|
| 889 | if ( $rc_update != 0 ) {
|
---|
[290] | 890 | error("failed to update local repository ($update_path)");
|
---|
[797] | 891 | $update_ok = 0;
|
---|
[270] | 892 | } elsif ( not $update_path ) {
|
---|
[275] | 893 |
|
---|
[270] | 894 | # set this flag if a full update is done
|
---|
[268] | 895 | $svnRepositoryIsUptodate = 1;
|
---|
| 896 | }
|
---|
[205] | 897 | }
|
---|
[797] | 898 | return $update_ok;
|
---|
[215] | 899 | }
|
---|
[196] | 900 |
|
---|
[271] | 901 | sub svn_ls( ;@ )
|
---|
[215] | 902 | {
|
---|
[270] | 903 | (
|
---|
| 904 | my $basename,
|
---|
| 905 | my $dirname_prod,
|
---|
| 906 | my $dirname_repo,
|
---|
| 907 | my $filename_prod,
|
---|
| 908 | my $filename_repo
|
---|
[801] | 909 | ) = get_filenames( $_[0] );
|
---|
[220] | 910 |
|
---|
[218] | 911 | # svn ls -R is better, but much, much slower
|
---|
| 912 | # ( my $rc, my @result ) = run_command("$SVN ls --recursive $svnCheckoutCredentials $path");
|
---|
[270] | 913 |
|
---|
[271] | 914 | my @files = ();
|
---|
| 915 | my @links = ();
|
---|
| 916 | my @dirs = ();
|
---|
| 917 | my @others = ();
|
---|
| 918 |
|
---|
[289] | 919 | find(
|
---|
| 920 | {
|
---|
| 921 | wanted => sub {
|
---|
| 922 | my $name = normalize_path($File::Find::name);
|
---|
| 923 | $name =~ s|^$dirname_repo||;
|
---|
[290] | 924 |
|
---|
[289] | 925 | #print "($name)\n";# . $File::Find::dir . "\n";
|
---|
| 926 | if ( not $name ) {
|
---|
[290] | 927 |
|
---|
[289] | 928 | # name string is empty (top directory).
|
---|
| 929 | # do nothing
|
---|
| 930 | } elsif ( $name =~ m/\.svn/ ) {
|
---|
[275] | 931 |
|
---|
[289] | 932 | # skip svn meta data
|
---|
| 933 | } elsif ( -l $_ ) {
|
---|
[275] | 934 |
|
---|
[289] | 935 | # soft link
|
---|
| 936 | # important: check for links first
|
---|
| 937 | # to exclude them from further checks
|
---|
| 938 | push( @links, $name );
|
---|
| 939 | } elsif ( -d $_ ) {
|
---|
[290] | 940 |
|
---|
| 941 | # directories
|
---|
| 942 | push( @dirs, $name );
|
---|
[289] | 943 | } elsif ( -f $_ ) {
|
---|
[275] | 944 |
|
---|
[289] | 945 | # regular file
|
---|
| 946 | push( @files, $name );
|
---|
| 947 | } else {
|
---|
| 948 | push( @others, $name );
|
---|
| 949 | }
|
---|
[290] | 950 | }
|
---|
[289] | 951 | },
|
---|
| 952 | ($filename_repo)
|
---|
| 953 | );
|
---|
[271] | 954 |
|
---|
[287] | 955 | return ( sort( @dirs, @files ) );
|
---|
[205] | 956 | }
|
---|
| 957 |
|
---|
[274] | 958 | sub svn_revert( ;$ )
|
---|
| 959 | {
|
---|
| 960 | my $path = shift || $DASSCM_REPO;
|
---|
| 961 |
|
---|
[275] | 962 | ( my $rc_update, my @result ) = run_command("$SVN revert -R '$path'");
|
---|
[274] | 963 |
|
---|
| 964 | if ( $rc_update != 0 ) {
|
---|
| 965 | print "\n", @result;
|
---|
[275] | 966 | error("failed to revert subversion repository changes");
|
---|
[274] | 967 | }
|
---|
| 968 | }
|
---|
| 969 |
|
---|
[285] | 970 | sub svn_remove_unknown_files( ;$ )
|
---|
| 971 | {
|
---|
| 972 | my $path = shift || $DASSCM_REPO;
|
---|
| 973 |
|
---|
[290] | 974 | ( my $rc_update, my @result ) = run_command("$SVN status '$path'");
|
---|
[285] | 975 |
|
---|
| 976 | if ( $rc_update != 0 ) {
|
---|
| 977 | print "\n", @result;
|
---|
| 978 | error("failed to receive subversion repository information");
|
---|
| 979 | } else {
|
---|
[290] | 980 | foreach (@result) {
|
---|
| 981 | if (s/^\? +//) {
|
---|
[285] | 982 | chomp;
|
---|
[290] | 983 |
|
---|
[285] | 984 | # if file is unknown to subversion (line starts with "?")
|
---|
| 985 | # remove it
|
---|
| 986 | print "removing $_\n";
|
---|
[801] | 987 |
|
---|
[800] | 988 | # unlink doesn't work recursive, there "rm -rf" is used
|
---|
| 989 | #unlink($_);
|
---|
[801] | 990 | system("rm -rf $_");
|
---|
[285] | 991 | }
|
---|
| 992 | }
|
---|
| 993 | }
|
---|
| 994 | }
|
---|
| 995 |
|
---|
[268] | 996 | sub getModifiedFiles( ;$ )
|
---|
| 997 | {
|
---|
[270] | 998 | (
|
---|
| 999 | my $basename,
|
---|
| 1000 | my $dirname_prod,
|
---|
| 1001 | my $dirname_repo,
|
---|
| 1002 | my $filename_prod,
|
---|
| 1003 | my $filename_repo
|
---|
[801] | 1004 | ) = get_filenames( $_[0] );
|
---|
[268] | 1005 |
|
---|
[275] | 1006 | my @files = svn_ls($filename_prod);
|
---|
[270] | 1007 |
|
---|
[268] | 1008 | # stores result from status (cvscheck)
|
---|
| 1009 | my %removedfiles = ();
|
---|
| 1010 | my %changedfiles = ();
|
---|
[278] | 1011 | my %unknownfiles = ();
|
---|
[268] | 1012 |
|
---|
| 1013 | # create list of modified files
|
---|
| 1014 | if (@files) {
|
---|
| 1015 |
|
---|
| 1016 | foreach my $file (@files) {
|
---|
| 1017 |
|
---|
[271] | 1018 | my $realfile = $dirname_prod . $file;
|
---|
| 1019 | my $cvsworkfile = $dirname_repo . $file;
|
---|
[268] | 1020 |
|
---|
| 1021 | if ( -d $realfile ) {
|
---|
[290] | 1022 |
|
---|
[278] | 1023 | # directory
|
---|
[290] | 1024 | if ( !-d "$cvsworkfile" ) {
|
---|
| 1025 |
|
---|
[278] | 1026 | # real is directory, repository is not. This is a problem
|
---|
| 1027 | $changedfiles{"$realfile"} = $cvsworkfile;
|
---|
| 1028 | }
|
---|
| 1029 | } elsif ( !-e $realfile ) {
|
---|
| 1030 | $removedfiles{"$realfile"} = $cvsworkfile;
|
---|
[268] | 1031 | } elsif ( !-r $realfile ) {
|
---|
[290] | 1032 |
|
---|
[278] | 1033 | # don't have permission to read the file,
|
---|
| 1034 | # can't check it
|
---|
| 1035 | $unknownfiles{"$realfile"} = $cvsworkfile;
|
---|
[268] | 1036 | } else {
|
---|
| 1037 | ( -r "$cvsworkfile" )
|
---|
[278] | 1038 | || fatalerror("failed to read $cvsworkfile");
|
---|
[268] | 1039 | if ( compare( $cvsworkfile, $realfile ) != 0 ) {
|
---|
| 1040 | $changedfiles{"$realfile"} = $cvsworkfile;
|
---|
| 1041 | }
|
---|
| 1042 | }
|
---|
| 1043 | }
|
---|
| 1044 | }
|
---|
| 1045 |
|
---|
[278] | 1046 | return ( \%changedfiles, \%removedfiles, \%unknownfiles );
|
---|
[268] | 1047 | }
|
---|
| 1048 |
|
---|
[238] | 1049 | #
|
---|
| 1050 | # from an array of files/dirs,
|
---|
| 1051 | # generates list of files
|
---|
| 1052 | # sorted by type
|
---|
| 1053 | #
|
---|
[237] | 1054 | sub get_files( @ )
|
---|
| 1055 | {
|
---|
| 1056 | my @files = ();
|
---|
| 1057 | my @links = ();
|
---|
| 1058 | my @dirs = ();
|
---|
| 1059 | my @others = ();
|
---|
| 1060 |
|
---|
[239] | 1061 | if (@_) {
|
---|
| 1062 | find(
|
---|
| 1063 | {
|
---|
| 1064 | wanted => sub {
|
---|
| 1065 | my $fullname = cwd() . "/" . $_;
|
---|
| 1066 | if ( -l $_ ) {
|
---|
| 1067 |
|
---|
| 1068 | # soft link
|
---|
| 1069 | # important: check for links first
|
---|
| 1070 | # to exclude them from further checks
|
---|
| 1071 | push( @links, $fullname );
|
---|
| 1072 | } elsif ( -d $_ ) {
|
---|
[271] | 1073 |
|
---|
| 1074 | # directories
|
---|
[239] | 1075 | push( @dirs, $fullname );
|
---|
| 1076 | } elsif ( -f $_ ) {
|
---|
| 1077 |
|
---|
| 1078 | # regular file
|
---|
| 1079 | push( @files, $fullname );
|
---|
| 1080 | } else {
|
---|
| 1081 | push( @others, $fullname );
|
---|
| 1082 | }
|
---|
| 1083 | }
|
---|
| 1084 | },
|
---|
| 1085 | @_
|
---|
| 1086 | );
|
---|
[237] | 1087 | }
|
---|
| 1088 |
|
---|
[239] | 1089 | # don't rely on others.
|
---|
[237] | 1090 | # If more specific file types are needed,
|
---|
| 1091 | # they will be added
|
---|
| 1092 | return {
|
---|
[239] | 1093 | files => \@files,
|
---|
| 1094 | links => \@links,
|
---|
| 1095 | dirs => \@dirs,
|
---|
| 1096 | others => \@others
|
---|
| 1097 | };
|
---|
[237] | 1098 | }
|
---|
| 1099 |
|
---|
[918] | 1100 | sub print_files_hash( $ )
|
---|
| 1101 | {
|
---|
| 1102 | my $href_files = shift;
|
---|
| 1103 |
|
---|
| 1104 | my @files = @{ $href_files->{files} };
|
---|
| 1105 | my @links = @{ $href_files->{links} };
|
---|
| 1106 |
|
---|
| 1107 | if (@files) {
|
---|
| 1108 | my $number = $#files + 1;
|
---|
| 1109 | print "files to check-in ($number): \n";
|
---|
| 1110 | print join( "\n", @files );
|
---|
| 1111 | print "\n";
|
---|
| 1112 | }
|
---|
| 1113 |
|
---|
| 1114 | # TODO: check in links and also link target? At least warn about link target
|
---|
| 1115 | if (@links) {
|
---|
| 1116 | my $number = $#links + 1;
|
---|
| 1117 | print "\n";
|
---|
| 1118 | print "ignoring links ($number):\n";
|
---|
| 1119 | print join( "\n", @links );
|
---|
| 1120 | print "\n";
|
---|
| 1121 | }
|
---|
| 1122 |
|
---|
| 1123 | }
|
---|
| 1124 |
|
---|
[888] | 1125 | #
|
---|
| 1126 | # use globbing to get lsit of files
|
---|
| 1127 | # that matches the given prefix
|
---|
| 1128 | # used for bash completion
|
---|
| 1129 | #
|
---|
| 1130 | sub get_complete_path_globbing( $ )
|
---|
| 1131 | {
|
---|
| 1132 | my $path = shift;
|
---|
| 1133 |
|
---|
| 1134 | # add globbing
|
---|
| 1135 | $path .= "*";
|
---|
| 1136 |
|
---|
| 1137 | # get files
|
---|
[889] | 1138 | my @files = glob($path);
|
---|
[888] | 1139 |
|
---|
[889] | 1140 | if ( $#files == 0 ) {
|
---|
[891] | 1141 |
|
---|
| 1142 | # if only one result is available
|
---|
| 1143 | # and this result is a directory,
|
---|
| 1144 | # add another result entry
|
---|
| 1145 | # (directory with and withour trainling /),
|
---|
| 1146 | # otherwise complete will stop here and continue with the next parameter
|
---|
| 1147 | my $path = normalize_path( $files[0] );
|
---|
[889] | 1148 | if ( -d $path ) {
|
---|
[891] | 1149 | @files = ( substr( $path, 0, -1 ), $path );
|
---|
[888] | 1150 | }
|
---|
[890] | 1151 | } else {
|
---|
[891] | 1152 |
|
---|
[890] | 1153 | # add "/" to all directories
|
---|
[891] | 1154 | @files = map( { normalize_path($_) } @files );
|
---|
[888] | 1155 | }
|
---|
| 1156 |
|
---|
| 1157 | return @files;
|
---|
| 1158 | }
|
---|
| 1159 |
|
---|
[189] | 1160 | #####################################################################
|
---|
| 1161 | #
|
---|
[186] | 1162 | # functions
|
---|
| 1163 | sub help(;@)
|
---|
| 1164 | {
|
---|
[893] | 1165 | if ( not @_ ) {
|
---|
[205] | 1166 | usage();
|
---|
| 1167 | } else {
|
---|
[893] | 1168 | print "help for ", join( " ", @_ ), ": ...\n";
|
---|
[214] | 1169 | usage();
|
---|
[205] | 1170 | }
|
---|
[186] | 1171 | }
|
---|
| 1172 |
|
---|
[203] | 1173 | sub login(@)
|
---|
| 1174 | {
|
---|
[205] | 1175 | check_parameter( @_, 1 );
|
---|
| 1176 | check_env();
|
---|
[203] | 1177 |
|
---|
[235] | 1178 | my $input_username = $_[0];
|
---|
[214] | 1179 |
|
---|
| 1180 | if ( not $input_username ) {
|
---|
| 1181 | my $output_username = "";
|
---|
| 1182 | if ($DASSCM_USERNAME) {
|
---|
| 1183 | $output_username = " ($DASSCM_USERNAME)";
|
---|
| 1184 | }
|
---|
| 1185 |
|
---|
| 1186 | print "Enter DASSCM user name", $output_username, ": ";
|
---|
| 1187 | $input_username = <STDIN>;
|
---|
| 1188 | chomp($input_username);
|
---|
[247] | 1189 |
|
---|
| 1190 | $input_username = $input_username || $DASSCM_USERNAME;
|
---|
[205] | 1191 | }
|
---|
[203] | 1192 |
|
---|
[205] | 1193 | # hidden password input
|
---|
[916] | 1194 | print "Enter password for $input_username: ";
|
---|
[918] | 1195 | setEchoMode(0);
|
---|
[205] | 1196 | my $input_password = <STDIN>;
|
---|
[918] | 1197 | setEchoMode(1);
|
---|
[205] | 1198 | chomp($input_password);
|
---|
[220] | 1199 | print "\n";
|
---|
[203] | 1200 |
|
---|
[247] | 1201 | # checking checkout username/password
|
---|
[252] | 1202 | svn_check_credentials( $DASSCM_CHECKOUT_USERNAME,
|
---|
| 1203 | $DASSCM_CHECKOUT_PASSWORD );
|
---|
[247] | 1204 | print "checkout access okay\n";
|
---|
[205] | 1205 |
|
---|
[247] | 1206 | svn_check_credentials( $input_username, $input_password );
|
---|
| 1207 |
|
---|
[205] | 1208 | #
|
---|
| 1209 | # set environment variables
|
---|
| 1210 | #
|
---|
[267] | 1211 | $ENV{'DASSCM_USERNAME'} = "$input_username";
|
---|
| 1212 | $ENV{'DASSCM_PASSWORD'} = "$input_password";
|
---|
[205] | 1213 |
|
---|
[209] | 1214 | print "subversion access okay\n\n", "DASSCM_USERNAME: $input_username\n",
|
---|
| 1215 | "DASSCM_PASSWORD: (hidden)\n", "DASSCM_PROD: $DASSCM_PROD\n",
|
---|
| 1216 | "DASSCM_REPO: $DASSCM_REPO\n",
|
---|
[278] | 1217 | "Server Repository: $DASSCM_SVN_REPOSITORY\n", "\n";
|
---|
[205] | 1218 |
|
---|
[278] | 1219 | status();
|
---|
| 1220 |
|
---|
| 1221 | print "\n[dasscm shell]\n\n";
|
---|
[235] | 1222 | my $shell = $SHELL || "bash";
|
---|
| 1223 | exec($shell) or die "failed to start new shell";
|
---|
[203] | 1224 | }
|
---|
| 1225 |
|
---|
[260] | 1226 | #
|
---|
| 1227 | # initialize local checkout directory (initial checkout)
|
---|
| 1228 | #
|
---|
[205] | 1229 | sub init(@)
|
---|
| 1230 | {
|
---|
| 1231 | check_parameter( @_, 1 );
|
---|
| 1232 | check_env();
|
---|
| 1233 |
|
---|
[235] | 1234 | # don't do repository creation (svn mkdir) here,
|
---|
| 1235 | # because then their must be a lot of prior checks
|
---|
| 1236 |
|
---|
[205] | 1237 | # update complete repository
|
---|
[801] | 1238 | my $retcode = run_interactive(
|
---|
[918] | 1239 | "cd $DASSCM_LOCAL_REPOSITORY_BASE; $SVN checkout $svnCheckoutCredentials $svnOptions $DASSCM_SVN_REPOSITORY"
|
---|
[801] | 1240 | );
|
---|
[205] | 1241 | }
|
---|
| 1242 |
|
---|
[215] | 1243 | sub ls(@)
|
---|
[186] | 1244 | {
|
---|
[205] | 1245 | check_parameter( @_, 1 );
|
---|
| 1246 | check_env();
|
---|
[186] | 1247 |
|
---|
[271] | 1248 | my @files = svn_ls(@_);
|
---|
[215] | 1249 |
|
---|
[275] | 1250 | if (@files) {
|
---|
[274] | 1251 | print join( "\n", @files );
|
---|
| 1252 | print "\n";
|
---|
| 1253 | }
|
---|
[215] | 1254 | }
|
---|
| 1255 |
|
---|
| 1256 | sub update(@)
|
---|
| 1257 | {
|
---|
| 1258 | check_parameter( @_, 1 );
|
---|
| 1259 | check_env();
|
---|
| 1260 |
|
---|
| 1261 | #
|
---|
| 1262 | # update local repository
|
---|
| 1263 | #
|
---|
| 1264 | svn_update();
|
---|
| 1265 | }
|
---|
| 1266 |
|
---|
[237] | 1267 | #
|
---|
| 1268 | # helper function for "add" command
|
---|
| 1269 | #
|
---|
[215] | 1270 | sub add_helper(@)
|
---|
| 1271 | {
|
---|
[205] | 1272 | (
|
---|
| 1273 | my $basename,
|
---|
| 1274 | my $dirname_prod,
|
---|
| 1275 | my $dirname_repo,
|
---|
| 1276 | my $filename_prod,
|
---|
| 1277 | my $filename_repo
|
---|
[801] | 1278 | ) = get_filenames( $_[0] );
|
---|
[186] | 1279 |
|
---|
[274] | 1280 | mkpath($dirname_repo);
|
---|
[889] | 1281 | copy_file_to_repository($filename_prod);
|
---|
[186] | 1282 |
|
---|
[274] | 1283 | # already checked in?
|
---|
| 1284 | chdir $DASSCM_REPO;
|
---|
[205] | 1285 |
|
---|
[274] | 1286 | # also add the path to filename.
|
---|
| 1287 | for my $dir ( split( '/', $dirname_prod ) ) {
|
---|
| 1288 | if ($dir) {
|
---|
[275] | 1289 | my ( $rc, @out ) = run_command("$SVN add --non-recursive '$dir'");
|
---|
[274] | 1290 | if ( $rc > 0 ) {
|
---|
| 1291 | print join( "\n", @out );
|
---|
[205] | 1292 | }
|
---|
[274] | 1293 | chdir $dir;
|
---|
[205] | 1294 | }
|
---|
| 1295 | }
|
---|
[275] | 1296 | my ( $rc, @out ) = run_command("$SVN add '$basename'");
|
---|
[274] | 1297 | if ( $rc > 0 ) {
|
---|
| 1298 | print join( "\n", @out );
|
---|
| 1299 | }
|
---|
| 1300 | chdir $StartDirectory;
|
---|
| 1301 |
|
---|
[215] | 1302 | }
|
---|
[205] | 1303 |
|
---|
[918] | 1304 | sub add_helper_multi(@)
|
---|
[215] | 1305 | {
|
---|
| 1306 |
|
---|
[237] | 1307 | # get all regular files and links
|
---|
[239] | 1308 | my $href_files = get_files(@_);
|
---|
[220] | 1309 |
|
---|
[237] | 1310 | #print Dumper( $href_files );
|
---|
| 1311 |
|
---|
[239] | 1312 | my @files = @{ $href_files->{files} };
|
---|
| 1313 | my @links = @{ $href_files->{links} };
|
---|
[237] | 1314 |
|
---|
| 1315 | # copy files one by one to local repository
|
---|
| 1316 | for my $file (@files) {
|
---|
[239] | 1317 |
|
---|
[233] | 1318 | # add file
|
---|
[239] | 1319 | add_helper($file);
|
---|
[233] | 1320 | }
|
---|
| 1321 |
|
---|
[918] | 1322 | return $href_files;
|
---|
| 1323 | }
|
---|
[220] | 1324 |
|
---|
[918] | 1325 | #
|
---|
| 1326 | # adding new files (or directories)
|
---|
| 1327 | #
|
---|
| 1328 | sub add(@)
|
---|
| 1329 | {
|
---|
| 1330 | check_parameter( @_, 1 );
|
---|
| 1331 | check_env();
|
---|
[215] | 1332 |
|
---|
[918] | 1333 | #
|
---|
| 1334 | # update local repository
|
---|
| 1335 | #
|
---|
| 1336 | svn_update();
|
---|
[916] | 1337 |
|
---|
[918] | 1338 | # add files to repository, print information about added files
|
---|
| 1339 | print_files_hash( add_helper_multi(@_) );
|
---|
[916] | 1340 |
|
---|
[918] | 1341 | # perform plugins and add additional files, like plugin results
|
---|
| 1342 | perform_plugins();
|
---|
| 1343 | add_helper_multi(@DASSCM_ADDITIONAL_FILES);
|
---|
| 1344 |
|
---|
[205] | 1345 | if ( $options{'message'} ) {
|
---|
| 1346 | $svnOptions .= " --message \"$options{'message'}\" ";
|
---|
| 1347 | }
|
---|
| 1348 |
|
---|
[239] | 1349 | # commit calls $EDITOR.
|
---|
[237] | 1350 | # use "interactive" here, to display output
|
---|
[801] | 1351 | my $retcode = run_interactive(
|
---|
[267] | 1352 | "$SVN commit $svnOptions --username '$DASSCM_USERNAME' $svnPasswordCredentials $DASSCM_REPO"
|
---|
[801] | 1353 | );
|
---|
[205] | 1354 |
|
---|
[274] | 1355 | # svn commit does not deliever an error return code, if commit is canceld,
|
---|
| 1356 | # so a revert is performed in any case
|
---|
| 1357 | svn_revert();
|
---|
[186] | 1358 | }
|
---|
| 1359 |
|
---|
[271] | 1360 | #
|
---|
| 1361 | # checks in all modified files
|
---|
| 1362 | #
|
---|
| 1363 | sub commit(@)
|
---|
| 1364 | {
|
---|
| 1365 | check_parameter( @_, 1 );
|
---|
| 1366 | check_env();
|
---|
| 1367 |
|
---|
| 1368 | (
|
---|
| 1369 | my $basename,
|
---|
| 1370 | my $dirname_prod,
|
---|
| 1371 | my $dirname_repo,
|
---|
| 1372 | my $filename_prod,
|
---|
| 1373 | my $filename_repo
|
---|
[801] | 1374 | ) = get_filenames( $_[0] );
|
---|
[271] | 1375 |
|
---|
| 1376 | #
|
---|
| 1377 | # update local repository
|
---|
| 1378 | #
|
---|
| 1379 | svn_update();
|
---|
| 1380 |
|
---|
[275] | 1381 | ( my $refChangedFiles, my $refRemovedFiles ) =
|
---|
| 1382 | getModifiedFiles($filename_prod);
|
---|
[271] | 1383 | my %changedfiles = %{$refChangedFiles};
|
---|
| 1384 | my %removedfiles = %{$refRemovedFiles};
|
---|
| 1385 |
|
---|
[275] | 1386 | if (%removedfiles) {
|
---|
| 1387 | my $removedFilesString =
|
---|
| 1388 | '"' . join( '" "', values(%removedfiles) ) . '"';
|
---|
| 1389 | my ( $rc, @out ) = run_command("$SVN rm $removedFilesString");
|
---|
[271] | 1390 | if ( $rc > 0 ) {
|
---|
| 1391 | print join( "\n", @out );
|
---|
| 1392 | }
|
---|
| 1393 | }
|
---|
| 1394 |
|
---|
| 1395 | # copy files one by one to local repository
|
---|
| 1396 | for my $file ( keys(%changedfiles) ) {
|
---|
[275] | 1397 | copy_file_to_repository($file);
|
---|
[271] | 1398 | }
|
---|
| 1399 |
|
---|
[918] | 1400 | perform_plugins();
|
---|
| 1401 | add_helper_multi(@DASSCM_ADDITIONAL_FILES);
|
---|
[271] | 1402 |
|
---|
| 1403 | if ( $options{'message'} ) {
|
---|
| 1404 | $svnOptions .= " --message \"$options{'message'}\" ";
|
---|
| 1405 | }
|
---|
| 1406 |
|
---|
| 1407 | # commit calls $EDITOR.
|
---|
| 1408 | # use "interactive" here, to display output
|
---|
[801] | 1409 | my $retcode = run_interactive(
|
---|
[271] | 1410 | "$SVN commit $svnOptions --username '$DASSCM_USERNAME' $svnPasswordCredentials $DASSCM_REPO"
|
---|
[801] | 1411 | );
|
---|
[274] | 1412 |
|
---|
| 1413 | # svn commit does not deliever an error return code, if commit is canceld,
|
---|
| 1414 | # so a revert is performed in any case
|
---|
| 1415 | svn_revert();
|
---|
[271] | 1416 | }
|
---|
| 1417 |
|
---|
[800] | 1418 | #
|
---|
| 1419 | # revert: copies files back from repository to system
|
---|
| 1420 | #
|
---|
| 1421 | sub revert(@)
|
---|
| 1422 | {
|
---|
| 1423 | check_parameter( @_, 1 );
|
---|
| 1424 | check_env();
|
---|
| 1425 |
|
---|
| 1426 | (
|
---|
| 1427 | my $basename,
|
---|
| 1428 | my $dirname_prod,
|
---|
| 1429 | my $dirname_repo,
|
---|
| 1430 | my $filename_prod,
|
---|
| 1431 | my $filename_repo
|
---|
[801] | 1432 | ) = get_filenames( $_[0] );
|
---|
[800] | 1433 |
|
---|
| 1434 | # return code for the shell
|
---|
| 1435 | # default: error
|
---|
| 1436 | my $return_code = $RETURN_OK;
|
---|
| 1437 |
|
---|
| 1438 | # cleanup repository
|
---|
[801] | 1439 | cleanup();
|
---|
[889] | 1440 |
|
---|
[800] | 1441 | #svn_update();
|
---|
| 1442 |
|
---|
| 1443 | ( my $refChangedFiles, my $refRemovedFiles, my $refUnknownFiles ) =
|
---|
| 1444 | getModifiedFiles($filename_prod);
|
---|
| 1445 | my %changedfiles = %{$refChangedFiles};
|
---|
| 1446 | my %removedfiles = %{$refRemovedFiles};
|
---|
| 1447 | my %unknownfiles = %{$refUnknownFiles};
|
---|
| 1448 |
|
---|
| 1449 | if ( %removedfiles or %changedfiles or %unknownfiles ) {
|
---|
| 1450 |
|
---|
| 1451 | if (%removedfiles) {
|
---|
| 1452 | print "DELETED files and directories. Recreated from repository:\n";
|
---|
[801] | 1453 | my @removedPaths =
|
---|
| 1454 | ( sort { length $a > length $b } keys %removedfiles );
|
---|
[800] | 1455 | print join( "\n", @removedPaths ) . "\n\n";
|
---|
| 1456 |
|
---|
| 1457 | # copy files one by one from local repository to system
|
---|
| 1458 | # and also create directories
|
---|
| 1459 | # paths are sorted, so that directories are created first
|
---|
[801] | 1460 | for my $real_path (@removedPaths) {
|
---|
| 1461 | if ( -d $removedfiles{"$real_path"} ) {
|
---|
[800] | 1462 | mkpath("$real_path");
|
---|
| 1463 | } else {
|
---|
[889] | 1464 | copy_file_from_repository_to_system($real_path);
|
---|
[800] | 1465 | }
|
---|
| 1466 | }
|
---|
| 1467 | }
|
---|
| 1468 |
|
---|
| 1469 | if (%changedfiles) {
|
---|
| 1470 | print "MODIFIED files. Copied from repository to the system:\n";
|
---|
| 1471 | print join( "\n", ( keys %changedfiles ) ) . "\n\n";
|
---|
| 1472 |
|
---|
| 1473 | # copy files one by one from local repository to system
|
---|
| 1474 | for my $real_file ( keys(%changedfiles) ) {
|
---|
[889] | 1475 | copy_file_from_repository_to_system($real_file);
|
---|
[800] | 1476 | }
|
---|
| 1477 |
|
---|
| 1478 | }
|
---|
| 1479 |
|
---|
| 1480 | if (%unknownfiles) {
|
---|
| 1481 | print "UNKNOWN: insufficient permission to check files:\n";
|
---|
| 1482 | print join( "\n", ( keys %unknownfiles ) ) . "\n\n";
|
---|
| 1483 |
|
---|
| 1484 | $return_code = $RETURN_NOK;
|
---|
| 1485 | }
|
---|
| 1486 |
|
---|
| 1487 | } else {
|
---|
| 1488 | print "no modified files found in $dirname_repo\n";
|
---|
| 1489 | }
|
---|
| 1490 |
|
---|
| 1491 | return $return_code;
|
---|
| 1492 | }
|
---|
| 1493 |
|
---|
[193] | 1494 | sub blame(@)
|
---|
| 1495 | {
|
---|
[205] | 1496 | check_parameter( @_, 1 );
|
---|
| 1497 | check_env();
|
---|
[193] | 1498 |
|
---|
[205] | 1499 | (
|
---|
| 1500 | my $basename,
|
---|
| 1501 | my $dirname_prod,
|
---|
| 1502 | my $dirname_repo,
|
---|
| 1503 | my $filename_prod,
|
---|
| 1504 | my $filename_repo
|
---|
[801] | 1505 | ) = get_filenames( $_[0] );
|
---|
[205] | 1506 |
|
---|
| 1507 | my $retcode = run_interactive("$SVN blame $svnOptions $filename_repo");
|
---|
[193] | 1508 | }
|
---|
| 1509 |
|
---|
[187] | 1510 | sub diff(@)
|
---|
| 1511 | {
|
---|
[205] | 1512 | check_parameter( @_, 1 );
|
---|
| 1513 | check_env();
|
---|
[187] | 1514 |
|
---|
[205] | 1515 | (
|
---|
| 1516 | my $basename,
|
---|
| 1517 | my $dirname_prod,
|
---|
| 1518 | my $dirname_repo,
|
---|
| 1519 | my $filename_prod,
|
---|
| 1520 | my $filename_repo
|
---|
[801] | 1521 | ) = get_filenames( $_[0] );
|
---|
[205] | 1522 |
|
---|
| 1523 | #print "$basename,$dirname_prod,$dirname_repo\n";
|
---|
| 1524 |
|
---|
[797] | 1525 | svn_update();
|
---|
[205] | 1526 |
|
---|
[238] | 1527 | ( my $rc_diff, my @diff_result ) =
|
---|
[239] | 1528 | run_command( $diff . " $filename_repo $filename_prod" );
|
---|
[238] | 1529 |
|
---|
| 1530 | print @diff_result;
|
---|
[187] | 1531 | }
|
---|
| 1532 |
|
---|
[209] | 1533 | sub status(@)
|
---|
| 1534 | {
|
---|
| 1535 | check_parameter( @_, 1 );
|
---|
| 1536 | check_env();
|
---|
| 1537 |
|
---|
[270] | 1538 | (
|
---|
| 1539 | my $basename,
|
---|
| 1540 | my $dirname_prod,
|
---|
| 1541 | my $dirname_repo,
|
---|
| 1542 | my $filename_prod,
|
---|
| 1543 | my $filename_repo
|
---|
[801] | 1544 | ) = get_filenames( $_[0] || "/" );
|
---|
[270] | 1545 |
|
---|
[252] | 1546 | # return code for the shell
|
---|
| 1547 | # default: error
|
---|
| 1548 | my $return_code = $RETURN_NOK;
|
---|
| 1549 |
|
---|
[209] | 1550 | #
|
---|
| 1551 | # update local repository
|
---|
| 1552 | #
|
---|
[278] | 1553 | #svn_update( $filename_prod );
|
---|
[209] | 1554 |
|
---|
[918] | 1555 | # perform plugins (required to see changes in plugin results)
|
---|
[916] | 1556 | perform_plugins();
|
---|
[278] | 1557 |
|
---|
| 1558 | # get modified files
|
---|
| 1559 | ( my $refChangedFiles, my $refRemovedFiles, my $refUnknownFiles ) =
|
---|
[275] | 1560 | getModifiedFiles($dirname_prod);
|
---|
[268] | 1561 | my %changedfiles = %{$refChangedFiles};
|
---|
| 1562 | my %removedfiles = %{$refRemovedFiles};
|
---|
[278] | 1563 | my %unknownfiles = %{$refUnknownFiles};
|
---|
[209] | 1564 |
|
---|
[278] | 1565 | if ( %removedfiles or %changedfiles or %unknownfiles ) {
|
---|
| 1566 |
|
---|
[215] | 1567 | if (%removedfiles) {
|
---|
[278] | 1568 | print "DELETED: files found in repository, but not in system:\n";
|
---|
[800] | 1569 | print join( "\n", sort ( keys %removedfiles ) ) . "\n\n";
|
---|
[209] | 1570 | }
|
---|
| 1571 |
|
---|
[215] | 1572 | if (%changedfiles) {
|
---|
[278] | 1573 | print "MODIFIED: files differs between repository and system:\n";
|
---|
| 1574 | print join( "\n", ( keys %changedfiles ) ) . "\n\n";
|
---|
[209] | 1575 | }
|
---|
[278] | 1576 |
|
---|
| 1577 | if (%unknownfiles) {
|
---|
| 1578 | print "UNKNOWN: insufficient permission to check files:\n";
|
---|
| 1579 | print join( "\n", ( keys %unknownfiles ) ) . "\n\n";
|
---|
| 1580 | }
|
---|
| 1581 |
|
---|
[209] | 1582 | } else {
|
---|
[270] | 1583 | print "no modified files found in $dirname_repo\n";
|
---|
[252] | 1584 | $return_code = $RETURN_OK;
|
---|
[209] | 1585 | }
|
---|
[215] | 1586 |
|
---|
[252] | 1587 | return $return_code;
|
---|
[215] | 1588 | }
|
---|
[209] | 1589 |
|
---|
[277] | 1590 | #
|
---|
| 1591 | # return short status in Nagios plugin conform way
|
---|
| 1592 | #
|
---|
| 1593 | sub check()
|
---|
| 1594 | {
|
---|
| 1595 | check_env();
|
---|
| 1596 |
|
---|
| 1597 | # return code for the shell
|
---|
[290] | 1598 | my $return_code = $RETURN_OK;
|
---|
[277] | 1599 | my $return_string = "OK: no modified files";
|
---|
| 1600 |
|
---|
[918] | 1601 | # perform plugins (required to see changes in plugin results)
|
---|
[916] | 1602 | perform_plugins();
|
---|
[278] | 1603 |
|
---|
| 1604 | # get modified files
|
---|
| 1605 | ( my $refChangedFiles, my $refRemovedFiles, my $refUnknownFiles ) =
|
---|
[290] | 1606 | getModifiedFiles("/");
|
---|
[277] | 1607 | my %changedfiles = %{$refChangedFiles};
|
---|
| 1608 | my %removedfiles = %{$refRemovedFiles};
|
---|
[278] | 1609 | my %unknownfiles = %{$refUnknownFiles};
|
---|
[277] | 1610 |
|
---|
| 1611 | if ( %removedfiles or %changedfiles ) {
|
---|
| 1612 | $return_string = "Warning: ";
|
---|
[290] | 1613 | if (%changedfiles) {
|
---|
| 1614 | $return_string .=
|
---|
| 1615 | "changed: " . join( ", ", ( keys %changedfiles ) ) . ". ";
|
---|
[277] | 1616 | }
|
---|
[290] | 1617 | if (%removedfiles) {
|
---|
| 1618 | $return_string .=
|
---|
| 1619 | "removed: " . join( ", ", ( keys %removedfiles ) ) . ". ";
|
---|
[277] | 1620 | }
|
---|
[278] | 1621 | if (%unknownfiles) {
|
---|
[290] | 1622 | $return_string .=
|
---|
| 1623 | "unknown: " . join( ", ", ( keys %unknownfiles ) ) . ". ";
|
---|
[278] | 1624 | }
|
---|
[277] | 1625 | $return_code = $RETURN_WARN;
|
---|
| 1626 | }
|
---|
| 1627 |
|
---|
| 1628 | # addition nagios Service Status
|
---|
| 1629 | #Critical
|
---|
| 1630 | #Unknown
|
---|
| 1631 |
|
---|
[290] | 1632 | print "$return_string\n";
|
---|
[277] | 1633 | return $return_code;
|
---|
| 1634 | }
|
---|
| 1635 |
|
---|
[270] | 1636 | sub permissions()
|
---|
[215] | 1637 | {
|
---|
| 1638 | check_env();
|
---|
| 1639 |
|
---|
[278] | 1640 | my $return_code = $RETURN_OK;
|
---|
| 1641 |
|
---|
[215] | 1642 | #
|
---|
| 1643 | # update local repository
|
---|
| 1644 | #
|
---|
| 1645 | #svn_update();
|
---|
| 1646 |
|
---|
[220] | 1647 | my $dir = $DASSCM_REPO;
|
---|
[275] | 1648 | my @files = svn_ls("/");
|
---|
[215] | 1649 |
|
---|
| 1650 | if (@files) {
|
---|
| 1651 |
|
---|
[918] | 1652 | print "#\n";
|
---|
| 1653 | print "# created by dasscm permissions\n";
|
---|
| 1654 | print "# It is intended to be used for restoring permissions\n";
|
---|
| 1655 | print "#\n";
|
---|
[220] | 1656 |
|
---|
[918] | 1657 | # generate and print permissions
|
---|
| 1658 | foreach my $line ( generatePermissionList(@files) ) {
|
---|
| 1659 | print "$line\n";
|
---|
[215] | 1660 | }
|
---|
[278] | 1661 |
|
---|
[215] | 1662 | }
|
---|
[278] | 1663 |
|
---|
| 1664 | return $return_code;
|
---|
[209] | 1665 | }
|
---|
| 1666 |
|
---|
[274] | 1667 | #
|
---|
| 1668 | # remove all uncommited changes in the repository
|
---|
| 1669 | #
|
---|
| 1670 | sub cleanup()
|
---|
| 1671 | {
|
---|
| 1672 | check_env();
|
---|
[268] | 1673 |
|
---|
[275] | 1674 | svn_revert($DASSCM_REPO);
|
---|
[285] | 1675 | svn_remove_unknown_files($DASSCM_REPO);
|
---|
[274] | 1676 | }
|
---|
| 1677 |
|
---|
[884] | 1678 | #
|
---|
| 1679 | # used for bash completion
|
---|
| 1680 | # prints the next possible command line parameters
|
---|
| 1681 | #
|
---|
| 1682 | sub complete(@)
|
---|
| 1683 | {
|
---|
[889] | 1684 | my @input = @_;
|
---|
[894] | 1685 | my %options_complete = ();
|
---|
[884] | 1686 |
|
---|
[894] | 1687 | # check and remove global options. if options are wrong, nothing to do
|
---|
[907] | 1688 | @ARGV = @input;
|
---|
[914] | 1689 | if ( GetOptions( \%options_complete, @OPTIONS_GLOBAL ) ) {
|
---|
[894] | 1690 | my $number_arguments = @input;
|
---|
| 1691 | if ( $number_arguments <= 1 ) {
|
---|
[893] | 1692 |
|
---|
[894] | 1693 | # complete dasscm commands
|
---|
| 1694 | my $input = $input[0] || "";
|
---|
| 1695 | map { m/^$input/ && print $_, "\n" } ( keys %COMMANDS );
|
---|
| 1696 | } else {
|
---|
[914] | 1697 |
|
---|
[894] | 1698 | # complete dasscm parameter
|
---|
| 1699 | my $command = get_command_uniform_name( $input[0] );
|
---|
[914] | 1700 | if ($command) {
|
---|
| 1701 |
|
---|
[895] | 1702 | # remove command
|
---|
| 1703 | shift @input;
|
---|
[887] | 1704 |
|
---|
[895] | 1705 | # check and remove options
|
---|
[914] | 1706 | my @options = get_command_possible_options($command);
|
---|
[907] | 1707 | @ARGV = @input;
|
---|
[914] | 1708 | if ( ( not @options )
|
---|
| 1709 | || ( GetOptions( \%options_complete, @options ) ) )
|
---|
| 1710 | {
|
---|
[895] | 1711 |
|
---|
[914] | 1712 | my @params = get_command_possible_params($command);
|
---|
[895] | 1713 | if ($verbose) { print "params: ", Dumper(@params); }
|
---|
| 1714 |
|
---|
| 1715 | my $number_arguments = @input;
|
---|
| 1716 |
|
---|
| 1717 | #print "input: ", join( ",", @input ), " (", $number_arguments, ")\n";
|
---|
| 1718 |
|
---|
[914] | 1719 | if ( $number_arguments > 0 ) {
|
---|
[895] | 1720 | my $parameter_number = $number_arguments - 1;
|
---|
| 1721 | if ( defined( $params[$parameter_number] )
|
---|
| 1722 | && $params[$parameter_number] )
|
---|
| 1723 | {
|
---|
| 1724 | my $param = $params[$parameter_number];
|
---|
[914] | 1725 | if ($verbose) {
|
---|
| 1726 | print "param used: ", $param, "\n";
|
---|
| 1727 | }
|
---|
[895] | 1728 | if ( $param eq "PATH_PROD" ) {
|
---|
[914] | 1729 | complete_path(
|
---|
| 1730 | $input[ $number_arguments - 1 ] );
|
---|
[895] | 1731 | } elsif ( $param eq "PATH_REPO" ) {
|
---|
[914] | 1732 | complete_repopath(
|
---|
| 1733 | $input[ $number_arguments - 1 ] );
|
---|
[895] | 1734 | }
|
---|
| 1735 | }
|
---|
| 1736 | }
|
---|
[894] | 1737 | }
|
---|
[887] | 1738 | }
|
---|
[884] | 1739 | }
|
---|
| 1740 | }
|
---|
| 1741 | }
|
---|
| 1742 |
|
---|
[887] | 1743 | sub complete_path(@)
|
---|
| 1744 | {
|
---|
| 1745 | check_parameter( @_, 1 );
|
---|
| 1746 | check_env();
|
---|
| 1747 |
|
---|
| 1748 | (
|
---|
| 1749 | my $basename,
|
---|
| 1750 | my $dirname_prod,
|
---|
| 1751 | my $dirname_repo,
|
---|
| 1752 | my $filename_prod,
|
---|
| 1753 | my $filename_repo
|
---|
| 1754 | ) = get_filenames( $_[0] );
|
---|
| 1755 |
|
---|
[889] | 1756 | my @files = get_complete_path_globbing($filename_prod);
|
---|
[887] | 1757 |
|
---|
| 1758 | if (@files) {
|
---|
| 1759 | print join( "\n", @files );
|
---|
| 1760 | print "\n";
|
---|
| 1761 | }
|
---|
| 1762 | }
|
---|
| 1763 |
|
---|
| 1764 | sub complete_repopath(@)
|
---|
| 1765 | {
|
---|
| 1766 | check_parameter( @_, 1 );
|
---|
| 1767 | check_env();
|
---|
| 1768 |
|
---|
| 1769 | (
|
---|
| 1770 | my $basename,
|
---|
| 1771 | my $dirname_prod,
|
---|
| 1772 | my $dirname_repo,
|
---|
| 1773 | my $filename_prod,
|
---|
| 1774 | my $filename_repo
|
---|
| 1775 | ) = get_filenames( $_[0] );
|
---|
| 1776 |
|
---|
[889] | 1777 | my @files = get_complete_path_globbing($filename_repo);
|
---|
| 1778 |
|
---|
[887] | 1779 | if (@files) {
|
---|
[889] | 1780 |
|
---|
[887] | 1781 | # remove DASSCM_REPO path again
|
---|
[889] | 1782 | print join(
|
---|
| 1783 | "\n",
|
---|
| 1784 | map( {
|
---|
| 1785 | s|^${DASSCM_REPO}|/|;
|
---|
| 1786 | $_
|
---|
| 1787 | } @files )
|
---|
| 1788 | );
|
---|
[887] | 1789 | print "\n";
|
---|
| 1790 | }
|
---|
| 1791 |
|
---|
| 1792 | }
|
---|
| 1793 |
|
---|
[189] | 1794 | #####################################################################
|
---|
| 1795 | #
|
---|
[186] | 1796 | # main
|
---|
[189] | 1797 | #
|
---|
[186] | 1798 |
|
---|
[252] | 1799 | my $return_code = $RETURN_OK;
|
---|
[186] | 1800 | my $number_arguments = @ARGV;
|
---|
| 1801 |
|
---|
[893] | 1802 | # global options
|
---|
| 1803 | # stops at first non-option
|
---|
[914] | 1804 | Getopt::Long::Configure('require_order');
|
---|
| 1805 | if ( not GetOptions( \%options, @OPTIONS_GLOBAL ) ) {
|
---|
[893] | 1806 | usage();
|
---|
| 1807 | exit $RETURN_NOK;
|
---|
| 1808 | }
|
---|
| 1809 |
|
---|
| 1810 | # set verbose to command line option
|
---|
| 1811 | $verbose = $options{'verbose'};
|
---|
| 1812 |
|
---|
[914] | 1813 | if ( $options{'help'} ) {
|
---|
[893] | 1814 | help(@ARGV);
|
---|
| 1815 | exit;
|
---|
| 1816 | }
|
---|
| 1817 |
|
---|
[892] | 1818 | # get subcommand and remove it from @ARGV
|
---|
[914] | 1819 | if ( defined( $ARGV[0] ) ) {
|
---|
[889] | 1820 | $command = get_command_uniform_name( $ARGV[0] );
|
---|
[205] | 1821 | shift @ARGV;
|
---|
[892] | 1822 | }
|
---|
[893] | 1823 |
|
---|
[914] | 1824 | if ( not defined($command) ) {
|
---|
| 1825 | usage();
|
---|
| 1826 | exit $RETURN_NOK;
|
---|
[893] | 1827 | }
|
---|
[196] | 1828 |
|
---|
[893] | 1829 | $DASSCM_LOCAL_REPOSITORY_BASE = $config->{'DASSCM_LOCAL_REPOSITORY_BASE'};
|
---|
| 1830 | $DASSCM_REPOSITORY_NAME = $config->{'DASSCM_REPOSITORY_NAME'};
|
---|
[205] | 1831 |
|
---|
[918] | 1832 | $DASSCM_PLUGIN_RESULTS_PATH =
|
---|
| 1833 | $config->{'DASSCM_LOCAL_REPOSITORY_BASE'} . "/" . "plugin-results/";
|
---|
[916] | 1834 |
|
---|
[918] | 1835 | # get list of additional directories and files, seperated by blank (" ")
|
---|
| 1836 | # these files are always stored in subversion
|
---|
| 1837 | if ( $config->{'DASSCM_ADDITIONAL_FILES'} ) {
|
---|
| 1838 | @DASSCM_ADDITIONAL_FILES = split / /, $config->{'DASSCM_ADDITIONAL_FILES'};
|
---|
| 1839 | } else {
|
---|
| 1840 | @DASSCM_ADDITIONAL_FILES = ( $DASSCM_PLUGIN_RESULTS_PATH );
|
---|
| 1841 | }
|
---|
| 1842 |
|
---|
[893] | 1843 | # TODO: check variables
|
---|
| 1844 | $DASSCM_SVN_REPOSITORY =
|
---|
[914] | 1845 | $config->{'DASSCM_SVN_REPOSITORY_BASE'} . "/" . $DASSCM_REPOSITORY_NAME;
|
---|
[205] | 1846 |
|
---|
[893] | 1847 | $DASSCM_CHECKOUT_USERNAME = $config->{'DASSCM_CHECKOUT_USERNAME'};
|
---|
| 1848 | $DASSCM_CHECKOUT_PASSWORD = $config->{'DASSCM_CHECKOUT_PASSWORD'};
|
---|
[205] | 1849 |
|
---|
[893] | 1850 | #
|
---|
| 1851 | # if a user is given by dasscm configuration file, we use it.
|
---|
| 1852 | # Otherwise we expect that read-only account is configured
|
---|
| 1853 | # as local subversion configuration.
|
---|
| 1854 | # If this is also not the case,
|
---|
| 1855 | # user is required to type username and password.
|
---|
| 1856 | # This will be stored as local subversion configuration thereafter.
|
---|
| 1857 | #
|
---|
| 1858 | if ( $DASSCM_CHECKOUT_USERNAME && $DASSCM_CHECKOUT_PASSWORD ) {
|
---|
| 1859 | $svnCheckoutCredentials =
|
---|
[914] | 1860 | " --username $DASSCM_CHECKOUT_USERNAME --password $DASSCM_CHECKOUT_PASSWORD ";
|
---|
[893] | 1861 | }
|
---|
[286] | 1862 |
|
---|
[893] | 1863 |
|
---|
| 1864 | # check for command options
|
---|
[914] | 1865 | my @cmd_options = get_command_possible_options($command);
|
---|
| 1866 | if (@cmd_options) {
|
---|
| 1867 |
|
---|
[205] | 1868 | # get command line options and store them in options hash
|
---|
[893] | 1869 | my $result = GetOptions( \%options, @cmd_options );
|
---|
[205] | 1870 |
|
---|
| 1871 | # print options
|
---|
| 1872 | foreach my $option ( keys %options ) {
|
---|
[215] | 1873 | print "${option}: $options{$option}\n";
|
---|
[205] | 1874 | }
|
---|
[893] | 1875 | }
|
---|
[205] | 1876 |
|
---|
[893] | 1877 | #
|
---|
| 1878 | # action accordinly to command are taken
|
---|
| 1879 | #
|
---|
| 1880 | &{ get_command_function($command) }(@ARGV);
|
---|
[214] | 1881 |
|
---|
[252] | 1882 | exit $return_code;
|
---|