libinstall.pm.in 17.5 KB
Newer Older
1 2 3
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2003-2010 University of Utah and the Flux Group.
5 6 7
# All rights reserved.
#
#
8 9
# A simple library for use in the installation scripts, to make them
# seem a little more legitimate, instead of the quick hacks they are.
10
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
11
use POSIX qw(strftime);
12
use Exporter;
13
use vars qw(@EXPORT $TOP_OBJDIR $TOP_SRCDIR
14
	    $TBROOT $LOGDIR $MAINSITE $PGENISUPPORT $GMAKE $PKG_INFO
15
	    $PORTSDIR $VARRUN $RCDIR $MYSQL $DBNAME
16 17
	    $SQL_UPDATE_MAJOR_REVISION $INSTALL_UPDATE_MAJOR_REVISION
	    $HAVE_XERCES);
18

19
@EXPORT = qw($TOP_OBJDIR $TOP_SRCDIR
20
	     $TBROOT $LOGDIR $MAINSITE $PGENISUPPORT $GMAKE $PKG_INFO
21
	     $PORTSDIR $VARRUN $RCDIR $MYSQL $DBNAME
22 23
	     $SQL_UPDATE_MAJOR_REVISION $INSTALL_UPDATE_MAJOR_REVISION
	     $HAVE_XERCES);
24 25 26 27

# Configure variables

$TBROOT        = "@prefix@";
28
$TOP_SRCDIR    = "@top_srcdir@";
29 30 31 32 33 34 35 36
$LOGDIR        = "$TBROOT/log";
$MAINSITE      = @TBMAINSITE@;
$PGENISUPPORT  = @PROTOGENI_SUPPORT@;
$GMAKE         = "/usr/local/bin/gmake";
$PKG_INFO      = "/usr/sbin/pkg_info";
$PORTSDIR      = "/usr/ports";
$VARRUN        = "/var/run";
$RCDIR         = "/usr/local/etc/rc.d";
37

38 39
$DBNAME        = "@TBDBNAME@";
$MYSQL         = "/usr/local/bin/mysql";
40
$HAVE_XERCES   = "@HAVE_XERCES@";
41 42 43 44 45 46

# Change these if the major numbers in sql/updates or install/updates
# are changed.
$SQL_UPDATE_MAJOR_REVISION	= 4;
$INSTALL_UPDATE_MAJOR_REVISION	= 5;

47 48 49 50 51
#
# Make sure that output gets printed right away
#
$| = 1;

52
#
53
# Magic string that shows up in files already edited 
54
#
55
my $MAGIC_TESTBED_VERSION = $INSTALL_UPDATE_MAJOR_REVISION + ".0";
56 57
my $MAGIC_TESTBED_START   = "Added by Emulab - Version: ";
my $MAGIC_TESTBED_END     = "End of Emulab added section";
58

59 60
sub MAGIC_TESTBED_START { $MAGIC_TESTBED_START . $MAGIC_TESTBED_VERSION; }
sub MAGIC_TESTBED_END   { $MAGIC_TESTBED_END; }
61

62 63 64 65 66
# When used in update mode, printing is a little different.
my $updatemode = 0;

# Used by update-install to bump the version number.
sub SET_TESTBED_VERSION($)  { $updatemode = $MAGIC_TESTBED_VERSION = $_[0]; }
67

68 69 70 71 72
# Set by update-install.
my $impotent   = 0;
my $logfp;
sub SET_IMPOTENT_MODE($)	    { $impotent = 1; $logfp = $_[0]; };

73 74 75 76 77
#
# Some programs we may call
#
my $FETCH = "/usr/bin/fetch";

78 79 80 81 82 83 84 85
#
# Figure out which directory we live in, so that some stages can do thing
# relative to it.
#
$TOP_OBJDIR = `/usr/bin/dirname $0`;
chomp $TOP_OBJDIR;
$TOP_OBJDIR = "$TOP_OBJDIR/..";

