head	1.19;
access;
symbols;
locks
	mohlerb:1.19; strict;
comment	@# @;


1.19
date	2000.05.04.21.17.56;	author mohlerb;	state Exp;
branches;
next	1.18;

1.18
date	2000.04.17.04.37.46;	author mohlerb;	state Exp;
branches;
next	1.17;

1.17
date	2000.04.04.03.29.40;	author mohlerb;	state Exp;
branches;
next	1.16;

1.16
date	2000.03.16.23.01.10;	author mohlerb;	state Exp;
branches;
next	1.15;

1.15
date	2000.03.03.00.08.58;	author mohlerb;	state Exp;
branches;
next	1.14;

1.14
date	99.10.20.20.07.57;	author mohlerb;	state Exp;
branches;
next	1.13;

1.13
date	99.08.11.20.28.11;	author mohlerb;	state Exp;
branches;
next	1.12;

1.12
date	99.08.06.21.54.49;	author mohlerb;	state Exp;
branches;
next	1.11;

1.11
date	99.08.04.17.03.34;	author mohlerb;	state Exp;
branches;
next	1.10;

1.10
date	99.08.04.03.59.02;	author mohlerb;	state Exp;
branches;
next	1.9;

1.9
date	99.08.04.00.29.01;	author mohlerb;	state Exp;
branches;
next	1.8;

1.8
date	99.07.02.21.59.26;	author mohlerb;	state Exp;
branches;
next	1.7;

1.7
date	99.07.02.16.06.51;	author mohlerb;	state Exp;
branches;
next	1.6;

1.6
date	99.06.22.19.25.45;	author mohlerb;	state Exp;
branches;
next	1.5;

1.5
date	99.06.18.21.20.38;	author mohlerb;	state Exp;
branches;
next	1.4;

1.4
date	99.06.18.17.10.36;	author mohlerb;	state Exp;
branches;
next	1.3;

1.3
date	99.06.16.16.04.21;	author mohlerb;	state Exp;
branches;
next	1.2;

1.2
date	99.06.05.00.25.00;	author mohlerb;	state Exp;
branches;
next	1.1;

1.1
date	99.06.04.22.56.18;	author mohlerb;	state Exp;
branches;
next	;


desc
@install script for the web server scripts
@


1.19
log
@changes from Bruce Mohler including:
check for a file ".ran.install" left behind by the install
shell script; if the file doesn't exist, then quit with an
appropriate comment
@
text
@#!/usr/bin/perl
#
# install.pl - Install the web server scripts
# 
# Synopsis:
# 
#	install.pl [ -d ] [ -f ] [ -h ]
# 
# This script
# 
#	Makes sure we're running as root (you can force *not* running as root).
# 
#	Makes sure all required files are in current working directory.
# 
#	Makes sure syssumm account is setup properly.
# 
#	Copies incoming.pl to syssumm home directory and makes sure
# 	.forward file exists.
# 
#	Checks for web server configuration file in syssumm home
# 	directory and creates it if it doesn't exist.  This file
# 	contains path to CGI directory and base of Root of directory
# 	tree for HTML documents.
# 
#	It copies sysquery.pl into the CGI directory.
# 
#	It make sure that the syssumm sub-directory exists under
#	HTML root directory.  If syssumm.format doesn't exist,
#	it copies that file into the syssumm sub-directory otherwise
#	it prompts the user to let him/her know that the file
#	exists but may have local modifications.  Ditto for the
# 	syssumm.header file (it will not overwrite an existing
# 	file).
# 
# This script assumes that we're running under a UNIX-like
# operating system.
# 
# The idea for this script was suggested by Bart Swennen:
# 
# BS would it be possible to put all things that must be customized into a
# BS separate file and to distribute only a sample for this file, but not the
# BS file itself in the sources ? In this way, users can put their own
# BS customizations in that file, starting with the sample file as an
# BS example. When a new release arrives, you just have to unpack it and
# BS leave the customization file as you edited it before. Because it is not
# BS in the source distribution, it will not be overwritten by unpacking the
# BS new release.
# 
# ==============================================================
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 
# 2 of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be 
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.
# 
# Original source:
# 	Copyright (c) 1999, 2000 SAIC (Bruce W. Mohler)
# 
# Contributed source:
# 	Copyright (c) 1999, 2000 Martin Andrews
# 
# ==============================================================
# 
# $Header: /export/home/mohlerb/syssumm/web.server/RCS/install.pl,v 1.18 2000/04/17 04:37:46 mohlerb Exp mohlerb $
# 
# $Revision: 1.18 $
# 
# $Log: install.pl,v $
# Revision 1.18  2000/04/17 04:37:46  mohlerb
# changes from Bruce Mohler including:
# removed reference to obsolete function CreateConfigurationFile;
# this defect was found by Michael Seeger <michael.seeger@@mchh.siemens.de>
#
# Revision 1.17  2000/04/04 03:29:40  mohlerb
# changes from Frank Crawford including:
# added copy of setfield.pl and use of current perl executable,
# rather than a statically defined one
#
# Revision 1.16  2000/03/16 23:01:10  mohlerb
# changes from Bruce Mohler including:
# changes to support re-write LoadConfigurationFile function;
# note that the CreateConfigurationFile function no longer
# exists; a single argument to LoadConfigurationFile function
# (boolean) which states whether to try to fix problems if
# one or more configuration tags are missing; this is only
# true in install.pl, false for all other scripts; therefore
# if tags are added to the configuration file in later versions,
# it will automatically prompt for new values and add them to
# the file
#
# Revision 1.15  2000/03/03 00:08:58  mohlerb
# changes from Bruce Mohler including:
# restructed code to make script more modular; added @@Comments
# which functions can add text to; if @@Comments contains any
# lines, they are displayed at the end of the program so that
# the system administrator can see things that are really
# important (like they need to update their syssumm.format
# file)
#
# Revision 1.14  1999/10/20 20:07:57  mohlerb
# changes from Bruce Mohler including:
# support for $DOCROOT/syssumm/syssumm.header file for customizing
# web pages at your local site
#
# Revision 1.13  1999/08/11 20:28:11  mohlerb
# changes from Paul Farrall including:
# Replaced subroutine CopyFile() with Perl library function copy()
# in File::Copy package
# Added some lines to check for existing $PATH.  If none is set,
# then set it to /bin:/usr/bin.  Otherwise append /bin:/usr/bin,
# but don't nuke what's already there
# Added SearchForPerl() subroutine.  All syssumm scripts look
# for Perl in /usr/bin.  Since users may have Perl installed
# somewhere else, I thought it would be nice if we check that
# for the user
# If it finds it in some other place than /usr/bin it makes
# symbolic link /usr/bin/perl -> path_to_perl.  If it can't find
# perl interpreter, it displays a warning message, but doesn't
# stop script execution
#
# Revision 1.12  1999/08/06 21:54:49  mohlerb
# changes from Paul Farrall including:
# changed default path to Perl to /usr/bin
# changed install.pl to make a backup of any existing version of
# sysquery.pl before copying over it
# did the same for incoming.pl, common.pm, and updatelists.pl
# added copy of updatelists.pl to syssumm home directory
# fixed error on setting file permissions on format file
# changed .forward install to print "installed .forward..." OR
# ".forward found..."
#
# Revision 1.11  1999/08/04 17:03:34  mohlerb
# changes from Bruce Mohler including:
# when the syssumm home directory and web.server.info files are
# created, make sure that they are created with permissions that
# make them globally readable, otherwise processes like the
# sysquery.pl script (running under the web server account) may
# not get access to the common.pm and configuration files.
#
# Revision 1.10  1999/08/04 03:59:02  mohlerb
# changes from Bruce Mohler including:
# added a little more explanatory information at the point where
# the script stops to let you create the syssumm account
#
# Revision 1.9  1999/08/04 00:29:01  mohlerb
# changes from Bruce Mohler including:
# the function that checks to make sure that MANIFEST is all
# present properly tests for directories now, not just files
#
# Revision 1.8  1999/07/02 21:59:26  mohlerb
# changes from Bruce Mohler including:
# fixes after testing sysquery.pl
#
# Revision 1.7  1999/07/02 16:06:51  mohlerb
# changes from Bruce Mohler including:
# snapshot of major revisions to web server scripts
# factored many common functions into common.pm (different from
# common.pm in remote sub-directory!!!)
# added support for creating and maintain list files for sysquery.pl
# lists (OS, Vendor, Location, Organization) in an expandable fashion
# all scripts were tested except for sysquery.pl
#
# Revision 1.6  1999/06/22 19:25:45  mohlerb
# changes from Bruce Mohler including:
# added $SyssummUserid to the config file so that the value is
# persistent across installations
#
# Revision 1.5  1999/06/18 21:20:38  mohlerb
# changes from Frank Crawford and Bruce Mohler including:
# Frank: Addition of command line option to specify SysSumm user.
# Frank: Various bug fixes.
# Bruce: Check each config file entry to make sure that it's in
# Bruce: the correct order.
# Bruce: Fix hard-coded source for processing entries into and
# Bruce: out of the configuration file.  Driven by 1 array and
# Bruce: 2 hashes.
#
# Revision 1.4  1999/06/18 17:10:36  mohlerb
# changes from Bruce Mohler including:
# changes to support additional CUSTOMIZE field based on Paul's
# prior patch - these changes are not tested yet!!!
#
# Revision 1.3  1999/06/16 16:04:21  mohlerb
# changes from Martin Andrews including:
# fixes for routines prompting for information
#
# Revision 1.2  1999/06/05 00:25:00  mohlerb
# changes from Bruce Mohler including:
# the CUSTOMIZE fields are inserted during the installation
# process by using the install.pl script
#
# Revision 1.1  1999/06/04 22:56:18  mohlerb
# Initial revision
#

