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