[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Installation procedure...



Hi Everyone!

I am trying to get started with LSMB and decided to go with the 1.3 branch from svn as I think it will be easier for migrations in the long run. I tried the install procedure and it mostly worked. 

After quite a bit of caveman debugging, I have patched the Initiate.pm script to allow for a more complete setup which will allow one to go from download to login with a lot less effort.

The additions are mainly related to the beta 3 install documentation which mention granting roles, etc.

I'm not sure what the gifidir is for, so it's commented out in my patch.

Cheers,
Jason.

Index: LedgerSMB/Initiate.pm
===================================================================
--- LedgerSMB/Initiate.pm	(revision 2912)
+++ LedgerSMB/Initiate.pm	(working copy)
@@ -257,7 +257,8 @@
		
		#Stage 2 -  CReate the language plpgsql
	
-	$form->{newdbh}=LedgerSMB::Initiate->handle_create_language($form);
+	#$form->{newdbh}=LedgerSMB::Initiate->handle_create_language($form);
+	#LedgerSMB::Initiate->handle_create_language($form);
		
		#stage 3 -  Execute series of files which are located in array @totalexecutable_files in the database $form->{newdbh}

@@ -274,10 +275,10 @@
sub process_roles {
    $logger->debug("Begin LedgerSMB::Initiate::process_roles");
	my ($form) = @_;
-	print STDERR "loading roles............\n";
+	print STDERR "loading roles for " . $form->{database} . "............\n";
	LedgerSMB::Initiate->getdbh($form);
-	open (PSQL, '|-', 'psql') || $form->error($locale->text("Couldn't open psql"));
-	my $company = $form->{company};
+	open (PSQL, '|-', 'psql ' . $form->{database}) || $form->error($locale->text("Couldn't open psql"));
+	my $company = $form->{database};
    $logger->debug("LedgerSMB::Initiate::process_roles: company = $company");

	open (ROLEFILE, '<', 'sql/modules/Roles.sql') || $form->error($locale->text("Couldn't open Roles.sql"));
@@ -290,19 +291,33 @@
	my $query;
	if ($form->{createuser}){
		$query = qq| create user | . 
-			$form->{newdbh}->quote_identifier($form->{admin_username}) .
+			$form->{dbh}->quote_identifier($form->{admin_username}) .
			qq| WITH PASSWORD | .
-			$form->{newdbh}->quote($form->{admin_password}) .
+			$form->{dbh}->quote($form->{admin_password}) .
			qq| IN ROLE | .
-			$form->{newdbh}->quote_identifier("lsmb_${company}__users_manage");
+			$form->{dbh}->quote_identifier("lsmb_${company}__users_manage");
	} else {
		$query = "GRANT " .
-			$form->{newdbh}->quote_identifier("lsmb_${company}__users_manage")  . 
+			$form->{dbh}->quote_identifier("lsmb_${company}__users_manage")  . 
			" TO " .
-			$form->{newdbh}->quote_identifier($form->{admin_username});
+			$form->{dbh}->quote_identifier($form->{admin_username});
	}
-	print PSQL "$query";
+	print PSQL "$query;";

+	print PSQL "INSERT INTO entity (name, entity_class, created, country_id) VALUES ('" .$form->{admin_username}. "', 3, NOW(), '232');";
+	print PSQL "INSERT INTO person (entity_id, first_name, last_name, created) VALUES (1, 'Admin', 'User', NOW());";
+	print PSQL "INSERT INTO entity_employee (manager_id, entity_id, startdate, role) VALUES (1, 1, NOW(), '" .$form->{admin_username}. "');";
+	print PSQL "INSERT INTO users (username, entity_id) VALUES ('" .$form->{admin_username}. "', 1);";
+	print PSQL "INSERT INTO user_preference (id) VALUES (1);";
+
+	my @roles = `psql -t -c "SELECT rolname FROM pg_roles WHERE rolname LIKE 'lsmb_${company}%';"`;
+	foreach (@roles) {
+		chomp;
+		next if $_ =~ /^$/;
+		print PSQL "grant $_ to " .$form->{dbh}->quote_identifier($form->{admin_username}). ";";
+	}
+
+
    $logger->debug("End LedgerSMB::Initiate::process_roles");
}

@@ -474,7 +489,7 @@
	
	open(ORD, '<', $dir . "LOADORDER");
	while (my $line = <ORD>){
-		$line =~ s/\#.*$//; # ignore comments
+		next if $line =~ /^\s*#/; # ignore comments
		next if $line =~ /^\s*$/;
		$line =~ s/^\s*//;
		$line =~ s/\s*$//;
@@ -505,26 +520,20 @@

	$dir =~s/\/[\w\d\.]*$/$location/;

+        my @dest;	
+	
	my $chartdir=$dir."chart/";
-	
-	my $gifidir=$dir."gifi/";
	@chartdir = LedgerSMB::Initiate->read_directory($form, $chartdir);
-
-        my @dest;	
-
-        my $i;
-	for($i=0;$i<=$#chartdir;$i++)
-	{
-		$dest[$i]=$chartdir.$chartdir[$i] if $chartdir[$i] = $coa;
+	foreach (@chartdir) {
+		push(@dest, $chartdir.$_) if $_ eq $coa;
	}
-	for(my $j=0;$j<=$#gifidir;$j++,$i++)
-	{
	  
-		$dest[$i]=$chartdir.$gifidir[$i] if $gifidir[$i] = $coa;
+#	my $gifidir=$dir."gifi/";
+#	@gifidir = LedgerSMB::Initiate->read_directory($form, $gifidir);
+#	foreach (@gifidir) {
+#		push(@dest, $gifidir.$_) if $_ eq $coa;
+#	}
	
-	}
-
-	
	return(@dest);


Index: sql/Pg-database.sql
===================================================================
--- sql/Pg-database.sql	(revision 2912)
+++ sql/Pg-database.sql	(working copy)
@@ -1,3 +1,5 @@
+CREATE LANGUAGE plpgsql;
+
begin;
CREATE SEQUENCE id;
-- As of 1.3 there is no central db anymore. --CT