Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 197 lines (162 sloc) 6.156 kB
e449c13 @mjray Add configuration file helper to the installer
mjray authored
1 # Copyright 2007 MJ Ray
2 #
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
9 #
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 #
214deb7 Fix FSF address in directory .
Lars Wirzenius authored
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
e449c13 @mjray Add configuration file helper to the installer
mjray authored
17 #
18 # Current maintainer MJR http://mjr.towers.org.uk/
98782b8 Correct comments and POD to reflect keyword additions/changes
Chris Nighswonger authored
19 #
20 # 2007/11/12 Added DB_PORT and changed other keywords to reflect multi-dbms support. -fbcit
e449c13 @mjray Add configuration file helper to the installer
mjray authored
21
22 use Sys::Hostname;
23 use Socket;
24
25 =head1 NAME
26
27 rewrite-config.PL - helper for the Koha packager and installer
28
29 =head1 SYNOPSIS
30
31 perl rewrite-config.PL configurationfile
32
33 =head1 DESCRIPTION
34
61190e9 @mjray New installation instructions and release notes.
mjray authored
35 This helper script replaces keywords in the
e449c13 @mjray Add configuration file helper to the installer
mjray authored
36 configuration files with value either supplied through
37 the environment (with export, or by putting them on
61190e9 @mjray New installation instructions and release notes.
mjray authored
38 the start of the make command line) or with reasonable
e449c13 @mjray Add configuration file helper to the installer
mjray authored
39 guesses worked out by the script.
40
61190e9 @mjray New installation instructions and release notes.
mjray authored
41 =head2 KEYWORDS
e449c13 @mjray Add configuration file helper to the installer
mjray authored
42
61190e9 @mjray New installation instructions and release notes.
mjray authored
43 The following configuration keywords are available:
e449c13 @mjray Add configuration file helper to the installer
mjray authored
44
243ec54 @mjray Move many files to more FHS-like paths
mjray authored
45 PREFIX,
d1f9665 Now using install_base instead of prefix
Chris Cormack authored
46 BASE_DIR, CGI_DIR, LOG_DIR, INSTALL_BASE,
98782b8 Correct comments and POD to reflect keyword additions/changes
Chris Nighswonger authored
47 DB_TYPE, DB_HOST, DB_PORT, DB_NAME, DB_PASS, DB_USER, WEBMASTER_EMAIL, WEBSERVER_DOMAIN,
28695e9 @mjray Add missing auto_install features to new installer
mjray authored
48 WEBSERVER_HOST, WEBSERVER_IP, WEBSERVER_PORT, WEBSERVER_PORT_LIBRARIAN, ZEBRA_PASS, ZEBRA_USER
e449c13 @mjray Add configuration file helper to the installer
mjray authored
49
61190e9 @mjray New installation instructions and release notes.
mjray authored
50 =head1 EXAMPLES
51
52 To override the guessed hostname and email address, run:
53
54 WEBSERVER_HOST=mysecrethostname.com.invalid \
55 WEBMASTER_EMAIL=webmaster@publichost.com make install
56
57 Note that if WEBSERVER_HOST does not resolve to an IP address, you will
58 also need to override WEBSERVER_IP.
59
e449c13 @mjray Add configuration file helper to the installer
mjray authored
60 =cut
61
9902f24 don't try to resolve if WEBSERVER_IP is set and now use WEBSERVER_HOST.
Marc Chantreux authored
62 if ( $myhost = $ENV{WEBSERVER_HOST} || hostname ) {
63 ( $mydomain = $myhost ) =~ s/.*?\.//;
64 } else {
65 $myhost = 'localhost';
66 $mydomain = 'localdomain';
4712745 fix for bug 2528: installation fails with confusing error message
Jesse Weaver authored
67 }
68
9902f24 don't try to resolve if WEBSERVER_IP is set and now use WEBSERVER_HOST.
Marc Chantreux authored
69 unless ( $myip = $ENV{WEBSERVER_IP} ) {
70 my $byname = gethostbyname( $myhost )
71 or die "Could not get the IP address of $myhost, DNS fault? ($!)";
72 $myip = inet_ntoa $byname
73 or die "can't inet_ntoa ($!)";
74 }
75
76
d1f9665 Now using install_base instead of prefix
Chris Cormack authored
77 $prefix = $ENV{'INSTALL_BASE'} || "/usr";
e449c13 @mjray Add configuration file helper to the installer
mjray authored
78
79 # These are our configuration guesses
80 # Keys were extracted by
81 # <grep -o '__.*__' etc/* | cut -f2 -d: | sort -u | sed -e 's/^/ "/;s/$/" => "",/'
82 %configuration = (
82daf0a installer: added install log
Galen Charlton authored
83 "__KOHA_INSTALLED_VERSION__" => "no_version_found",
243ec54 @mjray Move many files to more FHS-like paths
mjray authored
84 "__LOG_DIR__" => "/var/log",
bc4699c Changes to add dbms type and port & rename db vars for multi-dbms
Chris Nighswonger authored
85 "__DB_TYPE__" => "mysql",
86 "__DB_NAME__" => "koha",
87 "__DB_HOST__" => $myhost,
88 "__DB_PORT__" => "3306",
89 "__DB_USER__" => "kohaadmin",
90 "__DB_PASS__" => "katikoan",
28695e9 @mjray Add missing auto_install features to new installer
mjray authored
91 "__WEBMASTER_EMAIL__" => 'webmaster@'.$mydomain,
e449c13 @mjray Add configuration file helper to the installer
mjray authored
92 "__WEBSERVER_DOMAIN__" => $mydomain,
93 "__WEBSERVER_HOST__" => $myhost,
cecd7ef @mjray BUGFIX: set all configuration keys - die terminated the hash
mjray authored
94 "__WEBSERVER_IP__" => $myip,
95 "__WEBSERVER_PORT__" => "80",
96 "__WEBSERVER_PORT_LIBRARIAN__" => "8080",
bbd043f adding three new variables for installation:
Joshua Ferraro authored
97 "__ZEBRA_SRU_HOST__" => $myhost,
98 "__ZEBRA_SRU_BIBLIOS_PORT__" => "9998",
99 "__ZEBRA_SRU_AUTHORITIES_PORT__" => "9999",
e6ee69b various installer changes
Galen Charlton authored
100 "__KOHA_USER__" => "koha",
101 "__KOHA_GROUP__" => "koha",
e449c13 @mjray Add configuration file helper to the installer
mjray authored
102 "__ZEBRA_PASS__" => "zebrastripes",
103 "__ZEBRA_USER__" => "kohauser",
5befdd2 installer (part 2): more work
Galen Charlton authored
104 '__INTRANET_CGI_DIR__' => "$prefix/intranet/cgi-bin",
105 '__INTRANET_TMPL_DIR__' => "$prefix/intranet/templates",
106 '__INTRANET_WWW_DIR__' => "$prefix/intranet/www",
107 '__OPAC_CGI_DIR__' => "$prefix/opac/cgi-bin",
108 '__OPAC_TMPL_DIR__' => "$prefix/opac/templates",
109 '__OPAC_WWW_DIR__' => "$prefix/opac/www",
110 '__PERL_MODULE_DIR__' => ($ENV{'INSTALLSITELIB'} || sprintf($prefix."/lib/perl5/site_perl/%vd",$^V))."/koha",
111 '__KOHA_CONF_DIR__' => "$prefix/etc/koha",
112 '__ZEBRA_CONF_DIR__' => "$prefix/etc/koha/zebradb",
70dccac FRBR: configure PazPar2 during installation
Galen Charlton authored
113 '__PAZPAR2_CONF_DIR__' => "$prefix/etc/koha/pazpar2",
1b71360 installer: various changes
Galen Charlton authored
114 '__MISC_DIR__' => "$prefix/misc",
5befdd2 installer (part 2): more work
Galen Charlton authored
115 '__SCRIPT_DIR__' => "$prefix/bin",
116 '__MAN_DIR__' => "$prefix/man",
117 '__DOC_DIR__' => "$prefix/doc",
118 '__ZEBRA_LOCK_DIR__' => "$prefix/var/lock/zebradb",
119 '__ZEBRA_DATA_DIR__' => "$prefix/var/lib/zebradb",
120 '__ZEBRA_RUN_DIR__' => "$prefix/var/run/zebradb",
0f5fa1b installer: further moves of zebra configuration files
Galen Charlton authored
121 '__ZEBRA_MARC_FORMAT__' => 'marc21',
122 '__ZEBRA_LANGUAGE__' => 'en',
1c0401e authorities - enabled DOM indexing
Galen Charlton authored
123 '__ZEBRA_AUTH_CFG__' => 'zebra-authorities.cfg',
124 '__AUTH_RETRIEVAL_CFG__' => 'retrieval-info-auth-grs1.xml',
70dccac FRBR: configure PazPar2 during installation
Galen Charlton authored
125 "__MERGE_SERVER_HOST__" => $myhost,
126 "__MERGE_SERVER_PORT__" => '11001',
127 "__PAZPAR2_HOST__" => $myhost,
128 "__PAZPAR2_PORT__" => '11002',
20f1c41 install: added --prev-install-log option to Makefile.PL
Galen Charlton authored
129 "__INSTALL_MODE__" => 'standard',
130 "__INSTALL_BASE__" => '/usr/share/koha',
131 "__INSTALL_ZEBRA__" => 'yes',
132 "__INSTALL_SRU__" => 'yes',
133 "__INSTALL_PAZPAR2__" => 'no',
6835e19 kohabug 1776 - disable mergeserver if not installing PazPar2
Galen Charlton authored
134 "__PAZPAR2_TOGGLE_XML_PRE__" => '<!--',
135 "__PAZPAR2_TOGGLE_XML_POST__" => '-->',
20f1c41 install: added --prev-install-log option to Makefile.PL
Galen Charlton authored
136 "__AUTH_INDEX_MODE__" => 'grs1',
149ece8 added RUN_DATABASE_TESTS to install log
Galen Charlton authored
137 "__RUN_DATABASE_TESTS__" => 'no',
2fafa14 kohabug 1776 - try to locate Zebra during install
Galen Charlton authored
138 "__PATH_TO_ZEBRA__" => "",
0d20950 add memcached questions to koha-install-log
Michael Hafen authored
139 "__USE_MEMCACHED__" => 'no',
e16e920 @ranginui Updating the Makefile so memcached configuration can be added to the …
ranginui authored
140 "__MEMCACHED_SERVERS__" => "",
141 "__MEMCACHED_NAMESPACE__" => "",
e449c13 @mjray Add configuration file helper to the installer
mjray authored
142 );
143
144 # Override configuration from the environment
145 foreach $key (keys %configuration) {
146 if (defined($ENV{$key})) {
147 $configuration{$key} = $ENV{$key};
148 }
149 }
150
6835e19 kohabug 1776 - disable mergeserver if not installing PazPar2
Galen Charlton authored
151 # munge commenting out the PazPar2 mergeserver
152 # entry in koha-conf.xml if necessary
153 if ($configuration{'__INSTALL_PAZPAR2__'} eq 'yes') {
154 $configuration{'__PAZPAR2_TOGGLE_XML_PRE__'} = '';
155 $configuration{'__PAZPAR2_TOGGLE_XML_POST__'} = '';
156 }
157
e449c13 @mjray Add configuration file helper to the installer
mjray authored
158 $fname = $ARGV[0];
6835e19 kohabug 1776 - disable mergeserver if not installing PazPar2
Galen Charlton authored
159 $file = &read_file($fname);
1df0f05 installer: make rewrite-config.PL change only defined parameters
Galen Charlton authored
160 $file =~ s/__.*?__/exists $configuration{$&} ? $configuration{$&} : $&/seg;
e6ee69b various installer changes
Galen Charlton authored
161
162 # At this point, file is in 'blib' and by default
163 # has mode a-w. Therefore, must change permission
164 # to make it writable. Note that stat and chmod
165 # (the Perl functions) should work on Win32
166 my $old_perm;
167 $old_perm = (stat $fname)[2] & 07777;
168 my $new_perm = $old_perm | 0200;
169 chmod $new_perm, $fname;
170
e449c13 @mjray Add configuration file helper to the installer
mjray authored
171 open(OUTPUT,">$fname") || die "Can't open $fname for write: $!";
172 print OUTPUT $file;
173 close(OUTPUT);
174
e6ee69b various installer changes
Galen Charlton authored
175 chmod $old_perm, $fname;
176
e449c13 @mjray Add configuration file helper to the installer
mjray authored
177 # Idea taken from perlfaq5
178 sub read_file($) {
179 local(*INPUT,$/);
180 open(INPUT,$_[0]) || die "Can't open $_[0] for read";
181 my $file = <INPUT>;
182 return $file;
183 }
184
185 __END__
186
187
188 =head1 SEE ALSO
189
190 Makefile.PL, ExtUtils::MakeMaker(3)
191
192 =head1 AUTHOR
193
194 MJ Ray mjr at phonecoop.coop
195
196 =cut
Something went wrong with that request. Please try again.