new.spirit

 view release on metacpan or  search on metacpan

install.pl  view on Meta::CPAN


sub thanks {
	print <<__EOF;

new.spirit was successfully installed. Please ensure
that your webserver is configured with the mappings
you entered. If you use the Apache webserver, you can
simply add these parameters to your httpd.conf file:

  Alias       $CFG::htdocs_url $CFG::root_dir/htdocs
  ScriptAlias $CFG::cgi_url $CFG::root_dir/cgi-bin

Point your browser to this URL for further documentation:

  http://localhost$CFG::htdocs_url/doc/

And don't forget to have fun with new.spirit... ;)


Information for spirit 1.x upgraders:
-------------------------------------

If you are uprading from a spirit 1.x installation, you
can use bin/convert_from_spirit1x.pl to import your
user account and project informationen into your new
new.spirit 2.x system. Your spirit 1.x files are not
touched through this procedure.

ATTENTION:  But if you access spirit 1.x objects with
----------  new.spirit 2.x they will be converted on
	    the fly. They are not accessible through
	    spirit 1.x anymore after this conversion!

__EOF
}

sub create_passwd {
	my %par = @_;
	
	my $force = $par{force};
	
	if ( $force or not -f $CFG::passwd_file ) {
		message ("creating new $CFG::passwd_file");
		unlink $CFG::passwd_file;
		require "NewSpirit/Passwd.pm";
		NewSpirit::LKDB->set_db_module($CFG::db_module);
	        my $p = new NewSpirit::Passwd;
	        $p->add ('spirit', 'spirit', {PROJECT=>1,USER=>1},{});
		message_ok();
	} else {
		message ("file $CFG::passwd_file exists (-p forces recreation)");
		message_ok();
	}
}

sub set_file_modes {
	my %par = @_;
	
	message("setting file modes");
	
	my $files = require "etc/filemodes.conf";
	$files->{"./etc/passwd"} = 33204;

	foreach my $file ( sort keys %{$files} ) {
		$VERBOSE && print "$file: $files->{$file}\n";
		chmod $files->{$file}, $file;
	}
	
	!$VERBOSE && message_ok();
}

sub set_shebang {
	my %par = @_;
	
	message ("setting shebang line");
	
	my @files;
	find (
		sub {
			return if not -f $_;
			return if not /\.(pl|cgi)$/;
			push @files, "$File::Find::dir/$_";
		},
		"."
	);
	
	my $shebang = "#!$Config{perlpath}";
	
	foreach my $file ( @files ) {
		print "$file...\n";
		open (SCRIPT, $file)
			or die "can't read $file";
		my $text = join '', <SCRIPT>;
		close SCRIPT;
		
		$text =~ s/^#\!.*/$shebang/;
		
		open (SCRIPT, "> $file")
			or die "can't write $file";
		print SCRIPT $text;
		close SCRIPT;
	}
	
	message_ok();

	1;
}

sub check_modules {
	my $modules = require "etc/perl-modules.conf";
	
	message("checking for Perl modules");
	$VERBOSE && print "\n";
	
	my @missing;
	
	foreach my $module ( sort keys %{$modules} ) {
		$VERBOSE && print "\t$module... ";
		eval "use $module";
		if ( $@ ) {
			push @missing, $module;
			$VERBOSE && message_not_ok();
		} else {
			$VERBOSE && message_ok();
		}
	}
	
	if ( not $VERBOSE ) {
		@missing ? message_not_ok() : message_ok();
	}
	
	if ( @missing ) {
		print "\n";
		print "Please install the following modules and\n";
		print "execute 'perl install.pl' again.\n\n";
		print "  ", join (" ", @missing);
		print "\n\n";
		exit 1;
	}
	
	# warn if installed CIPP version is older than shipped version
	my @files = sort @{NewSpirit::filename_glob (
		dir => "$CFG::perlmodules_dir",
		regex => "CIPP.*"
	)};
	
	my $last = @files[@files-1];
	$last =~ /CIPP-(\d+\.\d+(_\d+)?)/;
	my $last_version = $1;
	
	if ( $last_version > $CIPP::VERSION ) {
		print "\n";
		my $answer = ask (
			text => "Warning! Installed CIPP version $CIPP::VERSION is older than\n".
			        "shipped version $last_version. You should install the package\n\n".
				"$last first.\n\n".
				"Type 'ignore' to ignore this warning an proceed",
			default => 'exit',
		);
		
		exit 1 if $answer ne 'ignore';
	}
}

sub check_manifest {
	open (MAN, "MANIFEST") or die "can't read MANIFEST";
	
	message ("checking whether distribution is complete");
	
	my @missing;



( run in 1.621 second using v1.01-cache-2.11-cpan-df04353d9ac )