Removed the $:: notation from a lot of global variables; this is needed to
[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 $domainname = $domainname =~ /^[^\.]+\.(.*)$/? $1: undef;
14 Install::setdomainname $domainname;
15
16 my $etcdir = '/etc';
17 Install::setetcdir $etcdir;
18
19 unless ($< == 0) {
20     print "You must be root to run this script.\n";
21     exit 1;
22 }
23
24
25 unless (-d 'intranet-html') {
26    print <<EOP;
27 You seem to be installing from CVS. Please run the "buildrelease" script
28 and install from the resulting release tarball.
29 EOP
30    exit 1;
31 }
32
33 my $kohaversion=`cat koha.version`;
34 chomp $kohaversion;
35 Install::setkohaversion $kohaversion;
36
37
38 if ($kohaversion =~ /RC/) {
39     releasecandidatewarning();
40 }
41
42 checkabortedinstall();
43
44 if (-e "$etcdir/koha.conf") {
45     my $installedversion=`grep kohaversion= $etcdir/koha.conf`;
46     chomp $installedversion;
47     $installedversion=~m/kohaversion=(.*)/;
48     $installedversion=$1;
49     my $installedversionmsg;
50     if ($installedversion) {
51         $installedversionmsg=getmessage('KohaVersionInstalled', [$installedversion]);
52     } else {
53         $installedversionmsg=getmessage('KohaUnknownVersionInstalled');
54     }
55
56     my $message=getmessage('KohaAlreadyInstalled', [$etcdir, $kohaversion, $installedversionmsg]);
57     showmessage($message, 'none');
58     exit;
59 }
60
61 my $continuingmsg=getmessage('continuing');
62
63 my $message=getmessage('WelcomeToKohaInstaller');
64 my $answer=showmessage($message, 'yn');
65
66 if ($answer eq "Y" || $answer eq "y") {
67         print $continuingmsg;
68     } else {
69     print qq|
70 This installer currently does not support a completely automated
71 setup.
72
73 Please be sure to read the documentation, or visit the Koha website
74 at http://www.koha.org for more information.
75 |;
76     exit;
77 };
78
79 # Check for missing Perl Modules
80 checkperlmodules();
81
82 # Ask for installation directories
83 getapacheinfo();
84
85 getinstallationdirectories();
86
87 getdatabaseinfo();
88
89 getapachevhostinfo();
90
91 updateapacheconf();
92
93 basicauthentication();
94
95 installfiles();
96
97 databasesetup();
98
99 updatedatabase();
100
101 #updatemarc();
102
103 populatedatabase();
104
105 restartapache();
106
107
108 # Installation is complete.  Rename the koha.conf.tmp file
109
110 rename "$etcdir/koha.conf.tmp", "$etcdir/koha.conf" || warn "Couldn't rename file at $etcdir. Must have write capability.\n";
111
112
113 showmessage(getmessage('AuthenticationWarning', [$etcdir]), 'PressEnter');
114
115
116 showmessage(getmessage('Completed', [ Install::getservername(), Install::getintranetport(), Install::getservername(), Install::getopacport()]), 'PressEnter');
117
118
119
120
121 if (-f "kohareporter") {
122     my $reply=showmessage('Would you like to complete a survey about your library?', 'yn', 'y');
123     if ($reply=~/y/i) {
124         system("perl kohareporter");
125     }
126 }