minor update.
[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    elsif (open(INPUT, "</etc/hostname")) {
25       $domainname = <INPUT>;
26    }
27 }
28 Install::setdomainname $domainname;
29
30 ###############################################
31 # SET  THE  etcdir  ENVIRONMENT  VAR  INSTEAD #
32 ###############################################
33 my $etcdir = $ENV{etcdir}||'/etc';
34 system("mkdir -p $etcdir");
35
36 Install::setetcdir $etcdir;
37
38 unless (-d 'intranet-html') {
39    print <<EOP;
40 You seem to be installing from CVS. Please run the "buildrelease" script
41 and install from the resulting release tarball.
42 EOP
43    exit 1;
44 }
45
46 my $kohaversion=`cat koha.version`;
47 chomp $kohaversion;
48 Install::setkohaversion $kohaversion;
49
50
51 if ($kohaversion =~ /RC/) {
52     releasecandidatewarning();
53 }
54
55 checkabortedinstall();
56
57 if (-e "$etcdir/koha.conf") {
58     my $installedversion=`grep kohaversion= "$etcdir/koha.conf"`;
59     chomp $installedversion;
60     $installedversion=~m/kohaversion=(.*)/;
61     $installedversion=$1;
62     my $installedversionmsg;
63     if ($installedversion) {
64         $installedversionmsg=getmessage('KohaVersionInstalled', [$installedversion]);
65     } else {
66         $installedversionmsg=getmessage('KohaUnknownVersionInstalled');
67     }
68
69     my $message=getmessage('KohaAlreadyInstalled', [$etcdir, $kohaversion, $installedversionmsg]);
70     showmessage($message, 'none');
71     exit;
72 }
73
74 my $continuingmsg=getmessage('continuing');
75
76 my $message=getmessage('WelcomeToKohaInstaller');
77 my $answer=showmessage($message, 'yn');
78
79 if ($answer eq "Y" || $answer eq "y") {
80         print $continuingmsg;
81     } else {
82     print qq|
83 This installer currently does not support a completely automated
84 setup.
85
86 Please be sure to read the documentation, or visit the Koha website
87 at http://www.koha.org for more information.
88 |;
89     exit;
90 };
91
92 # Check for missing Perl Modules
93 checkperlmodules();
94
95 # Ask for installation directories
96 getapacheinfo();
97
98 getinstallationdirectories();
99
100 getdatabaseinfo();
101
102 getapachevhostinfo();
103
104 updateapacheconf();
105
106 basicauthentication();
107
108 installfiles();
109
110 backupmycnf();
111
112 databasesetup();
113
114 updatedatabase();
115
116 populatedatabase();
117
118 restoremycnf();
119
120 finalizeconfigfile();
121
122 restartapache();
123
124
125
126
127 showmessage(getmessage('AuthenticationWarning', [$etcdir]), 'PressEnter');
128
129
130 showmessage(getmessage('Completed', [ Install::getservername(), Install::getintranetport(), Install::getservername(), Install::getopacport()]), 'PressEnter');
131
132
133
134
135 if (-f "kohareporter") {
136     my $reply=showmessage('Would you like to complete a survey about your library?', 'yn', 'y');
137     if ($reply=~/y/i) {
138         system("perl kohareporter");
139     }
140 }