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