[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-202-gdfe8018
? sunnavy
sunnavy at bestpractical.com
Tue Aug 3 20:45:04 EDT 2010
The branch, 3.9-trunk has been updated
via dfe8018c8af543ab3b4399195810c7f2eaacbd0e (commit)
from 8c0ecb43ec7039676b20fa8fe060de7b96773e61 (commit)
Summary of changes:
lib/RT/Handle.pm | 4 ++++
sbin/rt-setup-database.in | 27 +++++++++++++++++++++++----
2 files changed, 27 insertions(+), 4 deletions(-)
- Log -----------------------------------------------------------------
commit dfe8018c8af543ab3b4399195810c7f2eaacbd0e
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Aug 4 08:42:05 2010 +0800
add --root-password-file for rt-setup-database
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index da7a672..08dfffc 100755
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -725,6 +725,7 @@ Load some sort of data into the database, takes path to a file.
sub InsertData {
my $self = shift;
my $datafile = shift;
+ my $root_password = shift;
# Slurp in stuff to insert from the datafile. Possible things to go in here:-
our (@Groups, @Users, @ACL, @Queues, @ScripActions, @ScripConditions,
@@ -794,6 +795,9 @@ sub InsertData {
if ( @Users ) {
$RT::Logger->debug("Creating users...");
foreach my $item (@Users) {
+ if ( $item->{'Name'} eq 'root' && $root_password ) {
+ $item->{'Password'} = $root_password;
+ }
my $new_entry = new RT::User( $RT::SystemUser );
my ( $return, $msg ) = $new_entry->Create(%$item);
unless ( $return ) {
diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index 2afab67..adb7bc7 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -96,7 +96,7 @@ GetOptions(
'action=s',
'force', 'debug',
'dba=s', 'dba-password=s', 'prompt-for-dba-password',
- 'datafile=s', 'datadir=s', 'skip-create'
+ 'datafile=s', 'datadir=s', 'skip-create', 'root-password-file=s'
);
unless ( $args{'action'} ) {
@@ -104,6 +104,23 @@ unless ( $args{'action'} ) {
exit(-1);
}
+# get customized root password
+my $root_password;
+if ( $args{'root-password-file'} ) {
+ open my $fh, '<', $args{'root-password-file'}
+ or die "Couldn't open 'args{'root-password-file'}' for reading: $!";
+ $root_password = <$fh>;
+ chomp $root_password;
+ my $min_length = RT->Config->Get('MinimumPasswordLength');
+ if ($min_length) {
+ die
+"password needs to be at least $min_length long, please check file '$args{'root-password-file'}'"
+ if length $root_password < $min_length;
+ }
+ close $fh;
+}
+
+
# check and setup @actions
my @actions = grep $_, split /,/, $args{'action'};
if ( @actions > 1 && $args{'datafile'} ) {
@@ -250,7 +267,8 @@ sub action_insert {
my $file = $args{'datafile'};
$file = $RT::EtcPath . "/initialdata" if $init && !$file;
$file ||= $args{'datadir'}."/content";
- return $RT::Handle->InsertData( $file );
+
+ return $RT::Handle->InsertData( $file, $root_password );
}
sub action_upgrade {
@@ -477,8 +495,9 @@ Several actions can be combined using comma separated list.
--skip-create for 'init': skip creating the database and the
user account, so we don't need administrator
privileges
-
-
+--root-password-file for 'init' and 'insert': rather than using the
+ default password, take the initial root password
+ from this file
EOF
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list