use FileHandle;
use File::Copy;  # includes copy function for copying files
use Getopt::Std;
use common;

#######################################################################
# Global Variables
#######################################################################

# switches set on the command line
$Debug = 0;
$DisplayHelpAndQuit = 0;
$RunAnyway = 0;

# 
# At run-time, certain global variables are defined from a
# persistent configuration file by the function LoadConfigurationFile
# in common.pm.  Refer to the source in that Perl module to 
# determine which variables are defined.
# 
# In addition, certain variables are exported into the calling
# scripts main:: name space including the syssumm home directory,
# uid, and gid.
# 

$ManifestFileName = "MANIFEST";

# common Perl module
$CommonPerlModule = "common.pm";

# e-mail information
$ScriptPermissions = 0755;
$FilePermissions = 0644;
$IncomingScriptName = "incoming.pl";
$ForwardFileName = ".forward";
$UpdateListsScriptName = "updatelists.pl";
$SetFieldScriptName = "setfield.pl";

# web server information
$DirectoryPermissions = 0755;

$DefaultPathToPerl = $^X;
$AbsoluteDefaultPathToPerl = "/usr/bin/perl";

@@Comments = ( );


#######################################################################
# Subroutines
#######################################################################

############################ Main Functions ###########################

sub ProcessCommandLine
{
	if ( -f ".ran.install" ) {
		unlink ".ran.install";
	}
	else {
		print STDERR "You need to run \"./install\" rather than \"./install.pl\".\n";
		print STDERR "Exiting...\n";
		exit 1;
	}

	if ( getopts('dfh') ) {
		if ( $opt_d ) { $Debug = 1; }
		if ( $opt_f ) { $RunAnyway = 1; }
		if ( $opt_h ) { $DisplayHelpAndQuit = 1; }
	}
	else {
		die "There were problems processing the command line.";
	}

	if ( $DisplayHelpAndQuit ) {
		DisplayHelp();
		exit(0);
	}

	return;
}


#######################################################################
# Initialization
#######################################################################

sub InitializeStuff
{
	RunAsRoot();
	SearchForPerl();
	CheckManifest();
	CheckForConfigFile();

	return;
}


sub RunAsRoot
{
	if ( $< != 0 ) {		# running as uid 0 (zero)?
		print STDERR "You're not running as root ";
		if ( $RunAnyway ) {
			print STDERR "but I guess you know what you're doing...\n\n";
		}
		else {
			print STDERR "so I'm going to terminate...\n";
			print STDERR "If you're really want to run this script ";
			print STDERR "as someone other than root,";
			print STDERR "use the \'-f\' command line option\n";
			exit(1);
		}
	}

	# let's set the path just in case...
	# But don't nuke existing path if it exists

	if ( $ENV{PATH} ) {
		$ENV{"PATH"} = "$ENV{PATH}" . ":/bin:/usr/bin";
	} else {
		$ENV{"PATH"} = "/bin:/usr/bin";
	}

	return;
}