86 87 88 89 90 91 92
#
# Let's pretend perl's exception mechanism has a sane name for the function
# that raises an exception
#
sub throw(@) {
    die @_,"\n";
}
93

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
#
# Start a new installation phase
#
sub Phase($$$) {
    my ($name, $descr, $coderef) = @_;

    push @libinstall::phasestack, $name;
    push @libinstall::descrstack, $descr;
    
    #
    # Okay, this will probably earn me my own special circle in Perl Hell. Use
    # dynamic scoping to allow data to be passed inbetween indirectly recursive
    # calls of Phase(). hasSubPhase is used to determine if we were called
    # recursively in the eval(). skipped and nonSkipped let us figure out if
    # all child calls were skipped. But, we have to give this information to
    # our parent _after_ we declare our own. So, we use references. Damn!
    #
 
    $hasSubPhase++;
    my $firstSubPhase = ($hasSubPhase == 1);
    local $hasSubPhase = 0;
    
    my $parentNonSkipped = \$nonSkipped;
    my $parentSkipped = \$skipped;
    local $nonSkipped = 0;
    local $skipped = 0;
    
    local $depth = ($depth? $depth +1 : 1);
    my $isSubPhase = ($depth > 1);

    my $descrstring = "| " x ($depth -1) . $descr;
125
    if ($firstSubPhase) {
126
	print "\n";
127 128
	printf $logfp "\n"
	    if ($impotent);
129 130
    }
    printf "%-50s", $descrstring;
131 132
    printf $logfp "%-50s", $descrstring
	if ($impotent);
133 134 135 136 137 138

    #
    # Clear these, as we don't want to see the outputs of previous phases
    #
    @libinstall::lastExecOutput = ();
    $libinstall::lastCommand = undef;
139
    @libinstall::loglines = ();
140 141 142 143 144 145 146 147 148 149 150 151 152 153

    #
    # Cool! TWO levels of Perl Hell just for me!
    # We pretend we have real exceptions, here. The way this works, we _expect_
    # something to call die(), which is how you throw exceptions in perl. Neat,
    # huh? The three calls below (Phase?*()) are the ones that do this.
    #
    eval { &$coderef(); };

    #
    # Prepare for printing!
    #
    my $message = "";
    my $die = 0;
154
    my $stop = 0;
155
    if ($hasSubPhase) {
156
	print  "| " x ($depth -1) . "+-" . "--" x (24 - $depth) . "> ";
157 158 159 160 161 162 163
    }

    #
    # Check the exception thrown by the eval()
    #
    SWITCH: for ($@) {
	(/^skip$/) && do {
164
	    print "[ Skipped ($libinstall::reason) ]\n";
165 166
	    print $logfp "[ Skipped ($libinstall::reason) ]\n"
		if ($impotent && defined($logfp));
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
	    $$parentSkipped++;
	    $libinstall::phaseResults{$name} = $_;
	    last SWITCH;
	};

	(/^fail$/) && do {
	    print "[ Failed    ]\n";
	    $$parentNonSkipped++;
	    $libinstall::phaseResults{$name} = $_;
	    $die = 1;
	    $message = "Installation failed: $libinstall::reason";
	    if ($isSubPhase) {
		#
		# Propagate failure up the tree
		#
		PhaseFail($libinstall::reason);
	    }
	    last SWITCH;
	};

187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
	(/^stop$/) && do {
	    print "[ Stopped    ]\n";
	    print $logfp "[ Stopped ($libinstall::reason) ]\n"
		if ($impotent && defined($logfp));
	    $$parentNonSkipped++;
	    $message = "$libinstall::reason";
	    if ($impotent) {
		$libinstall::phaseResults{$name} = "succeed";
	    }
	    else {
		$libinstall::phaseResults{$name} = $_;
		$stop = 1;
		if ($isSubPhase) {
		    #
		    # Propagate failure up the tree
		    #
		    PhaseStop($libinstall::reason);
		}
	    }
	    last SWITCH;
	};

209 210 211 212
	(undef || /^$/ || /^succeed$/) && do {
	    #
	    # If we're a parent, and all sub-phases got skipped, we did too
	    #
Leigh B. Stoller's avatar
Leigh B. Stoller committed
213 214
	    my $stamp = POSIX::strftime("%H:%M:%S", localtime());
	    
215
	    if ($hasSubPhase && $skipped && ($nonSkipped == 0)) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
216
		print "[ Skipped   ] ($stamp)\n";
217 218
		print $logfp "[ Skipped   ]\n"
		    if ($impotent && defined($logfp));
219 220 221
		$libinstall::phaseResults{$name} = "skip";
		$$parentSkipped++;
	    } else {
222 223 224 225 226 227 228 229 230 231 232 233 234
		if ($impotent) {
		    if (defined($logfp)) {
			print $logfp "[ $libinstall::reason ]\n";
		    
			print $logfp 
			    "> " . join("\n> ", @libinstall::loglines) . "\n"
			    if (@libinstall::loglines);
		    }
		    print "[ $libinstall::reason ]\n";
		}
		else {
		    print "[ Succeeded ] ($stamp)\n";
		}
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
		$$parentNonSkipped++;
		$libinstall::phaseResults{$name} = "succeed";
	    }
	    last SWITCH;
	};

	#
	# Default case - shouldn't get here, unless something called die with
	# the wrong value
	#
	print "[ ERROR     ]\n";
	$$parentNonSkipped++;
	$message = "Internal error - Bad exception:\n$_";
	$libinstall::phaseResults{$name} = "fail";
        $die = 1;
	if ($isSubPhase) {
	    #
	    # Propagate failure up the tree
	    #
	    PhaseFail($message);
	}
    }

