1 # $Id:$ vim: fdm=marker
3 # Licensed under the GPL
4 # Copyright 2008 Biblibre.com
5 # Koha library project www.koha.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 with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA 02111-1307 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}
45 : ${INSTALL_MODE:=standard}
47 : ${ZEBRA_MARC_FORMAT:=marc21}
48 : ${ZEBRA_LANGUAGE:=en}
49 : ${ZEBRA_USER:=kohauser}
50 : ${ZEBRA_PASS:=zebrastripes}
51 : ${ZEBRA_SRU_HOST:=localhost}
52 : ${ZEBRA_SRU_BIBLIOS_PORT:=9998}
53 : ${ZEBRA_SRU_AUTHORITIES_PORT:=9999}
59 : ${MERGE_SERVER_HOST:=localhost}
60 : ${MERGE_SERVER_PORT:=11001}
62 : ${PAZPAR2_HOST:=localhost}
63 : ${PAZPAR2_PORT:=11002}
65 : ${KOHA_SRC_DIR:=/usr/local/src}
66 : ${KOHA_SRC_BASE:=koha}
67 KOHA_SRC_PATH="$KOHA_SRC_DIR/$KOHA_SRC_BASE"
68 : ${GET_KOHA_SRC_METHOD:=git}
70 # repo that is used by configure_lenny_sources
71 # FIXME: comment this before update
72 LENNY_FLAVORS="testing main non-free contrib"
74 GET_KOHA_LOG=/dev/null
76 # functions declarations {{{
83 while echo '(y/n)' && read ans; do
84 [ x"$ans" = xn ] && return 1
85 [ x"$ans" = xy ] && return 0
90 warn () { echo "$*" >&2
94 # the rest is an error message
103 # add a list of names of packages to be installed
104 # exemple: add_package screen zsh
105 # or : echo screen zsh | add_package
116 open_package_list () {
117 PACKAGELIST=$(mktemp)
118 # write in fd3 to add a name of required package
122 install_package_list () {
126 xargs -a $PACKAGELIST aptitude install
131 configure_indexdata_sources () {
133 # Add indexdata packages to the apt sources
134 echo ' # Sources for yaz and idzebra
135 deb http://ftp.indexdata.dk/debian etch main
136 ' > /etc/apt/sources.list.d/indexdata.sources.list
138 # install indexdata key (to make indexdata sources usable)
139 wget -O- http://ftp.indexdata.dk/debian/indexdata.asc |
140 apt-key add - || die 1 "can't get indexdata sources"
144 configure_lenny_using_apt_spy () {
146 aptitude -y install apt-spy
151 # configure_lenny_using_etch_mirror () {
152 # sed /etc/apt/sources.list > \
153 # /etc/apt/sources.list.d/testing.sources.list
154 # need to handle $@ for this
157 add_default_lenny_repro () {
158 echo "deb $LENNY_REPO $LENNY_FLAVORS" > \
159 /etc/apt/sources.list.d/testing.sources.list
162 ask_for_lenny_repo () {
163 echo 'type the url of the repository to use for lenny packages. Be sure that is a valid debian repository.
164 for example http://ftp.fr.debian.org/debian/'
166 add_default_lenny_repro
171 if [ "$LENNY_REPO" ]; then
172 add_default_lenny_repro
174 echo '$LENNY_REPO not set, what do you want to do now'
176 'manually set LENNY_REPO
178 'get and use apt-spy to automatically find a repository
179 (it can take some times)
181 'let sources.list as it (still configured)' \
182 'leave the installation'
192 configure_lenny_using_apt_spy
208 configure_aptitude_correctly () {
209 # configure aptitude to behave as old apt tools and
210 # use etch packages by default
211 cat << CONFAPT > /etc/apt/apt.conf.d/Apt
213 Default-Release "stable";
214 Cache-Limit 20000000;
218 Recommends-Important false;
219 Keep-Recommends false;
225 set_libxml_parser () {
226 # TODO: update-perl-sax-parsers --priority since lib-xml-sax-perl 0.16
228 # when XML::LibXML::SAX::Parser header detected
229 # move the 2 lines in the hold space
230 /[[]XML::LibXML::SAX::Parser[]]/ {
234 # replace end of file by hold space
236 ' /etc/perl/XML/SAX/ParserDetails.ini
239 verify_sax_parser () {
241 r=`perl -MXML::SAX::ParserFactory -e 'print ref XML::SAX::ParserFactory->parser'`
242 test "$r" = XML::LibXML::SAX::Parser || set_libxml_parser
245 create_debian_koha_user() {
246 # TODO: use $KOHA_GROUP
247 echo ----------------------
248 echo add the system user and group for koha.
250 echo ----------------------
254 apache_add_ports () {
255 local ports ports_conf needed
256 ports_conf="${1:-/etc/apache2/ports.conf}"
257 ports=`sed -n 's/Listen[\t ]\([0-9]\+\)/\1/p' "$ports_conf"`
258 { for needed in 80 8080; do
259 expr "$ports" : '.*\<\('$needed'\)\>.*' > /dev/null ||
260 echo "# Added by koha installer
263 done } >> "$ports_conf"
266 get_koha_git_clone () {
267 # /!\ be carrefull to be in the good directory
268 # /usr/local/src/ recommended
269 local base="${1:-koha}"
272 aptitude -y install git-core git-email
273 git clone git://git.koha.org/pub/scm/koha.git "$base"
276 get_koha_release () {
277 wget -O- http://download.koha.org/koha-3.00.00.tar.gz |
282 # /!\ be carrefull to be in the good directory
283 # /usr/local/src/ recommended
289 get_koha_release "$base" && return 0
290 [ $method = tar ] && return 1
292 local i basename; i=2
293 while [ $i != 11 ]; do
294 basename=koha-3.00.00-beta$i
295 wget -O- http://download.koha.org/$basename.tar.gz |
297 mv $basename "$base" &&
305 get_koha_sources () {
306 # /!\ be carrefull to be in the good directory
307 # /usr/local/src/ recommended
313 git) get_koha_git_clone $base
316 get_koha_release "$base" ||
319 beta) get_koha_beta "$base" "$method" ||
322 *) : # TODO: error message and exit
327 # end of function declarations }}}
329 if [ -e "$KOHA_SRC_PATH" ];then
330 if ask_yn "$KOHA_SRC_PATH still exists. use it ?"; then
331 ask_yn "download the sources again ?" ||
337 [ -d "$KOHA_SRC_DIR" ] ||
338 die 1 "$KOHA_SRC_DIR is not a directory"
341 # parsing arguments {{{
343 # TODO: this won't work with real bourne shell (use expr instead)
345 [ "$1" = *b* ] && GET_KOHA_SRC_METHOD=beta
346 [ "$1" = *t* ] && GET_KOHA_SRC_METHOD=tar
347 [ "$1" = *c* ] && DEBIAN_STILL_CONFIGURED=yes
352 cd $KOHA_SRC_PATH && return 0
357 for candidate in koha?*; do
358 if [ $done = no ]; then
359 mv $candidate $KOHA_SRC_BASE
361 die 1 "more than one koha candidate into $KOHA_SRC_DIR, please clean up"
364 cd $KOHA_SRC_PATH && die 1 "can't cd to $KOHA_SRC_PATH"
367 mysql_create_base () {
368 # TODO: what if non mysql backend ? so code !
369 # try to create or try to find the base
370 mysqladmin -uroot create "$1" ||
371 echo show databases |
376 mysql_grant_access () {
377 local base login password
378 base="$1" login="$2" password="$3"
379 cat << GRANTACCESS | mysql
380 grant all on $base.* to '$login'@'localhost' identified by '$password';
385 verify_etch_sources () {
387 current=/etc/apt/sources.list
388 backup=/etc/apt/sources.list.bak
389 if [ ! -e $current ] || [ ! -s $current ]; then
390 [ -e $backup ] && mv $backup $current || die 1 "can't find etch"
397 [ "$PLEASE_DONT_GET" ] ||
398 get_koha_sources "$KOHA_SRC_BASE" "$GET_KOHA_SRC_METHOD" > $GET_KOHA_LOG 2>&1 &
400 [ $DEBIAN_STILL_CONFIGURED ] || {
401 configure_indexdata_sources # to install yaz and iezebra
402 configure_lenny # because etch lacks some packages
403 configure_aptitude_correctly # to solve dependancies and conflicts
411 open_package_list # now we can add packages with add_package command
412 # this would be installed by dependances but it needs to be
413 # installed first to autoconfigure perl sax parser
414 add_package libxml-libxml-perl
415 # libyaz-dev required to build Net::Z3950::ZOOM from cpan
416 # can be removed when debian package will be usefull
417 add_package libyaz-dev
418 # lot of koha dependancies
419 cat << PACKAGES | add_package
422 libmail-sendmail-perl
423 libhtml-scrubber-perl
424 libmarc-record-perl/testing
425 libmarc-charset-perl/testing
426 libmarc-crosswalk-dublincore-perl
428 libpdf-reuse-barcode-perl
430 libxml-rss-perl/testing
444 libdatetime-format-mail-perl
446 libdatetime-format-strptime-perl
447 libdatetime-format-w3cdtf-perl
454 libtext-csv-perl/testing
455 libtext-charwidth-perl
456 libtime-duration-perl
463 libxml-xslt-perl/testing
468 libhtml-template-pro-perl
469 libdbd-mysql-perl/testing
471 liblist-moreutils-perl
472 libtext-iconv-perl/testing
473 libalgorithm-checkdigits-perl
477 # no more "path not found" message during cpan configuration
478 add_package unzip lynx ncftp ftp
480 # just because it ease the life of the sysop
481 add_package screen zsh less lsof strace
483 # every selected packages will now be installed
485 # something wrong with libyaz-dev... KISS workaround is reinstall
486 aptitude install libyaz-dev
488 # those perl libs have no statisfying debian packages
489 # so they are installed via cpan.
490 cpan Net::Z3950::ZOOM Biblio::EndnoteStyle
492 getent passwd $KOHA_USER ||
493 create_debian_koha_user $KOHA_USER ||
494 die 1 "can't create $KOHA_USER"
496 mysql_create_base "$DB_NAME" ||
497 die 1 "can't create or find $DB_NAME"
498 mysql_grant_access "$DB_NAME" "$DB_USER" "$DB_PASS" ||
499 die 1 "can't grant access to $DB_USER"
501 echo "please wait while i'm downloading koha sources"
514 sed -n ' s/^'"$1"' = //T;p;q' Makefile
517 koha_conf=`makefile_value KOHA_DEST_KOHA_CONF_DIR`
518 ln -s "$koha_conf"/koha-httpd.conf /etc/apache2/sites-available/koha
522 invoke-rc.d apache2 reload
524 koha_script=`makefile_value KOHA_DEST_SCRIPT_DIR`
525 ln -s "$koha_script"/koha-zebraqueue-ctl.sh /etc/init.d/koha-zebraqueue-daemon
526 update-rc.d koha-zebraqueue-daemon defaults
530 # if cd misc/translator; then
531 # ./tmpl_process3 install -s po/fr-FR... -i ../../koha-tmpl/opac-tmpl/prog/en -o ../../koha-tmpl/opac-tmpl/prog/fr-FR