sub SearchForPerl()
{
	# All syssumm scripts look for perl in $DefaultPathToPerl, so
	# check if it's there.  If not, find it and add symbolic link.

	# Make sure that $DefaultPathToPerl is an absolute
	# path.  If not, default to /usr/bin...
	if ( ! ( "$DefaultPathToPerl" =~ /^\// ) ) {
		# relative path
		$DefaultPathToPerl = $AbsoluteDefaultPathToPerl;
	}

	if ( ! ( -f "$DefaultPathToPerl")) {
		print "Looks like the perl interpreter is not in /usr/bin\n";
		print "Please wait while I look for it...\n";

		my $FoundIt = 0;
		foreach $Directory ( split(/:/, $ENV{"PATH"}) ) {
			print "Looking for perl in $Directory.....";
			if ( -f "$Directory/perl" ) {
				print "Found it!\nAdding symlink $Directory/perl -> $DefaultPathToPerl\n";
				$FoundIt = 1;
				symlink("$Directory/perl", "$DefaultPathToPerl") or
					warn "Couldn't create symlink: $!";
				my $Comment = "Created symlink $Directory/perl /usr/bin/perl";
				push @@Comments, $Comment;
				last;
			}
			print "\n";
		}
		if ( ! $FoundIt ) {
			print STDERR "Couldn't find the perl executable in any\n";
			print STDERR "of the directories in your PATH variable.\n";
			print STDERR "Please create a symbolic link in /usr/bin\n";
			print STDERR "to your perl executable.\n";
			exit(1);
		}
	}
	else {
		print "Found perl in $DefaultPathToPerl\n";
	}

	return 0;
}


sub CheckManifest
{
	# does the Manifest file exist in the current directory?
	if ( ! -f $ManifestFileName ) {
		print STDERR "I cannot find the $ManifestFileName file in the current directory\n";
		print STDERR "This script assumes that you've un-tar'd all of the\n";
		print STDERR "files for the web server into the current directory.\n";
		exit(1);
	}

	# how "fresh" is the file?
	if ( ( -M $ManifestFileName ) > 30 ) {
		print STDERR "The $ManifestFileName file is over 30 days old.\n";
		print STDERR "It may be stale!\n";
		if ( $RunAnyway ) {
			print STDERR "Since you're running with '-f', I'll continue.\n";
		}
		else {
			exit(1);
		}
	}

	# load the file and make sure all of the files are present
	open MANIFEST, "<$ManifestFileName" or
		die "Coulnd't open $ManifestFileName file: $!";
	my @@ListOfFiles = <MANIFEST>;
	chomp(@@ListOfFiles);
	close MANIFEST;

	my $NotFound = 0;
	foreach $File (@@ListOfFiles) {
		if ( ! ( -f $File or -d $File )) {
			print STDERR "Didn't find file/directory: $File\n";
			$NotFound = 1;
		}
	}
	if ( $NotFound ) {
		print STDERR "One or more required files in the $ManifestFileName file were not found.\n";
		exit(1);
	}

	print "All required files are present.\n\n";

	return;
}


sub CheckForConfigFile
{
	# does the account exist?
	my $HomeDirectory = (getpwnam($SyssummUserid))[7];
	if ( $HomeDirectory eq "" ) {
		print STDERR "No $SyssummUserid account exists.\n";
		print STDERR "If you are running the install script for the first time, please create\n";
		print STDERR "the account before you rerun this script.\n";
		print STDERR "For example, if you are running this script under Linux, you could:\n\n";
		print STDERR "useradd -g <gid> -u <uid> -m -n syssumm\n\n";
		print STDERR "Substitute a real uid and gid for the <uid>\n";
		print STDERR "and <gid> in the example.\n";
		exit(1);
	}

	# make sure the home directory exists
	if ( ! -d $HomeDirectory ) {
		print STDERR "The home directory for the $SyssummUserid account doesn't exist.\n";
		print STDERR "Please create the directory before you rerun the script.\n";
		exit(1);
	}
	print "A home directory for $SyssummUserid exists...\n\n";

	# make sure permissions on home directory are correct
	my $Mode = ( stat $HomeDirectory )[2];
	# we only want the permission bits...
	$Mode = $Mode & 0777;
	if ( $Mode != $DirectoryPermissions ) {
		print STDERR "The permissions on the home directory for the $SyssummUserid account\n";
		print STDERR "need to be changed to 0755.\n";
		exit(1);
	}

	# does the configuration file exist?
	my $PathToConfigFile = "$HomeDirectory/$ConfigurationFileName";
	LoadConfigurationFile(1);

	return;
}


#######################################################################
# Syssumm Account Validation
#######################################################################

sub CheckSyssummAccount
{
	CheckSyssummPasswd();
	CheckSyssummUid();

	return;
}


sub CheckSyssummPasswd
{
	# is it password protected?
	my $Password = (getpwnam($SyssummUserid))[1];
	if ( $Password eq "" ) {	# Nope.
		print STDERR "The $SyssummUserid account exists but doen't have a password.\n";
		print STDERR "This is a potential security problem.\n";
		print STDERR "Please put a password on the account before you rerun the script.\n";
		exit(1);
	}
	print "It is protected by a password...\n";

	return;
}


sub CheckSyssummUid
{
	# make sure that the uid is not 0 (zero)
	if ( $SyssummUid == 0 ) {		# Yep.
		print STDERR "The uid of the $SyssummUserid account is zero (ie., root)\n";
		print STDERR "This is a potential security problem.\n";
		print STDERR "Please change the uid before you rerun the script.\n";
		exit(1);
	}
	print "It has no special priveleges...\n";

	return;
}


#######################################################################
# Email Setup
#######################################################################

sub SetupEmail
{
	SetupEmailFiles();
	SetupEmailForwardFile();

	return;
}


sub SetupEmailFiles
{
	# 
	# XXX - This routine doesn't take smrsh-enabled systems into account
	# 

	foreach $File ( "$IncomingScriptName", "$CommonPerlModule", "$UpdateListsScriptName", "$SetFieldScriptName" ) {

		# Make an attempt to backup files if they already exist
		if ( -f "$SyssummHomeDirectory/$File" ) {
			rename ("$SyssummHomeDirectory/$File", "$SyssummHomeDirectory/$File.bak") ||
				die "can't back up $File\n";
			print "$File Exists (and was backed up)\n";
		}

		copy($File, $SyssummHomeDirectory);
	
		# make sure ownerships and permissions are correct
		my $PathToFile = "$SyssummHomeDirectory/$File";
		chown $SyssummUid, $SyssummGid, $PathToFile;
		if ( $File =~ /\.pl$/ ) {
			chmod $ScriptPermissions, $PathToFile;
		}
		else {
			chmod $FilePermissions, $PathToFile;
		}
	
		print "$File copied to $SyssummHomeDirectory\n";
	}

	return;
}


sub SetupEmailForwardFile
{
	# make sure that the .forward file exists
	my $PathToForwardFile = "$SyssummHomeDirectory/$ForwardFileName";
	my $PathToScript = "$SyssummHomeDirectory/$IncomingScriptName";
	if ( ! -f $PathToForwardFile ) {
		open FORWARD, (">$PathToForwardFile") or
			die "Couldn't create $PathToForwardFile: $!";
		print FORWARD "|$PathToScript\n";
		close FORWARD;

		# make sure ownerships and permissions are correct
		chown $SyssummUid, $SyssummGid, $PathToForwardFile;
		chmod $FilePermissions, $PathToForwardFile;

		print "$PathToForwardFile created\n";
	}
	else {
		print "A .forward file already exists...\n\n";
	}

	# 
	# One thing we might wnat to do is to check the permissions
	# on the .forward file *even* if it exists.  During one of
	# my testing sessions, I had the forwarding function fail
	# because the .forward file was owned by me and not syssumm.
	# 

	return;
}


#######################################################################
# Web Setup
#######################################################################

sub SetupWeb
{

	SetupCgiScript();

	my $PathToSyssummDirectory = "$DocrootDirectory/$SyssummDirectory";

	SetupSubDirectory($PathToSyssummDirectory);
	SetupFormatFile($PathToSyssummDirectory);
	SetupHeaderFile($PathToSyssummDirectory);

	return;
}


sub SetupCgiScript
{
	# move the (new) CGI script into CGI directory
	foreach $File ( "$CGIScriptName", ) {

		# Make an attempt to backup script if it already exists.
		if ( -f "$CGIDirectory/$CGIScriptName" ) {
			print "$CGIDirectory/$CGIScriptName Exists\n";
			rename ("$CGIDirectory/$CGIScriptName", "$CGIDirectory/$CGIScriptName.bak") ||
				die "can't back up $CGIDirectory/$CGIScriptName\n";
			print "$CGIDirectory/$CGIScriptName backed up\n";
		}

		copy($File, $CGIDirectory);
	
		# make sure ownerships and permissions are correct
		my $PathToFile = "$CGIDirectory/$File";
		chown $SyssummUid, $SyssummGid, $PathToFile;
		if ( $File =~ /\.pl$/ ) {
			chmod $ScriptPermissions, $PathToFile;
		}
		else {
			chmod $FilePermissions, $PathToFile;
		}
	
		print "$File copied to $CGIDirectory\n";
	}

	return;
}


sub SetupSubDirectory ($)
{	my $PathToSyssummDirectory = shift;

	# make sure syssumm sub-directory exists
	if ( ! -d $PathToSyssummDirectory ) {
		mkdir $PathToSyssummDirectory, $DirectoryPermissions or
			die "Couldn't create directory $PathToSyssummDirectory: $!";
		chown $SyssummUid, $SyssummGid, $PathToSyssummDirectory;
	}
	print "$PathToSyssummDirectory exists...\n";

	return;
}


sub SetupFormatFile ($)
{	my $PathToSyssummDirectory = shift;

	# check out the format file
	my $PathToFormatFile = "$PathToSyssummDirectory/$FormatFileName";
	# if it already exists...
	if ( -f $PathToFormatFile ) {
		# ... then move the prior one out of the way
		my $PathToFormatFileBackup = "$PathToFormatFile$PreviousFileSuffix";
		rename $PathToFormatFile, $PathToFormatFileBackup or
			die "Couldn't rename $PathToFormatFile: $!";

		push @@Comments, "A prior format file was found and saved as";
		push @@Comments, "$PathToFormatFileBackup.";
		push @@Comments, "Hand merge any local changes into the new format file.";
	}

	copy($FormatFileName, $PathToSyssummDirectory);

	chown $SyssummUid, $SyssummGid, $PathToFormatFile;
	chmod $FilePermissions, $PathToFormatFile;

	print "$FormatFileName copied to $PathToSyssummDirectory...\n\n";

	return;
}


sub SetupHeaderFile ($)
{	my $PathToSyssummDirectory = shift;

	# check out the header file
	my $PathToHeaderFile = "$PathToSyssummDirectory/$HeaderFileName";
	if ( ! -f $PathToHeaderFile ) {
		# file doesn't exist
		copy($HeaderFileName, $PathToSyssummDirectory);

		chown $SyssummUid, $SyssummGid, $PathToHeaderFile;
		chmod $FilePermissions, $PathToHeaderFile;

		print "$HeaderFileName copied to $PathToSyssummDirectory...\n\n";
	}
	else {
		print "A header file already exists.\n";
	}

	return;
}


#######################################################################
# Utility Stuff
#######################################################################

sub PrintComments
{
	if ( @@Comments ) {
		# mark this as beginning of special output
		print '*' x 76; print "\n";
		print '*' x 76; print "\n";

		foreach $Line (@@Comments) {
			print "* $Line\n";
		}

		# mark this as end of special output
		print '*' x 76; print "\n";
		print '*' x 76; print "\n";
	}

	return;
}


sub DisplayHelp
{
	print "System Summaries web server install script\n";
	print "synopsis: install.pl [ -d ] [ -f ] [ -h ]\n";
	print "\t-d\tTurn on debugging output\n";
	print "\t-f\tForce the script to run even though you're not root\n";
	print "\t-h\tPrints what you're reading now\n";

	return;
}


#######################################################################
# Mainline
#######################################################################

STDOUT->autoflush(1);
STDERR->autoflush(1);

ProcessCommandLine();
InitializeStuff();
CheckSyssummAccount();
SetupEmail();
SetupWeb();
print "syssumm install.pl complete...\n";
PrintComments();

unlink ".ran.install";

#######################################################################
# We're done!
#######################################################################
exit(0);
@


1.18
log
@changes from Bruce Mohler including:
removed reference to obsolete function CreateConfigurationFile;
this defect was found by Michael Seeger <michael.seeger@@mchh.siemens.de>
@
text
@d68 1
a68 1
# $Header: /export/home/mohlerb/syssumm/web.server/RCS/install.pl,v 1.17 2000/04/04 03:29:40 mohlerb Exp mohlerb $
d70 1
a70 1
# $Revision: 1.17 $
d73 5
d242 1
d255 9
d331 7
d339 2
a340 1
		print( "Looks like the perl interpreter is not in /usr/bin\nPlease wait while I look for it...\n");
a526 1
			print "$File Exists\n";
d529 1
a529 1
			print "$File backed up\n";
d750 2
@


1.17
log
@changes from Frank Crawford including:
added copy of setfield.pl and use of current perl executable,
rather than a statically defined one
@
text
@d68 1
a68 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.16 2000/03/16 23:01:10 mohlerb Exp mohlerb $
d70 1
a70 1
# $Revision: 1.16 $
d73 5
a430 3
	if ( ( ! -f $PathToConfigFile ) or -z $PathToConfigFile ) {
		CreateConfigurationFile();
	}
@


1.16
log
@changes from Bruce Mohler including:
changes to support re-write LoadConfigurationFile function;
note that the CreateConfigurationFile function no longer
exists; a single argument to LoadConfigurationFile function
(boolean) which states whether to try to fix problems if
one or more configuration tags are missing; this is only
true in install.pl, false for all other scripts; therefore
if tags are added to the configuration file in later versions,
it will automatically prompt for new values and add them to
the file
@
text
@d68 1
a68 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.15 2000/03/03 00:08:58 mohlerb Exp mohlerb $
d70 1
a70 1
# $Revision: 1.15 $
d73 12
d226 1
d231 1
a231 1
$DefaultPathToPerl = "/usr/bin/perl";
d498 1
a498 1
	foreach $File ( "$IncomingScriptName", "$CommonPerlModule", "$UpdateListsScriptName" ) {
@


1.15
log
@changes from Bruce Mohler including:
restructed code to make script more modular; added @@Comments
which functions can add text to; if @@Comments contains any
lines, they are displayed at the end of the program so that
the system administrator can see things that are really
important (like they need to update their syssumm.format
file)
@
text
@d68 1
a68 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.14 1999/10/20 20:07:57 mohlerb Exp mohlerb $
d70 1
a70 1
# $Revision: 1.14 $
d73 9
d386 4
a389 3
		print STDERR "For example, if you are running this script under Linux, you could:\n";
		print STDERR "useradd -g 20 -u 143 -m -n syssumm\n";
		print STDERR "(assuming that uid 143 was available...)\n";
d416 1
a416 1
	LoadConfigurationFile();
d423 1
a423 1
# Syssumm Accout Validation
@


1.14
log
@changes from Bruce Mohler including:
support for $DOCROOT/syssumm/syssumm.header file for customizing
web pages at your local site
@
text
@d61 1
a61 1
# 	Copyright (c) 1999 SAIC (Bruce W. Mohler)
d64 1
a64 1
# 	Copyright (c) 1999 Martin Andrews
d68 1
a68 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.13 1999/08/11 20:28:11 mohlerb Exp mohlerb $
d70 1
a70 1
# $Revision: 1.13 $
d73 5
d211 1
d213 1
d240 3
a242 3
#
# Make sure we're running as root
# 
d244 11
d292 1
d297 1
d300 2
d306 7
d412 4
d418 9
d437 6
d456 3
a458 3
# 
# This function sets up the incoming.pl script and the .forward file
# 
d460 1
a460 1
sub CheckEmailSetup
d462 9
d500 6
d536 3
a538 4
# 
# This function sets up the CGI script, the format file, and the
# syssumm sub-directory.
# 
d540 1
a540 1
sub CheckWebSetup
d542 15
d583 2
a584 1
	my $PathToSyssummDirectory = "$DocrootDirectory/$SyssummDirectory";
d586 4
d598 7
d607 6
a612 3
	if ( ! -f $PathToFormatFile ) {
		# file doesn't exist
		copy($FormatFileName, $PathToSyssummDirectory);
d614 3
a616 4
		chown $SyssummUid, $SyssummGid, $PathToFormatFile;
		chmod $FilePermissions, $PathToFormatFile;

		print "$FormatFileName copied to $PathToSyssummDirectory...\n\n";
a617 5
	else {
		print "A format file already exists.\n";
		print "Examine the change log at the beginning of the file\n";
		print "and hand merge any desired changes.\n\n";
	}
d619 14
d652 24
d696 1
a696 4
RunAsRoot();
SearchForPerl();
CheckManifest();
CheckForConfigFile();
d698 2
a699 2
CheckEmailSetup();
CheckWebSetup();
d701 1
@


1.13
log
@changes from Paul Farrall including:
Replaced subroutine CopyFile() with Perl library function copy()
in File::Copy package
Added some lines to check for existing $PATH.  If none is set,
then set it to /bin:/usr/bin.  Otherwise append /bin:/usr/bin,
but don't nuke what's already there
Added SearchForPerl() subroutine.  All syssumm scripts look
for Perl in /usr/bin.  Since users may have Perl installed
somewhere else, I thought it would be nice if we check that
for the user
If it finds it in some other place than /usr/bin it makes
symbolic link /usr/bin/perl -> path_to_perl.  If it can't find
perl interpreter, it displays a warning message, but doesn't
stop script execution
@
text
@d31 3
a33 1
#	exists but may have local modifications.
d68 1
a68 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.12 1999/08/06 21:54:49 mohlerb Exp mohlerb $
d70 1
a70 1
# $Revision: 1.12 $
d73 16
d533 15
@


1.12
log
@changes from Paul Farrall including:
changed default path to Perl to /usr/bin
changed install.pl to make a backup of any existing version of
sysquery.pl before copying over it
did the same for incoming.pl, common.pm, and updatelists.pl
added copy of updatelists.pl to syssumm home directory
fixed error on setting file permissions on format file
changed .forward install to print "installed .forward..." OR
".forward found..."
@
text
@d66 1
a66 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.11 1999/08/04 17:03:34 mohlerb Exp mohlerb $
d68 1
a68 1
# $Revision: 1.11 $
d71 11
d147 1
d186 1
d188 1
d236 1
a236 1
	$ENV{PATH} = "/bin:/usr/bin";
d238 6
d248 27
d286 2
a287 2
	if ( ( -M $ManifestFileName ) > 15 ) {
		print STDERR "The $ManifestFileName file is over 15 days old.\n";
d410 1
a410 1
		CopyFile($File, $SyssummHomeDirectory);
d473 1
a473 1
		CopyFile($File, $CGIDirectory);
d502 1
a502 1
		CopyFile($FormatFileName, $PathToSyssummDirectory);
a530 22
########################## Utility Functions ##########################

# 
# This script assumes that the input file is in the current directory
# 

sub CopyFile
{	my $InputFile = shift;
	my $DestinationDirectory = shift;

	my $OutputFile = "$DestinationDirectory/$InputFile";

	print "Copying $InputFile -> $OutputFile...\n" if $Debug;

	my @@CommandLineArgs = ("cp", "$InputFile", "$OutputFile");
	system(@@CommandLineArgs) == 0 or
		die "system @@CommandLineArgs failed: $!";

	return;
}


d540 1
@


1.11
log
@changes from Bruce Mohler including:
when the syssumm home directory and web.server.info files are
created, make sure that they are created with permissions that
make them globally readable, otherwise processes like the
sysquery.pl script (running under the web server account) may
not get access to the common.pm and configuration files.
@
text
@d1 1
a1 1
#!/usr/local/bin/perl
d66 1
a66 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.10 1999/08/04 03:59:02 mohlerb Exp mohlerb $
d68 1
a68 1
# $Revision: 1.10 $
d71 8
d169 1
d353 10
a362 1
	foreach $File ( "$IncomingScriptName", "$CommonPerlModule" ) {
d393 3
a395 1
	print "A .forward file exists...\n\n";
d417 9
d458 1
a458 1
		chmod $FormatFilePermissions, $PathToScript;
@


1.10
log
@changes from Bruce Mohler including:
added a little more explanatory information at the point where
the script stops to let you create the syssumm account
@
text
@d66 1
a66 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.9 1999/08/04 00:29:01 mohlerb Exp mohlerb $
d68 1
a68 1
# $Revision: 1.9 $
d71 5
d288 10
@


1.9
log
@changes from Bruce Mohler including:
the function that checks to make sure that MANIFEST is all
present properly tests for directories now, not just files
@
text
@d66 1
a66 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.8 1999/07/02 21:59:26 mohlerb Exp mohlerb $
d68 1
a68 1
# $Revision: 1.8 $
d71 5
d267 5
a271 2
		print STDERR "If you are running the install script for the first time, please create it before \n";
		print STDERR "you rerun this script.\n";
@


1.8
log
@changes from Bruce Mohler including:
fixes after testing sysquery.pl
@
text
@d66 1
a66 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.7 1999/07/02 16:06:51 mohlerb Exp mohlerb $
d68 1
a68 1
# $Revision: 1.7 $
d71 4
d240 2
a241 2
		if ( ! -f $File ) {
			print STDERR "Didn't find file: $File\n";
@


1.7
log
@changes from Bruce Mohler including:
snapshot of major revisions to web server scripts
factored many common functions into common.pm (different from
common.pm in remote sub-directory!!!)
added support for creating and maintain list files for sysquery.pl
lists (OS, Vendor, Location, Organization) in an expandable fashion
all scripts were tested except for sysquery.pl
@
text
@d66 1
a66 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.6 1999/06/22 19:25:45 mohlerb Exp mohlerb $
d68 1
a68 1
# $Revision: 1.6 $
d71 9
d144 1
a144 1
$FilePermissions = 0600;
a149 2
$CGIScriptName = "sysquery.pl";
$FormatFileName = "syssumm.format";
d369 1
a369 1
	foreach $File ( "$CGIScriptName", "$CommonPerlModule" ) {
@


1.6
log
@changes from Bruce Mohler including:
added $SyssummUserid to the config file so that the value is
persistent across installations
@
text
@d7 1
a7 1
#	install.pl [ -d ] [ -f ] [ -h ] [ -u <user> ]
d66 1
a66 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.5 1999/06/18 21:20:38 mohlerb Exp mohlerb $
d68 1
a68 1
# $Revision: 1.5 $
d71 5
d106 1
a115 1
$SyssummUserid = "syssumm";			# note the default
d117 11
a127 1
# account information
a128 3
$SyssummUid = 0;
$SyssummGid = 0;
$HomeDirectory = "";
d130 3
a140 1
$ConfigurationFileName = "web.server.info";
a141 1
$SyssummDirectory = "syssumm";
a142 1
$ProfileFileName = "syssumm.info";
a143 7
# values in stored configuration file
$CGIDirectory = "";
$HtdocDirectory = "";
$AdminEmailAddress = "";
$Webmaster = "";
$WebmasterEmailAddress = "";
$WebServerUrl = "";
a144 40
# 
# It is assumed that the following fields are in a certain order
# 
# We can probably fix this later on...
# 

@@ConfigFileFields = (
	SyssummUserid,
	CGIDirectory,
	HtdocDirectory,
	AdminEmailAddress,
	Webmaster,
	WebmasterEmailAddress,
	WebServerUrl,
);

%ConfigFieldPrompts = (
	SyssummUserid => "Enter the userid to use for the installation",
	CGIDirectory => "Enter path to your CGI directory",
	HtdocDirectory => 
		"Enter path to your web server document root directory",
	AdminEmailAddress => 
		"Enter e-mail address for your local System Administrator (with escaped '\@@')",
	Webmaster => "Enter \"name\" for webmaster on bottom of web page",
	WebmasterEmailAddress => 
		"Enter e-mail address for Webmaster (with escaped '\@@')",
	WebServerUrl => "Enter the URL for the web server",
);

%ConfigFieldTypes = (
	SyssummUserid => "name",
	CGIDirectory => "directory",
	HtdocDirectory => "directory",
	AdminEmailAddress => "email",
	Webmaster => "name",
	WebmasterEmailAddress => "email",
	WebServerUrl => "",
);


d153 1
a153 1
	if ( getopts('dfhu:') ) {
a156 1
		if ( $opt_u ) { $SyssummUserid = $opt_u; }
d245 1
a245 1
sub CheckConfigFile
d247 8
a254 1
	my $PathToConfigFile = "$HomeDirectory/$ConfigurationFileName";
d256 8
d265 3
a267 2
	if ( ! -f $PathToConfigFile ) {
		CreateConfigurationFile($PathToConfigFile);
d269 1
a269 1
	LoadConfigurationFile($PathToConfigFile);
a276 10
	# does the account exist?
	my ( $Name, $Password, $Uid, $Gid, $Quota, $Comment, 
	     $Gecos, $HomeDir, $Shell ) = getpwnam($SyssummUserid);
	if ( $Name eq "" ) {		# Nope.
		print STDERR "No syssumm account exists.\n";
		print STDERR "Please create it before you rerun this script.\n";
		exit(1);
	}
	print "An account exists for syssumm...\n";

d278 1
d280 1
a280 1
		print STDERR "The syssumm account exists but doen't have a password.\n";
d288 2
a289 2
	if ( $Uid == 0 ) {		# Yep.
		print STDERR "The uid of the syssumm account is zero (ie., root)\n";
a295 13
	# make sure the home directory exists
	if ( ! -d $HomeDir ) {
		print STDERR "The home directory for the syssumm account doesn't exist.\n";
		print STDERR "Please create the directory before you rerun the script.\n";
		exit(1);
	}
	print "A home directory for syssumm exists...\n\n";

	# global         local
	$HomeDirectory = $HomeDir;
	$SyssummUid = $Uid;
	$SyssummGid = $Gid;

d310 15
a324 2
	# copy the (new) incoming script to the syssumm home directory
	CopyPerlScript($IncomingScriptName, $HomeDirectory);
a325 10
	my $PathToScript = "$HomeDirectory/$IncomingScriptName";

	# make sure ownerships and permissions are correct
	chown $SyssummUid, $SyssummGid, $PathToScript;
	chmod $ScriptPermissions, $PathToScript;

	print "$IncomingScriptName copied to $HomeDirectory\n";

	my $PathToForwardFile = "$HomeDirectory/$ForwardFileName";

d327 2
d343 7
a360 2
	my $PathToConfigFile = "$HomeDirectory/$ConfigurationFileName";

d362 15
a376 1
	CopyPerlScript($CGIScriptName, $CGIDirectory);
d378 1
a378 1
	my $PathToScript = "$CGIDirectory/$CGIScriptName";
a379 8
	# make sure ownerships and permissions are correct
	chown $SyssummUid, $SyssummGid, $PathToScript;
	chmod $ScriptPermissions, $PathToScript;

	print "$CGIScriptName copied to $CGIDirectory...\n";

	my $PathToDirectory = "$HtdocDirectory/$SyssummDirectory";

d381 4
a384 4
	if ( ! -d $PathToDirectory ) {
		mkdir $PathToDirectory, $DirectoryPermissions or
			die "Couldn't create directory $PathToDirectory: $!";
		chown $SyssummUid, $SyssummGid, $PathToDirectory;
d386 1
a386 1
	print "$PathToDirectory exists...\n";
a387 2
	my $PathToFormatFile = "$PathToDirectory/$FormatFileName";

d389 1
d392 1
a392 4
		# move the new format file into place
		my @@args = ( "mv", "-f", $FormatFileName, $PathToDirectory );
		system(@@args) == 0 or
			die "system call @@args failed: $!";
d397 1
a397 1
		print "$FormatFileName copied to $PathToDirectory...\n\n";
d412 1
a412 1
	print "synopsis: install.pl [ -d ] [ -f ] [ -h ] [ -u <user> ]\n";
a415 1
	print "\t-u <user>\tSets user to <user> (default \"$SyssummUserid\")\n";
a422 54
sub PromptForDirectoryPath
{	my $Prompt = shift;
	my $DirectoryPath = "";

	while ( 1 == 1 ) {
		$DirectoryPath = PromptFor($Prompt);
		last if -d $DirectoryPath;
		print STDERR "That directory doesn't exist...\n";
	}

	return $DirectoryPath;
}


sub PromptForEmailAddress
{	my $Prompt = shift;
	my $EmailAddress = "";

	while ( 1 == 1 ) {
		$EmailAddress = PromptFor($Prompt);
		last if $EmailAddress =~ /\@@/;
		print STDERR "Invalid email address...\n";
	}

	return $EmailAddress;
}


sub PromptForName
{	my $Prompt = shift;
	my $Name = "";

	while ( 1 == 1 ) {
		$Name = PromptFor($Prompt);
		last if $Name =~ /\w/;
		print STDERR "Invalid name...\n";
	}

	return $Name;
}


sub PromptFor
{	my $Prompt = shift;
	my $Result = "";

	print STDOUT "$Prompt: ";
	$Result = <STDIN>;
	chomp($Result);

	return $Result;
}


a423 99
# The "flow of control" in the next 2 functions is controlled
# by an array, @@ConfigFileFields, and 2 hashes, %ConfigFieldPrompts
# and %ConfigFieldTypes, which should be defined above...
# 

# 
# The following two functions create a "persistant"
# configuration file for the scripts that reside on
# the web server computer.
# 
# The format of this file is
# 
#	tab=value
# 
# This is a sample of the file:
# 
#	CGIDirectory=/home/httpd/cgi-bin
#	HtdocDirectory=/home/httpd/html
#	AdminEmailAddress=root\@@stegasaurus.saic.com
#	Webmaster=Webmaster
#	WebmasterEmailAddress=root\@@stegasaurus.saic.com
# 

sub CreateConfigurationFile
{	my $PathToConfigFile = shift;

	# get the information...
	foreach $Tag (@@ConfigFileFields) {
		if ( $ConfigFieldTypes{$Tag} eq "directory" ) {
			${$Tag} = PromptForDirectoryPath($ConfigFieldPrompts{$Tag});
		}
		elsif ( $ConfigFieldTypes{$Tag} eq "email" ) {
			${$Tag} = PromptForEmailAddress($ConfigFieldPrompts{$Tag});
		}
		elsif ( $ConfigFieldTypes{$Tag} eq "name" ) {
			${$Tag} = PromptForName($ConfigFieldPrompts{$Tag});
		}
		else {
			${$Tag} = PromptFor($ConfigFieldPrompts{$Tag});
		}
	}

	# save them to a file
	open CONFIG, ">$PathToConfigFile" or
		die "Couldn't open $PathToConfigFile for output: $!";
	foreach $Tag (@@ConfigFileFields) {
		print CONFIG "$Tag=${$Tag}\n";
	}
	close(CONFIG);

	# make sure ownerships and permissions are correct
	chown $SyssummUid, $SyssummGid, $PathToConfigFile;
	chmod $FilePermissions, $PathToConfigFile;

	if ( $Debug ) {
		foreach $Tag (@@ConfigFileFields) {
			print "$Tag is ${$Tag}...\n";
		}
	}

	return;
}


sub LoadConfigurationFile
{	my $PathToConfigFile = shift;
	my $Line = "";

	open CONFIG, "<$PathToConfigFile" or
		die "Couldn't open $PathToConfigFile for input: $!";
	my $LineNbr = 1;
	foreach $Tag (@@ConfigFileFields) {
		$Line = <CONFIG>;
		chomp($Line);
		if ( $Line =~ /$Tag/ ) {
			$Line =~ /$Tag=(.*$)/;
			${$Tag} = $1;
			# auto escape "@@"
			${$Tag} =~ s/([^\\])@@/$1\\\@@/;       
		}
		else {
			die "Could not find tag $Tag on line number $LineNbr of config file";
		}
	}
	close(CONFIG);

	if ( $Debug ) {
		foreach $Tag (@@ConfigFileFields) {
			print "$Tag is ${$Tag}...\n";
		}
	}

	print "Prior configuration file loaded from $PathToConfigFile\n";

	return;
}


# 
d427 2
a428 2
sub CopyPerlScript
{	my $ScriptName = shift;
d431 1
a431 2
	my $InputFile = $ScriptName;
	my $OutputFile = "$DestinationDirectory/$ScriptName";
d435 3
a437 5
	print "CGI directory is $CGIDirectory...\n" if $Debug;
	print "httpd document root is $HtdocDirectory...\n" if $Debug;
	print "Admin e-mail address is $AdminEmailAddress...\n" if $Debug;
	print "Webmaster name is $Webmaster...\n" if $Debug;
	print "Webmaster e-mail address is $WebmasterEmailAddress...\n" if $Debug;
a438 24
	open INPUT, "<$InputFile" or
		die "Couldn't open $InputFile for input: $!";
	open OUTPUT, ">$OutputFile" or
		die "coulnd't open $OutputFile for output: $!";
	while ( $Line = <INPUT> ) {
		chomp($Line);
		if ( $Line =~ /^# CUSTOMIZE$/ ) {
			# secrete Perl code
			print OUTPUT "# CUSTOMIZED!\n";
			print OUTPUT "\$SyssummDirectory = \"$HtdocDirectory/$SyssummDirectory\";\n";
			print OUTPUT "\$FormatName = \"../$FormatFileName\";\n";
			print OUTPUT "\$ProfileName = \"$ProfileFileName\";\n";
			print OUTPUT "\$Sysquery = \"$CGIScriptName\";\n";
			print OUTPUT "\$AdminEmailAddress = \"$AdminEmailAddress\";\n";
			print OUTPUT "\$Webmaster = \"$Webmaster\";\n";
			print OUTPUT "\$WebmasterEmailAddress = \"$WebmasterEmailAddress\";\n";
			print OUTPUT "\$WebServerUrl = \"$WebServerUrl/$CGIDirectory/$Sysquery\";\n";
			next;
		}
		print OUTPUT "$Line\n";
	}
	close(OUTPUT);
	close(INPUT);

d453 1
a453 1
CheckConfigFile();
@


1.5
log
@changes from Frank Crawford and Bruce Mohler including:
Frank: Addition of command line option to specify SysSumm user.
Frank: Various bug fixes.
Bruce: Check each config file entry to make sure that it's in
Bruce: the correct order.
Bruce: Fix hard-coded source for processing entries into and
Bruce: out of the configuration file.  Driven by 1 array and
Bruce: 2 hashes.
@
text
@a6 1
#	install.pl [ -d ] [ -f ] [ -h ]
d66 1
a66 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.4 1999/06/18 17:10:36 mohlerb Exp mohlerb $
d68 1
a68 1
# $Revision: 1.4 $
d71 10
d147 1
d157 1
d170 1
d281 14
a341 14
sub CheckConfigFile
{
	my $PathToConfigFile = "$HomeDirectory/$ConfigurationFileName";

	# does the configuration file exist?
	if ( ! -f $PathToConfigFile ) {
		CreateConfigurationFile($PathToConfigFile);
	}
	LoadConfigurationFile($PathToConfigFile);

	return;
}


d664 1
a665 1
CheckConfigFile();
@


1.4
log
@changes from Bruce Mohler including:
changes to support additional CUSTOMIZE field based on Paul's
prior patch - these changes are not tested yet!!!
@
text
@d8 1
d67 1
a67 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.3 1999/06/16 16:04:21 mohlerb Exp mohlerb $
d69 1
a69 1
# $Revision: 1.3 $
d72 5
d101 1
a103 1
$SyssummUserid = "syssumm";
a117 6
$CGIDirectory = "";
$HtdocDirectory = "";
$AdminEmailAddress = "";
$Webmaster = "";
$WebmasterEmailAddress = "";
$WebServerUrl = "";
d131 5
d137 31
d176 1
a176 1
	if ( getopts('dfh') ) {
d180 1
d430 1
a430 1
	print "synopsis: install.pl [ -d ] [ -f ] [ -h ]\n";
d434 1
d446 1
a446 2
	my $Done = 0;
	while ( ! $Done ) {
d448 2
a449 4
		$Done = ( -d $DirectoryPath );
		if ( ! $Done ) {
			print STDERR "That directory doesn't exist...\n";
		}
d456 28
d497 6
d523 15
a537 7
	# all of the next variables are *LOCAL*
	my $CGIDirectory = PromptForDirectoryPath("Enter path to your CGI directory");
	my $HtdocDirectory = PromptForDirectoryPath("Enter path to your web server document root directory");
	my $AdminEmailAddress = PromptFor("Enter e-mail address for your local System Administrator (with escaped '\@@')");
	my $Webmaster = PromptFor("Enter \"name\" for webmaster on bottom of web page");
	my $WebmasterEmailAddress = PromptFor("Enter e-mail address for Webmaster (with escaped '\@@')");
	my $WebServerURL = PromptFor("Enter the URL for the web server");
d542 3
a544 6
	print CONFIG "CGIDirectory=$CGIDirectory\n";
	print CONFIG "HtdocDirectory=$HtdocDirectory\n";
	print CONFIG "AdminEmailAddress=$AdminEmailAddress\n";
	print CONFIG "Webmaster=$Webmaster\n";
	print CONFIG "WebmasterEmailAddress=$WebmasterEmailAddress\n";
	print CONFIG "WebServerUrl=$WebServerUrl\n";
d551 6
d563 1
d567 14
a580 37

	# the CGI directory
	my $Line = <CONFIG>;
	chomp($Line);
	$Line =~ /CGIDirectory=(.*$)/;
	$CGIDirectory = $1;			# Global

	# the HTML document root
	my $Line = <CONFIG>;
	chomp($Line);
	$Line =~ /HtdocDirectory=(.*$)/;
	$HtdocDirectory = $1;			# Global

	# the system administrator e-mail address
	my $Line = <CONFIG>;
	chomp($Line);
	$Line =~ /AdminEmailAddress=(.*$)/;
	$AdminEmailAddress = $1;		# Global

	# the Webmaster "name"
	my $Line = <CONFIG>;
	chomp($Line);
	$Line =~ /Webmaster=(.*$)/;
	$Webmaster = $1;			# Global

	# the Webmaster e-mail address
	my $Line = <CONFIG>;
	chomp($Line);
	$Line =~ /WebmasterEmailAddress=(.*$)/;
	$WebmasterEmailAddress = $1;		# Global

	# the URL of the web server
	my $Line = <CONFIG>;
	chomp($Line);
	$Line =~ /WebServerUrl=(.*$)/;
	$WebServerUrl = $1;			# Global

d583 5
a587 5
	print "CGI directory is $CGIDirectory...\n" if $Debug;
	print "httpd document root is $HtdocDirectory...\n" if $Debug;
	print "Admin e-mail address is $AdminEmailAddress...\n" if $Debug;
	print "Webmaster name is $Webmaster...\n" if $Debug;
	print "Webmaster e-mail address is $WebmasterEmailAddress...\n" if $Debug;
@


1.3
log
@changes from Martin Andrews including:
fixes for routines prompting for information
@
text
@d66 1
a66 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.2 1999/06/05 00:25:00 mohlerb Exp mohlerb $
d68 1
a68 1
# $Revision: 1.2 $
d71 4
d117 1
d123 7
d131 1
d383 1
a383 1
		print "any hand merge any desired changes.\n\n";
d460 1
d470 1
d517 6
d572 1
@


1.2
log
@changes from Bruce Mohler including:
the CUSTOMIZE fields are inserted during the installation
process by using the install.pl script
@
text
@d62 1
a62 1
# 	Copyright (c) 1999 <author>
d66 1
a66 1
# $Header: /export/home/mohlerb/src/perl/syssumm/web.server/RCS/install.pl,v 1.1 1999/06/04 22:56:18 mohlerb Exp mohlerb $
d68 1
a68 1
# $Revision: 1.1 $
d71 5
d397 1
a397 3
		print STDOUT "$Prompt: ";
		$DirectoryPath = <STDIN>;
		chomp($DirectoryPath);
d408 12
d444 3
a446 3
	my $AdminEmailAddress = PromptForDirectoryPath("Enter e-mail address for your local System Administrator (with escaped '\@@')");
	my $Webmaster = PromptForDirectoryPath("Enter \"name\" for webmaster on bottom of web page");
	my $WebmasterEmailAddress = PromptForDirectoryPath("Enter e-mail address for Webmaster (with escaped '\@@')");
@


1.1
log
@Initial revision
@
text
@d36 11
d66 1
a66 1
# $Header$
d68 1
a68 1
# $Revision$
d70 4
a73 1
# $Log$
d105 3
d111 1
d118 2
d261 14
d286 1
a286 3
	my @@args = ( "mv", "-f", $IncomingScriptName, $HomeDirectory );
	system(@@args) == 0 or
		die "system call @@args failed: $!";
a325 8
	# does the configuration file exist?
	if ( ! -f $PathToConfigFile ) {
		CreateConfigurationFile($PathToConfigFile);
	}
	LoadConfigurationFile($PathToConfigFile);
	print "CGI directory is $CGIDirectory\n" if $Debug;
	print "htdoc directory is $HtdocDirectory\n" if $Debug;

d327 1
a327 3
	my @@args = ( "mv", "-f", $CGIScriptName, $CGIDirectory );
	system(@@args) == 0 or
		die "system call @@args failed: $!";
d372 51
d426 1
a426 1
	# both of the next 2 variables are *LOCAL*
d429 3
d438 3
d456 2
d462 2
d468 19
d489 8
d501 3
a503 3
sub PromptForDirectoryPath
{	my $Prompt = shift;
	my $DirectoryPath = "";
d505 3
a507 10
	my $Done = 0;
	while ( ! $Done ) {
		print STDOUT "$Prompt: ";
		$DirectoryPath = <STDIN>;
		chomp($DirectoryPath);
		$Done = ( -d $DirectoryPath );
		if ( ! $Done ) {
			print STDERR "That directory doesn't exist...\n";
		}
	}
d509 2
a510 2
	return $DirectoryPath;
}
d512 1
d514 5
a518 7
sub DisplayHelp
{
	print "System Summaries web server install script\n";
	print "synopsis: install.pl [ -d ] [ -f ] [ -h ]\n";
	print "\t-d\tTurn on debugging output\n";
	print "\t-f\tForce the script to run even though you're not root\n";
	print "\t-h\tPrints what you're reading now\n";
d520 23
d558 1
@