258 259 260 261 262 263 264 265 266 267 268 269
    #
    # If we decided that we need to stop, do that now
    #
    if ($stop) {
	print "\n";
	print "############################################################\n";
	print "Installation stopped in phase $name. The reason is:\n";
	print "$message\n";
	print "############################################################\n";
	exit -1;
    }

270 271 272 273
    #
    # If we decided that we need to die, do that now
    #
    if ($die) {
274
	print "\n##### Installation failed in phase $name. The error was:\n";
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
	print "$message\n";
	PrintPhaseTrace();
	PrintLastOutput();
	print "Please send the above output to testbed-ops\@emulab.net\n";
	exit -1;
    }

    #
    # Pop ourselves off the phase stack!
    #
    pop @libinstall::phasestack;
    pop @libinstall::descrstack;

}

#
# Signal that the current phase has suceeded
#
sub PhaseSucceed(;$) {
    ($libinstall::reason) = (@_);
    if (!$libinstall::reason) {
	$libinstall::reason = "succeeded";
    }
    throw "succeed";
}

#
# Signal that the current phase has failed
#
sub PhaseFail($) {
    ($libinstall::reason) = (@_);
    throw "fail";
}

309 310 311 312 313 314 315 316
#
# Signal that the current phase needs to stop so the user can do something.
#
sub PhaseStop($) {
    ($libinstall::reason) = (@_);
    throw "stop";
}

317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
#
# Signal that the current phase is being skipped
#
sub PhaseSkip($) {
    ($libinstall::reason) = (@_);
    throw "skip";
}

#
# Check to see if a previous phase was skipped. Returns 1 if it was, 0 if not
#
sub PhaseWasSkipped($) {
    my ($phase) = (@_);
    return ($libinstall::phaseResults{$phase} &&
    	($libinstall::phaseResults{$phase} =~ /^skip$/));
}

334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
#
# For impotent mode.
#
sub PhaseWouldHave($) {
    ($libinstall::reason) = (@_);
    throw "succeed";
}

#
# Also for impotent mode; detailed logging.
#
sub PhaseLog(@) {
    (@libinstall::loglines) = (@_);
}

#
# Also for impotent mode; log differences to a file.
#
sub DiffFiles($$) {
    my ($src,$dst) = @_;

    return
	if (!$impotent);

    if (! -e $dst) {
	my $stuff = `cat $src`;
	PhaseLog(split('\n', $stuff));
    }
    my $diff = `diff $src $dst`;
    PhaseLog(split('\n', $diff));
}
    
