Lines 25-37
use DBIx::Class::Schema::Loader qw/ make_schema_at /;
Link Here
|
25 |
use Getopt::Long; |
25 |
use Getopt::Long; |
26 |
use Pod::Usage; |
26 |
use Pod::Usage; |
27 |
|
27 |
|
|
|
28 |
my %db_defaults = ( |
29 |
driver => 'mysql', |
30 |
host => 'localhost', |
31 |
port => '3306', |
32 |
); |
33 |
|
28 |
my $path = "./"; |
34 |
my $path = "./"; |
29 |
my $db_driver = 'mysql'; |
35 |
my $db_driver; |
30 |
my $db_host = 'localhost'; |
36 |
my $db_host; |
31 |
my $db_port = '3306'; |
37 |
my $db_port; |
32 |
my $db_name; |
38 |
my $db_name; |
33 |
my $db_user; |
39 |
my $db_user; |
34 |
my $db_passwd; |
40 |
my $db_passwd; |
|
|
41 |
my $koha_conf; |
35 |
my $help; |
42 |
my $help; |
36 |
|
43 |
|
37 |
GetOptions( |
44 |
GetOptions( |
Lines 42-53
GetOptions(
Link Here
|
42 |
"db_name=s" => \$db_name, |
49 |
"db_name=s" => \$db_name, |
43 |
"db_user=s" => \$db_user, |
50 |
"db_user=s" => \$db_user, |
44 |
"db_passwd=s" => \$db_passwd, |
51 |
"db_passwd=s" => \$db_passwd, |
|
|
52 |
"koha-conf:s" => \$koha_conf, |
45 |
"h|help" => \$help |
53 |
"h|help" => \$help |
46 |
); |
54 |
); |
47 |
|
55 |
|
48 |
# If we were asked for usage instructions, do it |
56 |
# If we were asked for usage instructions, do it |
49 |
pod2usage(1) if defined $help; |
57 |
pod2usage(1) if defined $help; |
50 |
|
58 |
|
|
|
59 |
if (defined $koha_conf) { |
60 |
if ($koha_conf eq '' and not defined $ENV{KOHA_CONF}) { |
61 |
print STDERR "Error: KOHA_CONF is not defined\n"; |
62 |
exit(1); |
63 |
} |
64 |
|
65 |
$koha_conf ||= $ENV{KOHA_CONF}; |
66 |
unless (-r $koha_conf) { |
67 |
print STDERR "Error: File $koha_conf does not exist or is not readable\n"; |
68 |
exit(1); |
69 |
} |
70 |
|
71 |
require C4::Context; |
72 |
my $context = C4::Context->new($koha_conf); |
73 |
unless ($context) { |
74 |
print STDERR "Error: Koha context creation failed. Please check that $koha_conf is correct\n"; |
75 |
exit(1); |
76 |
} |
77 |
|
78 |
$context->set_context; |
79 |
$db_defaults{driver} = $context->config('db_scheme'); |
80 |
$db_defaults{host} = $context->config('hostname'); |
81 |
$db_defaults{port} = $context->config('port'); |
82 |
$db_defaults{name} = $context->config('database'); |
83 |
$db_defaults{user} = $context->config('user'); |
84 |
$db_defaults{passwd} = $context->config('pass'); |
85 |
} |
86 |
|
87 |
$db_driver //= $db_defaults{driver}; |
88 |
$db_host //= $db_defaults{host}; |
89 |
$db_port //= $db_defaults{port}; |
90 |
$db_name //= $db_defaults{name}; |
91 |
$db_user //= $db_defaults{user}; |
92 |
$db_passwd //= $db_defaults{passwd}; |
93 |
|
51 |
if (! defined $db_name ) { |
94 |
if (! defined $db_name ) { |
52 |
print "Error: \'db_name\' parameter is mandatory.\n"; |
95 |
print "Error: \'db_name\' parameter is mandatory.\n"; |
53 |
pod2usage(1); |
96 |
pod2usage(1); |
Lines 68-75
misc/devel/update_dbix_class_files.pl
Link Here
|
68 |
|
111 |
|
69 |
=head1 SYNOPSIS |
112 |
=head1 SYNOPSIS |
70 |
|
113 |
|
71 |
update_dbix_class_files.pl --db_name=db-name --db_user=db-user \ |
114 |
update_dbix_class_files.pl [--koha-conf <path>] --db_name=db-name \ |
72 |
--db_passwd=db-pass ... |
115 |
--db_user=db-user --db_passwd=db-pass ... |
73 |
|
116 |
|
74 |
The command in usually called from the root directory for the Koha source tree. |
117 |
The command in usually called from the root directory for the Koha source tree. |
75 |
If you are running from another directory, use the --path switch to specify |
118 |
If you are running from another directory, use the --path switch to specify |
Lines 79-84
a different path.
Link Here
|
79 |
|
122 |
|
80 |
=over 8 |
123 |
=over 8 |
81 |
|
124 |
|
|
|
125 |
=item B<--koha-conf> <path> |
126 |
|
127 |
Path to koha-conf.xml from which DB connection params will be retrieved. |
128 |
|
129 |
<path> is optional and defaults to the value of environment variable KOHA_CONF, |
130 |
if set. It is an error to omit the <path> if KOHA_CONF is not set. |
131 |
|
132 |
Any B<--db_*> options will override values retrieved from <path>. |
133 |
|
82 |
=item B<--db_name> |
134 |
=item B<--db_name> |
83 |
|
135 |
|
84 |
DB name. (mandatory) |
136 |
DB name. (mandatory) |
Lines 111-114
path into which create the schema files. (defaults to './')
Link Here
|
111 |
|
163 |
|
112 |
prints this help text |
164 |
prints this help text |
113 |
|
165 |
|
114 |
=back |
166 |
=back |
115 |
- |
|
|