Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 132 lines (103 sloc) 3.838 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 #
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
98782b8 Correct comments and POD to reflect keyword additions/changes
Chris Nighswonger authored
20 #
21 # 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
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
61190e9 @mjray New installation instructions and release notes.
mjray authored
36 This helper script replaces keywords in the
e449c13 @mjray Add configuration file helper to the installer
mjray authored
37 configuration files with value either supplied through
38 the environment (with export, or by putting them on
61190e9 @mjray New installation instructions and release notes.
mjray authored
39 the start of the make command line) or with reasonable
e449c13 @mjray Add configuration file helper to the installer
mjray authored
40 guesses worked out by the script.
41
61190e9 @mjray New installation instructions and release notes.
mjray authored
42 =head2 KEYWORDS
e449c13 @mjray Add configuration file helper to the installer
mjray authored
43
61190e9 @mjray New installation instructions and release notes.
mjray authored
44 The following configuration keywords are available:
e449c13 @mjray Add configuration file helper to the installer
mjray authored
45
243ec54 @mjray Move many files to more FHS-like paths
mjray authored
46 PREFIX,
d1f9665 Now using install_base instead of prefix
Chris Cormack authored
47 BASE_DIR, CGI_DIR, LOG_DIR, INSTALL_BASE,
98782b8 Correct comments and POD to reflect keyword additions/changes
Chris Nighswonger authored
48 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
49 WEBSERVER_HOST, WEBSERVER_IP, WEBSERVER_PORT, WEBSERVER_PORT_LIBRARIAN, ZEBRA_PASS, ZEBRA_USER
e449c13 @mjray Add configuration file helper to the installer
mjray authored
50
61190e9 @mjray New installation instructions and release notes.
mjray authored
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
e449c13 @mjray Add configuration file helper to the installer
mjray authored
61 =cut
62
63 $myhost = hostname();
64 $mydomain = $myhost;
65 $mydomain =~ s/^.*?\.//;
cecd7ef @mjray BUGFIX: set all configuration keys - die terminated the hash
mjray authored
66 # This is set here to rescue systems with broken DNS
67 $myip = $ENV{'WEBSERVER_IP'} || inet_ntoa(scalar gethostbyname($myhost||'localhost')) || die "Cannot get our own IP address: DNS fault?";
d1f9665 Now using install_base instead of prefix
Chris Cormack authored
68 $prefix = $ENV{'INSTALL_BASE'} || "/usr";
e449c13 @mjray Add configuration file helper to the installer
mjray authored
69
70 # These are our configuration guesses
71 # Keys were extracted by
72 # <grep -o '__.*__' etc/* | cut -f2 -d: | sort -u | sed -e 's/^/ "/;s/$/" => "",/'
73 %configuration = (
9db489f Second try:Corrected bad pathing for default Perl base dir. Default n…
Chris Nighswonger authored
74 "__BASE_DIR__" => ($ENV{'INSTALLSITELIB'} || sprintf($prefix."/lib/perl/%vd",$^V))."/koha",
8a5e2f2 Corrected bad pathing for default Perl base dir. Default now matches …
Chris Nighswonger authored
75 # Corrected to match Debian Perl req's.... -fbcit
243ec54 @mjray Move many files to more FHS-like paths
mjray authored
76 "__CGI_DIR__" => $prefix."/lib/cgi-bin/koha",
77 "__LOG_DIR__" => "/var/log",
bc4699c Changes to add dbms type and port & rename db vars for multi-dbms
Chris Nighswonger authored
78 "__DB_TYPE__" => "mysql",
79 "__DB_NAME__" => "koha",
80 "__DB_HOST__" => $myhost,
81 "__DB_PORT__" => "3306",
82 "__DB_USER__" => "kohaadmin",
83 "__DB_PASS__" => "katikoan",
243ec54 @mjray Move many files to more FHS-like paths
mjray authored
84 "__PREFIX__" => $prefix,
28695e9 @mjray Add missing auto_install features to new installer
mjray authored
85 "__WEBMASTER_EMAIL__" => 'webmaster@'.$mydomain,
e449c13 @mjray Add configuration file helper to the installer
mjray authored
86 "__WEBSERVER_DOMAIN__" => $mydomain,
87 "__WEBSERVER_HOST__" => $myhost,
cecd7ef @mjray BUGFIX: set all configuration keys - die terminated the hash
mjray authored
88 "__WEBSERVER_IP__" => $myip,
89 "__WEBSERVER_PORT__" => "80",
90 "__WEBSERVER_PORT_LIBRARIAN__" => "8080",
e449c13 @mjray Add configuration file helper to the installer
mjray authored
91 "__ZEBRA_PASS__" => "zebrastripes",
92 "__ZEBRA_USER__" => "kohauser",
ba604d4 Added env var MARCFLAVOUR to spec marc to be installed for zebra
Chris Nighswonger authored
93 "__MARCFLAVOUR__" => "marc21",
e449c13 @mjray Add configuration file helper to the installer
mjray authored
94 );
95
96 # Override configuration from the environment
97 foreach $key (keys %configuration) {
98 if (defined($ENV{$key})) {
99 $configuration{$key} = $ENV{$key};
100 }
101 }
102
103 $fname = $ARGV[0];
104 $file = read_file($fname);
105 $file =~ s/__.*?__/$configuration{$&}/seg;
106 chmod 0644, $fname;
107 open(OUTPUT,">$fname") || die "Can't open $fname for write: $!";
108 print OUTPUT $file;
109 close(OUTPUT);
110
111 # Idea taken from perlfaq5
112 sub read_file($) {
113 local(*INPUT,$/);
114 open(INPUT,$_[0]) || die "Can't open $_[0] for read";
115 my $file = <INPUT>;
116 return $file;
117 }
118
119 __END__
120
121
122 =head1 SEE ALSO
123
124 Makefile.PL, ExtUtils::MakeMaker(3)
125
126 =head1 AUTHOR
127
128 MJ Ray mjr at phonecoop.coop
129
130 =cut
131
Something went wrong with that request. Please try again.