366 367 368 369 370 371
#
# Check to see if the phase is already done, as evidenced by the existance of
# a file
#
sub DoneIfExists($) {
    my ($filename) = @_;
372
    if (!$filename) { PhaseFail("Bad filename passed to DoneIfExists"); }
373
    if (-e $filename) {
374
	PhaseSkip("File already exists");
375 376 377
    }
}

378 379 380 381 382 383 384
#
# Same as above, but done if it doesn't exist
#
sub DoneIfDoesntExist($) {
    my ($filename) = @_;
    if (!$filename) { PhaseFail("Bad filename passed to DoneIfExists"); }
    if (!-e $filename) {
385
	PhaseSkip("File does not exist");
386 387 388
    }
}

389 390 391 392 393 394
#
# Check to see if the phase is already done, as evidenced by the existance of
# comments within a file
#
sub DoneIfEdited($) {
    my ($filename) = @_;
395
    if (!$filename) { PhaseFail("Bad filename passed to DoneIfEdited"); }
396
    my $magic_string = MAGIC_TESTBED_START();
397
    open(FH,$filename) or return;
398
    if (grep /$magic_string/, <FH>) {
399
        close(FH);
400
	PhaseSkip("File has already been edited");
401
    }
402
    close(FH);
403 404 405 406 407 408
}

#
# Check to see if the phase is already done, as evidenced by the fact that two
# files are identical
#
409
sub DoneIfIdentical($$) {
410 411 412 413
    my ($filename1,$filename2) = @_;
    if (!$filename1 || !$filename2) {
	PhaseFail("Bad filename passed to DoneIfIdentical");
    }
414 415 416
    if (!-e $filename1 || !-e $filename2) {
	return;
    }
417 418
    system("cmp -s $filename1 $filename2");
    if (! $?) {
419
	PhaseSkip("Files $filename1 and $filename2 are identical");
420 421 422
    }
}

423 424 425 426 427
#
# Done if package installed.
#
sub DoneIfPackageInstalled($) {
    my ($pname) = @_;
Mike Hibler's avatar
Mike Hibler committed
428
    my $foo = `$PKG_INFO -x $pname 2>&1`;
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
    if (! $?) {
	PhaseSkip("already installed");
    }
}

#
# Backup a file or fail.
#
sub BackUpFileFatal($)
{
    my ($filename) = @_;
    my $suffix     = time();
    my $backup     = $filename . "-" . $suffix;

    PhaseFail("$filename does not exist")
	if (! -e $filename);
Leigh B Stoller's avatar
Leigh B Stoller committed
445 446 447 448 449 450 451

    if (-e $backup) {
	sleep(1);
	$backup = $filename . "-" . time();
	PhaseFail("$backup already exists")
	    if (-e $backup);
    }
452 453 454 455 456

    ExecQuietFatal("/bin/cp -p $filename $backup")
	if (!$impotent);
}

457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
#
# Check to see if filesystem already mounted
#
sub DoneIfMounted($)
{
    my ($dir) = @_;

    #
    # Grab the output of the mount command and parse. 
    #
    if (! open(MOUNT, "/sbin/mount|")) {
	PhaseFail("Cannot run mount command");
    }
    while (<MOUNT>) {
	if ($_ =~ /^([-\w\.\/:\(\)]+) on ([-\w\.\/]+) \((.*)\)$/) {
	    # Search for nfs string in the option list.
	    foreach my $opt (split(',', $3)) {
		if ($opt eq "nfs") {
		    if ($dir eq $2) {
			close(MOUNT);
477
			PhaseSkip("NFS dir already mounted");
478 479 480 481 482 483 484 485 486
		    }
		}
	    }
	}
    }
    close(MOUNT);
    return;
}

