Moved knowledge of "koha.conf.tmp" to the Install.pm
[koha.git] / misc / installer.pl
1 #!/usr/bin/perl -w # please develop with -w
2
3 #use diagnostics;
4
5 use Install;
6 use strict; # please develop with the strict pragma
7
8 use vars qw( $input );
9
10 Install::setlanguage 'en';
11
12 my $domainname = `hostname`; # Note: must not have any arguments (portability)
13 if ($domainname =~ /^[^\s\.]+\.([-a-z0-9\.]+)$/) {
14    $domainname = $1;
15 } else {
16    undef $domainname;
17    if (open(INPUT, "</etc/resolv.conf")) {
18       while (<INPUT>) {
19          $domainname = $1 if /^domain\s+([-a-z0-9\.]+)\s*$/i;
20       last if defined $domainname;
21       }
22       close INPUT;
23    }
24 }
25 Install::setdomainname $domainname;
26
27 my $etcdir = '/etc';
28 Install::setetcdir $etcdir;
29
30 unless ($< == 0) {
31     print "You must be root to run this script.\n";
32     exit 1;
33 }
34
35
36 unless (-d 'intranet-html') {
37    print <<EOP;
38 You seem to be installing from CVS. Please run the "buildrelease" script
39 and install from the resulting release tarball.
40 EOP
41    exit 1;
42 }
43
44 my $kohaversion=`cat koha.version`;
45 chomp $kohaversion;
46 Install::setkohaversion $kohaversion;
47
48
49 if ($kohaversion =~ /RC/) {
50     releasecandidatewarning();
51 }
52
53 checkabortedinstall();
54
55 if (-e "$etcdir/koha.conf") {
56     my $installedversion=`grep kohaversion= $etcdir/koha.conf`;
57     chomp $installedversion;
58     $installedversion=~m/kohaversion=(.*)/;
59     $installedversion=$1;
60     my $installedversionmsg;
61     if ($installedversion) {
62         $installedversionmsg=getmessage('KohaVersionInstalled', [$installedversion]);
63     } else {
64         $installedversionmsg=getmessage('KohaUnknownVersionInstalled');
65     }
66
67     my $message=getmessage('KohaAlreadyInstalled', [$etcdir, $kohaversion, $installedversionmsg]);
68     showmessage($message, 'none');
69     exit;
70 }
71
72 my $continuingmsg=getmessage('continuing');
73
74 my $message=getmessage('WelcomeToKohaInstaller');
75 my $answer=showmessage($message, 'yn');
76
77 if ($answer eq "Y" || $answer eq "y") {
78         print $continuingmsg;
79     } else {
80     print qq|
81 This installer currently does not support a completely automated
82 setup.
83
84 Please be sure to read the documentation, or visit the Koha website
85 at http://www.koha.org for more information.
86 |;
87     exit;
88 };
89
90 # Check for missing Perl Modules
91 checkperlmodules();
92
93 # Ask for installation directories
94 getapacheinfo();
95
96 getinstallationdirectories();
97
98 getdatabaseinfo();
99
100 getapachevhostinfo();
101
102 updateapacheconf();
103
104 basicauthentication();
105
106 installfiles();
107
108 databasesetup();
109
110 updatedatabase();
111
112 populatedatabase();
113
114 finalizeconfigfile();
115
116 restartapache();
117
118
119
120
121 showmessage(getmessage('AuthenticationWarning', [$etcdir]), 'PressEnter');
122
123
124 showmessage(getmessage('Completed', [ Install::getservername(), Install::getintranetport(), Install::getservername(), Install::getopacport()]), 'PressEnter');
125
126
127
128
129 if (-f "kohareporter") {
130     my $reply=showmessage('Would you like to complete a survey about your library?', 'yn', 'y');
131     if ($reply=~/y/i) {
132         system("perl kohareporter");
133     }
134 }