Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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