487 488 489 490 491 492 493 494 495 496
#
# Append some text to a configuration file, with a special testbed tag that 
# will help inform the user of what's been done, and help future invocations
# tell that this has already been done. Returns undef if it succeeds, or
# an error string if it fails
# TODO - handle alternate comment characters
# TODO - handle files that it's OK to create
#
sub AppendToFile($@) {
    my ($filename, @lines) = @_;
497 498 499 500 501 502

    if ($impotent) {
	PhaseLog(@lines);
	PhaseWouldHave("append to $filename");
	return undef;
    }
503 504 505 506 507 508
    if (!-e $filename) {
	return "File $filename does not exist";
    }
    open(FH,">>$filename") or return "Unable to open $filename for ".
	"writing: $!";

509
    print FH "# " . MAGIC_TESTBED_START() . "\n";
510
    print FH map "$_\n", @lines;
511
    print FH "# " . MAGIC_TESTBED_END() . "\n";
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534

    close(FH);

    return undef;
}

#
# Same as above, but call PhaseFail on failure
#
sub AppendToFileFatal($@) {
    my ($filename,@lines) = @_;
    my $error = AppendToFile($filename,@lines);
    if ($error) {
	PhaseFail($error);
    }
}

#
# Create a new file (must not already exist), and fill it with the given
# contents. Returns undef if successful, or an error message otherwise.
#
sub CreateFile($;@) {
    my ($filename,@lines) = @_;
535 536 537 538 539 540

    if ($impotent) {
	PhaseLog(@lines);
	PhaseWouldHave("create $filename");
	return undef;
    }
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
    if (-e $filename) {
	return "File $filename already exists";
    }
    open(FH,">$filename") or return "Unable to open $filename for ".
	"writing: $!";

    if (@lines) {
	print FH map "$_\n", @lines;
    }

    close FH;
    return undef;    
}

#
# Same as above, but call PhaseFail on failure
#
sub CreateFileFatal($@) {
    my ($filename,@lines) = @_;
    my $error = CreateFile($filename,@lines);
    if ($error) {
	PhaseFail($error);
    }
}

#
# Execute a program, hiding its stdout and stderr from the user, but saving
568 569 570
# them for later use. Returns the exit value of the program if used in scalar
# context, or an array composed of the exit status and output if used in array
# context.
571 572 573 574 575 576
#
sub ExecQuiet(@) {
    #
    # Use a pipe read, so that we save away the output
    #
    my $commandstr = join(" ",@_);
577 578 579 580 581 582

    if ($impotent) {
	PhaseWouldHave("exec($commandstr)");
        return 0;
    }
    
583 584 585 586 587 588 589 590 591 592 593 594
    my @output = ();
    open(PIPE,"$commandstr 2>&1 |") or return -1;
    while (<PIPE>) {
	push @output, $_;
    }
    close(PIPE);

    my $exit_value  = $? >> 8;

    @libinstall::lastExecOutput = @output;
    $libinstall::lastCommand = $commandstr;

595 596 597 598 599
    if (wantarray) {
	return ($exit_value, @output);
    } else {
	return $exit_value;
    }
600 601 602 603 604 605 606 607 608 609 610 611
}

#
# Same as the above, but the current phase fails if the program returns a non-0
# exit status.
#
sub ExecQuietFatal(@) {
    if (ExecQuiet(@_)) {
	PhaseFail("Unable to execute: ");
    }
}

612
#
613
# Signal a daemon, if it's PID file exists. If we can't kill it, we assume that
614 615 616 617 618
# it's because it wasn't running, and skip the phase. Fails if it has trouble
# reading the pid file.
# Takes the name of the daemon as an argument, and assumes
# that the pid file is /var/run/$name.pid
#
619 620
sub SignalDaemon($$) {
    my ($name,$sig) = @_;
621 622 623 624 625 626 627 628
    my $pidfile = "/var/run/$name.pid";
    PhaseSkip("$name is not running") unless (-e $pidfile);
    open(PID,$pidfile) or PhaseFail("Unable to open pidfile $pidfile");
    my $pid = <PID>;
    chomp $pid;
    close PID;

    PhaseFail("Bad pid ($pid) in $pidfile\n") unless ($pid =~ /^\d+$/);
629 630 631 632 633 634 635

    if ($impotent) {
	PhaseWouldHave("signal($sig) $name");
	return;
    }
    if (!kill($sig, $pid)) {
	PhaseSkip("$name is not running");
636 637 638
    }
}

