[Affelio-cvs 597] CVS update: affelio/lib/Affelio/misc

Back to archive index

Tadashi Okoshi slash****@users*****
2005年 10月 24日 (月) 21:50:34 JST


Index: affelio/lib/Affelio/misc/InitAffelio.pm
diff -u affelio/lib/Affelio/misc/InitAffelio.pm:1.1 affelio/lib/Affelio/misc/InitAffelio.pm:1.2
--- affelio/lib/Affelio/misc/InitAffelio.pm:1.1	Mon Oct 24 20:37:26 2005
+++ affelio/lib/Affelio/misc/InitAffelio.pm	Mon Oct 24 21:50:34 2005
@@ -1,3 +1,5 @@
+#!/usr/bin/perl
+
 # Copyright (C) 2005 FishGrove Inc.
 #
 # This program is free software; you can redistribute it and/or
@@ -14,22 +16,25 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #
-# $Id: InitAffelio.pm,v 1.1 2005/10/24 11:37:26 slash5234 Exp $
+# $Id: InitAffelio.pm,v 1.2 2005/10/24 12:50:34 slash5234 Exp $
 
 package Affelio::misc::InitAffelio;
 {
     use strict;
     use Exporter;
     @Affelio::misc::InitAffelio::ISA = "Exporter";
-    @Affelio::misc::InitAffelio::EXPORT = qw (create_userdir get_userdir create_af_cfg create_db_cfg create_login_cfg copy_def_files init_db set_datadir_perm);
+    @Affelio::misc::InitAffelio::EXPORT = qw (create_userdir get_userdir create_af_cfg create_db_cfg create_login_cfg copy_def_files init_db set_datadir_perm setup_affelio);
 
     use lib("../../../extlib/");
+    use Cwd;
+    use DBI;
     use Error qw(:try);
     use lib(".");
     use lib("../../../lib/");
     use Affelio;
     use Affelio::misc::CGIError;
     use Affelio::misc::Debug;
+    use Affelio::App::Admin::EditTemplates;
     use Affelio::exception::Exception;
     use Affelio::exception::DBException;
     use Affelio::exception::IOException;
@@ -410,5 +415,67 @@
     }
 
 
+    #####################################################################
+    sub setup_affelio{
+	my $root_dir = shift;
+	my $root_url = shift;
+	my $locale = shift;
+	my $lh = shift;
+	my $template = shift;
+	my $sendmail_path = shift;
+	#
+	my $db_type = shift;
+	my $db_dbname = shift;
+	my $db_username = shift;
+	my $db_password = shift;
+	my $db_hostname = shift;
+	my $db_port = shift;
+	#
+	my $username = shift;
+	my $password = shift;
+	my $nickname =shift;
+	my $email =shift;
+
+	create_userdir($root_dir);
+
+	create_af_cfg("$root_dir/config/affelio.cfg",
+		      $root_dir,
+		      $root_url,
+		      $locale,
+		      $template,
+		      $sendmail_path);
+
+	chmod 0700, "$root_dir/config";
+
+	my $user_dir = "";
+	$user_dir = get_userdir("$root_dir /userdata");
+
+	create_db_cfg("$user_dir/db.cfg",
+		      $db_type,
+		      $db_dbname,
+		      $db_username,
+		      $db_password,
+		      $db_hostname,
+		      $db_port);
+
+
+	my @salts = ( "A".."Z", "a".."z", "0".."9", ".", "/" );
+	my $salt = $salts[int(rand(64))] . $salts[int(rand(64))];
+	my $crypted_password = crypt($password, $salt);
+	create_login_cfg("$user_dir/login.cfg",
+			 $username,
+			 $crypted_password);
+
+	copy_def_files($root_dir , $user_dir, $locale);
+
+	init_db($root_dir , $nickname, $email, $lh);
+
+	my $af;
+	$af = new Affelio(ConfigDir => "$root_dir /config/");
+	Affelio::App::Admin::EditTemplates::rebuild($af);
+
+	set_datadir_perm($root_dir );
+    }
+
 }
 1;


Affelio-cvs メーリングリストの案内
Back to archive index