1 # $Id:$ vim: fdm=marker
3 # Licensed under the GPL
4 # Copyright 2008 Biblibre.com
5 # Koha library project www.koha-community.org
7 # this script follow all the installtion procedure described in INSTALL.Debian
8 # with some additions to use lenny packages.
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along
22 # with Koha; if not, write to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 # - search and destroy all TODO in this file
27 # - detect country or locale to choose lang and marc by default for koha install
29 # - detect country or locale to choose translator
31 # abort if anything wrong
35 : ${DB_HOST:=localhost}
37 : ${DB_USER:=kohaadmin}
38 : ${DB_PASS:=katikoan}
40 : ${INSTALL_ZEBRA:=yes}
42 : ${INSTALL_PAZPAR2:=no}
43 : ${AUTH_INDEX_MODE:=grs1}
44 : ${BIB_INDEX_MODE:=grs1}
46 : ${INSTALL_MODE:=standard}
48 : ${ZEBRA_MARC_FORMAT:=marc21}
49 : ${ZEBRA_LANGUAGE:=en}
50 : ${ZEBRA_USER:=kohauser}
51 : ${ZEBRA_PASS:=zebrastripes}
52 : ${ZEBRA_SRU_HOST:=localhost}
53 : ${ZEBRA_SRU_BIBLIOS_PORT:=9998}
54 : ${ZEBRA_SRU_AUTHORITIES_PORT:=9999}
60 : ${MERGE_SERVER_HOST:=localhost}
61 : ${MERGE_SERVER_PORT:=11001}
63 : ${PAZPAR2_HOST:=localhost}
64 : ${PAZPAR2_PORT:=11002}
66 : ${KOHA_SRC_DIR:=/usr/local/src}
67 : ${KOHA_SRC_BASE:=koha}
68 KOHA_SRC_PATH="$KOHA_SRC_DIR/$KOHA_SRC_BASE"
69 : ${GET_KOHA_SRC_METHOD:=git}
71 # repo that is used by configure_lenny_sources
72 # FIXME: comment this before update
73 LENNY_FLAVORS="testing main non-free contrib"
75 GET_KOHA_LOG=/dev/null
77 # functions declarations {{{
84 while echo '(y/n)' && read ans; do
85 [ x"$ans" = xn ] && return 1
86 [ x"$ans" = xy ] && return 0
91 warn () { echo "$*" >&2
95 # the rest is an error message
104 # add a list of names of packages to be installed
105 # exemple: add_package screen zsh
106 # or : echo screen zsh | add_package
117 open_package_list () {
118 PACKAGELIST=$(mktemp)
119 # write in fd3 to add a name of required package
123 install_package_list () {
127 xargs -a $PACKAGELIST aptitude install
132 configure_indexdata_sources () {
134 # Add indexdata packages to the apt sources
135 echo ' # Sources for yaz and idzebra
136 deb http://ftp.indexdata.dk/debian etch main
137 ' > /etc/apt/sources.list.d/indexdata.sources.list
139 # install indexdata key (to make indexdata sources usable)
140 wget -O- http://ftp.indexdata.dk/debian/indexdata.asc |
141 apt-key add - || die 1 "can't get indexdata sources"
145 configure_lenny_using_apt_spy () {
147 aptitude -y install apt-spy
152 # configure_lenny_using_etch_mirror () {
153 # sed /etc/apt/sources.list > \
154 # /etc/apt/sources.list.d/testing.sources.list
155 # need to handle $@ for this
158 add_default_lenny_repro () {
159 echo "deb $LENNY_REPO $LENNY_FLAVORS" > \
160 /etc/apt/sources.list.d/testing.sources.list
163 ask_for_lenny_repo () {
164 echo 'type the url of the repository to use for lenny packages. Be sure that is a valid debian repository.
165 for example http://ftp.fr.debian.org/debian/'
167 add_default_lenny_repro
172 if [ "$LENNY_REPO" ]; then
173 add_default_lenny_repro
175 echo '$LENNY_REPO not set, what do you want to do now'
177 'manually set LENNY_REPO
179 'get and use apt-spy to automatically find a repository
180 (it can take some times)
182 'let sources.list as it (still configured)' \
183 'leave the installation'
193 configure_lenny_using_apt_spy
209 configure_aptitude_correctly () {
210 # configure aptitude to behave as old apt tools and
211 # use etch packages by default
212 cat << CONFAPT > /etc/apt/apt.conf.d/Apt
214 Default-Release "stable";
215 Cache-Limit 20000000;
219 Recommends-Important false;
220 Keep-Recommends false;
226 set_libxml_parser () {
227 # TODO: update-perl-sax-parsers --priority since lib-xml-sax-perl 0.16
229 # when XML::LibXML::SAX::Parser header detected
230 # move the 2 lines in the hold space
231 /[[]XML::LibXML::SAX::Parser[]]/ {
235 # replace end of file by hold space
237 ' /etc/perl/XML/SAX/ParserDetails.ini
240 verify_sax_parser () {
242 r=`perl -MXML::SAX::ParserFactory -e 'print ref XML::SAX::ParserFactory->parser'`
243 test "$r" = XML::LibXML::SAX::Parser || set_libxml_parser
246 create_debian_koha_user() {
247 # TODO: use $KOHA_GROUP
248 echo ----------------------
249 echo add the system user and group for koha.
251 echo ----------------------
255 apache_add_ports () {
256 local ports ports_conf needed
257 ports_conf="${1:-/etc/apache2/ports.conf}"
258 ports=`sed -n 's/Listen[\t ]\([0-9]\+\)/\1/p' "$ports_conf"`
259 { for needed in 80 8080; do
260 expr "$ports" : '.*\<\('$needed'\)\>.*' > /dev/null ||
261 echo "# Added by koha installer
264 done } >> "$ports_conf"
267 get_koha_git_clone () {
268 # /!\ be carrefull to be in the good directory
269 # /usr/local/src/ recommended
270 local base="${1:-koha}"
273 aptitude -y install git-core git-email
274 git clone git://git.koha-community.org/koha.git "$base"
277 get_koha_release () {
278 wget -O- http://download.koha-community.org/koha-3.00.00.tar.gz |
283 # /!\ be carrefull to be in the good directory
284 # /usr/local/src/ recommended
290 get_koha_release "$base" && return 0
291 [ $method = tar ] && return 1
293 local i basename; i=2
294 while [ $i != 11 ]; do
295 basename=koha-3.00.00-beta$i
296 wget -O- http://download.koha-community.org/$basename.tar.gz |
298 mv $basename "$base" &&
306 get_koha_sources () {
307 # /!\ be carrefull to be in the good directory
308 # /usr/local/src/ recommended
314 git) get_koha_git_clone $base
317 get_koha_release "$base" ||
320 beta) get_koha_beta "$base" "$method" ||
323 *) : # TODO: error message and exit
328 # end of function declarations }}}
330 if [ -e "$KOHA_SRC_PATH" ];then
331 if ask_yn "$KOHA_SRC_PATH still exists. use it ?"; then
332 ask_yn "download the sources again ?" ||
338 [ -d "$KOHA_SRC_DIR" ] ||
339 die 1 "$KOHA_SRC_DIR is not a directory"
342 # parsing arguments {{{
344 # TODO: this won't work with real bourne shell (use expr instead)
346 [ "$1" = *b* ] && GET_KOHA_SRC_METHOD=beta
347 [ "$1" = *t* ] && GET_KOHA_SRC_METHOD=tar
348 [ "$1" = *c* ] && DEBIAN_STILL_CONFIGURED=yes
353 cd $KOHA_SRC_PATH && return 0
358 for candidate in koha?*; do
359 if [ $done = no ]; then
360 mv $candidate $KOHA_SRC_BASE
362 die 1 "more than one koha candidate into $KOHA_SRC_DIR, please clean up"
365 cd $KOHA_SRC_PATH && die 1 "can't cd to $KOHA_SRC_PATH"
368 mysql_create_base () {
369 # TODO: what if non mysql backend ? so code !
370 # try to create or try to find the base
371 mysqladmin -uroot create "$1" ||
372 echo show databases |
377 mysql_grant_access () {
378 local base login password
379 base="$1" login="$2" password="$3"
380 cat << GRANTACCESS | mysql
381 grant all on $base.* to '$login'@'localhost' identified by '$password';
386 verify_etch_sources () {
388 current=/etc/apt/sources.list
389 backup=/etc/apt/sources.list.bak
390 if [ ! -e $current ] || [ ! -s $current ]; then
391 [ -e $backup ] && mv $backup $current || die 1 "can't find etch"
398 [ "$PLEASE_DONT_GET" ] ||
399 get_koha_sources "$KOHA_SRC_BASE" "$GET_KOHA_SRC_METHOD" > $GET_KOHA_LOG 2>&1 &
401 [ $DEBIAN_STILL_CONFIGURED ] || {
402 configure_indexdata_sources # to install yaz and iezebra
403 configure_lenny # because etch lacks some packages
404 configure_aptitude_correctly # to solve dependancies and conflicts
412 open_package_list # now we can add packages with add_package command
413 # this would be installed by dependances but it needs to be
414 # installed first to autoconfigure perl sax parser
415 add_package libxml-libxml-perl
416 # libyaz-dev required to build Net::Z3950::ZOOM from cpan
417 # can be removed when debian package will be usefull
418 add_package libyaz-dev
419 # lot of koha dependancies
420 cat << PACKAGES | add_package
423 libmail-sendmail-perl
424 libhtml-scrubber-perl
425 libmarc-record-perl/testing
426 libmarc-charset-perl/testing
427 libmarc-crosswalk-dublincore-perl
429 libpdf-reuse-barcode-perl
431 libxml-rss-perl/testing
444 libdatetime-format-mail-perl
445 libdatetime-format-ical-perl
447 libdatetime-format-strptime-perl
448 libdatetime-format-w3cdtf-perl
455 libtext-csv-perl/testing
456 libtext-charwidth-perl
457 libtime-duration-perl
464 libxml-xslt-perl/testing
469 libhtml-template-pro-perl
470 libdbd-mysql-perl/testing
471 libgraphics-magick-perl
472 liblist-moreutils-perl
473 libtext-iconv-perl/testing
474 libalgorithm-checkdigits-perl
478 # no more "path not found" message during cpan configuration
479 add_package unzip lynx ncftp ftp
481 # just because it ease the life of the sysop
482 add_package screen zsh less lsof strace
484 # every selected packages will now be installed
486 # something wrong with libyaz-dev... KISS workaround is reinstall
487 aptitude install libyaz-dev
489 # those perl libs have no statisfying debian packages
490 # so they are installed via cpan.
491 cpan Net::Z3950::ZOOM Biblio::EndnoteStyle
493 getent passwd $KOHA_USER ||
494 create_debian_koha_user $KOHA_USER ||
495 die 1 "can't create $KOHA_USER"
497 mysql_create_base "$DB_NAME" ||
498 die 1 "can't create or find $DB_NAME"
499 mysql_grant_access "$DB_NAME" "$DB_USER" "$DB_PASS" ||
500 die 1 "can't grant access to $DB_USER"
502 echo "please wait while i'm downloading koha sources"
515 sed -n ' s/^'"$1"' = //T;p;q' Makefile
518 koha_conf=`makefile_value KOHA_DEST_KOHA_CONF_DIR`
519 ln -s "$koha_conf"/koha-httpd.conf /etc/apache2/sites-available/koha
523 invoke-rc.d apache2 reload
525 koha_script=`makefile_value KOHA_DEST_SCRIPT_DIR`
529 # if cd misc/translator; then
530 # ./tmpl_process3 install -s po/fr-FR... -i ../../koha-tmpl/opac-tmpl/prog/en -o ../../koha-tmpl/opac-tmpl/prog/fr-FR