639 640 641 642 643 644
sub HUPDaemon($) {
    my ($name) = @_;

    SignalDaemon($name, 'HUP');
}

645 646 647
#
# Restart a daemon if running. Do not start if not running.
#
648 649
sub RestartDaemon($;$) {
    my ($name, $path) = @_;
650 651 652 653 654 655 656 657 658 659 660 661 662 663

    my $pidfile = "$VARRUN/${name}.pid";

    if (! -e "$VARRUN/stated.pid") {
	PhaseSkip("Testbed not running");
    }
    if (!-e $pidfile) {
	PhaseSkip("$name not running");
    }
    if ($impotent) {
	PhaseWouldHave("restart $name");
	return 1;
    }
    SignalDaemon($name, 'TERM');
664
    sleep(1);
665 666 667
    $path = "$TBROOT/sbin/$name"
	if (!defined($path));
    if (ExecQuiet($path) == 0) {
668 669 670 671 672
	PhaseSucceed("$name started");
    }
    PhaseFail("Could not start $name");
}

673 674 675 676 677 678
#
# Fetch a file from the network, using any protocol supported by fetch(1).
# Arguments are URL and a local filename. Retunrns 1 if succesful, 0 if not.
#
sub FetchFile($$) {
    my ($URL, $localname) = @_;
679 680 681 682 683 684

    if ($impotent) {
	PhaseLog("$URL --> $filename");
	PhaseWouldHave("fetch $URL");
	return 1;
    }
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701
    if (ExecQuiet("$FETCH -o $localname $URL")) {
	return 0;
    } else {
	return 1;
    }
}

#
# Same as above, but failure is fatal
#
sub FetchFileFatal($$) {
    my ($URL, $localname) = @_;
    if (!FetchFile($URL,$localname)) {
	PhaseFail("Unable to fetch $URL");
    }
}

702 703 704 705 706 707 708 709 710 711 712 713
#
# Locate the proper version of a package to install by looking
# at the available package tarballs.
#
# Must be called "in phase" since we will PhashFail on errors.
#
sub GetPackage($$) {
    my ($prefix, $packagedir) = @_;

    PhaseFail("Must provide -p (packagedir) argument!")
	if (!$packagedir);

714
    my $pname = `ls $packagedir/$prefix-*.tbz 2>/dev/null`;
715
    if ($?) {
716
	$pname = `ls $packagedir/$prefix-*.tgz 2>/dev/null`;
717 718 719 720 721 722 723 724
	PhaseFail("Cannot find $prefix package in $packagedir!")
	    if ($?);
    }
    chomp($pname);

    return $pname;
}

725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752
#
# Print out the phase stack that got us here
#
sub PrintPhaseTrace() {
    print "-------------------------------------------------- Phase Stack\n";
    my @tmpphase = @libinstall::phasestack;
    my @tmpdescr = @libinstall::descrstack;
    my ($phase, $descr);
    while (@tmpdescr) {
	($phase, $descr) = (pop @tmpphase, pop @tmpdescr);
	printf "%-10s %-50s\n", $phase, $descr;
    }
    print "--------------------------------------------------------------\n";
}

#
# Print out the ouput of the last command that ran
#
sub PrintLastOutput() {
    if (!$libinstall::lastCommand) {
	return;
    }
    print "------------------------------------------ Last Command Output\n";
    print "Command: $libinstall::lastCommand\n";
    print @libinstall::lastExecOutput;
    print "--------------------------------------------------------------\n";
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
753 754 755 756 757 758 759 760 761 762
#
# Get me a secret
#
sub GenSecretKey()
{
    my $key=`/bin/dd if=/dev/urandom count=128 bs=1 2> /dev/null | /sbin/md5`;
    chomp($key);
    return $key;
}

763
1;