Bug 11034: remove incorrect return for BiblioAutoLink
[koha.git] / debian / scripts / koha-enable
blobc0bbfa26272c0db09b28006887cbd2bf5c716de0
1 #!/bin/sh
3 # koha-enable -- enable a Koha instance.
4 # Copyright 2010 Catalyst IT, Ltd
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 set -e
23 die()
25 echo "$@" 1>&2
26 exit 1
29 warn()
31 echo "$@" 1>&2
34 is_enabled()
36 local instancename=$1
38 if ! is_instance $instancename; then
39 return 1
42 if grep -q '^[[:space:]]*Include /etc/koha/apache-shared-disable.conf' \
43 "/etc/apache2/sites-available/$instancename" ; then
44 return 1
45 else
46 return 0
50 is_instance()
52 local instancename=$1
54 if find /etc/koha/sites -mindepth 1 -maxdepth 1 \
55 -type d -printf '%f\n'\
56 | grep -q -x $instancename ; then
57 return 0
58 else
59 return 1
63 enable_instance()
65 local instancename=$1
67 if ! is_enabled $instancename; then
68 sed -i 's:^\(\s*Include /etc/koha/apache-shared-disable.conf\)$:#\1:' \
69 "/etc/apache2/sites-available/$instancename"
70 return 0
71 else
72 return 1
76 usage()
78 local scriptname=$0
79 cat <<EOF
80 Enables Koha instances.
82 Usage: $scriptname instancename1 instancename2...
84 EOF
87 # Parse command line.
88 [ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
90 restart_apache="no"
92 for name in "$@"
94 if is_instance $name ; then
95 if enable_instance $name; then
96 restart_apache="yes"
97 else
98 warn "Instance $name already enabled."
100 else
101 warn "Unknown instance $name."
103 done
105 if [ "$restart_apache" = "yes" ]; then
106 /etc/init.d/apache2 restart
109 exit 0