View | Details | Raw Unified | Return to bug 12805
Collapse All | Expand All

(-)a/debian/scripts/koha-disable-plugins (+77 lines)
Line 0 Link Here
1
#!/bin/sh
2
#
3
# koha-disable-plugins -- Disable Koha's KPZ plugin system
4
# Copyright (c) 2014 :    Indranil Das Gupta / L2C2 Technologies
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.
10
#
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.
15
#
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/>.
18
19
set -e
20
21
# include helper functions
22
if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
23
    . "/usr/share/koha/bin/koha-functions.sh"
24
else
25
    echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
26
    exit 1
27
fi
28
29
disable_plugins()
30
{
31
    local instancename=$1
32
    local kohaconf="/etc/koha/sites/${instancename}/koha-conf.xml"
33
34
    local tmpfile=/tmp/${instancename}_koha-conf.xml
35
    
36
    xmlstarlet ed -u '/yazgfs/config/enable_plugins' \
37
        -v 0 /etc/koha/sites/${name}/koha-conf.xml > ${tmpfile}
38
    
39
    cp -v ${tmpfile} /etc/koha/sites/${name}/koha-conf.xml
40
    
41
    chmod 640 /etc/koha/sites/${name}/koha-conf.xml
42
    
43
    chgrp ${instancename}-koha /etc/koha/sites/${name}/koha-conf.xml
44
    
45
    rm ${tmpfile}
46
    
47
    echo "Disabled Koha plugins for instance $instancename."
48
}
49
50
usage()
51
{
52
    local scriptname=$0
53
    cat <<EOF
54
Disables Koha plugins system for specified Koha instances.
55
56
Usage: $scriptname instancename1 instancename2...
57
58
EOF
59
}
60
61
# Parse command line.
62
[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
63
64
for name in "$@"
65
do
66
    if  is_instance ${name}; then
67
        if is_pluginsdir_enabled ${name}; then
68
            disable_plugins ${name}
69
        else
70
            warn "Plugins already disabled for instance ${name}"
71
        fi
72
    else
73
        warn "Unknown instance $name."
74
    fi
75
done
76
77
exit 0
(-)a/debian/scripts/koha-enable-plugins (+77 lines)
Line 0 Link Here
1
#!/bin/sh
2
#
3
# koha-enable-plugins -- Enable Koha's KPZ plugin system
4
# Copyright (c) 2014 :   Indranil Das Gupta / L2C2 Technologies
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.
10
#
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.
15
#
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/>.
18
19
set -e
20
21
# include helper functions
22
if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
23
    . "/usr/share/koha/bin/koha-functions.sh"
24
else
25
    echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
26
    exit 1
27
fi
28
29
enable_plugins()
30
{
31
    local instancename=$1
32
    local kohaconf="/etc/koha/sites/${instancename}/koha-conf.xml"
33
34
    local tmpfile=/tmp/${instancename}_koha-conf.xml
35
    
36
    xmlstarlet ed -u '/yazgfs/config/enable_plugins' \
37
        -v 1 /etc/koha/sites/${name}/koha-conf.xml > ${tmpfile}
38
    
39
    cp -v ${tmpfile} /etc/koha/sites/${name}/koha-conf.xml
40
    
41
    chmod 640 /etc/koha/sites/${name}/koha-conf.xml
42
    
43
    chgrp ${instancename}-koha /etc/koha/sites/${name}/koha-conf.xml
44
    
45
    rm ${tmpfile}
46
    
47
    echo "Enabled Koha plugins for instance $instancename."
48
}
49
50
usage()
51
{
52
    local scriptname=$0
53
    cat <<EOF
54
Enables Koha plugins system for specified Koha instances.
55
56
Usage: $scriptname instancename1 instancename2...
57
58
EOF
59
}
60
61
# Parse command line.
62
[ $# -ge 1 ] || ( usage ; die "Missing instance name..." )
63
64
for name in "$@"
65
do
66
    if  is_instance ${name}; then
67
        if ! is_pluginsdir_enabled ${name}; then
68
            enable_plugins ${name}
69
        else
70
            warn "Plugins already enabled for instance ${name}"
71
        fi
72
    else
73
        warn "Unknown instance $name."
74
    fi
75
done
76
77
exit 0
(-)a/debian/scripts/koha-functions.sh (+21 lines)
Lines 17-22 Link Here
17
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
18
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
19
20
# 2014-08-22 : Added is_pluginsdir_enabled() -  Indranil Das Gupta /
21
#                                               L2C2 Technologies
20
22
21
die()
23
die()
22
{
24
{
Lines 121-126 is_indexer_running() Link Here
121
    fi
123
    fi
122
}
124
}
123
125
126
is_pluginsdir_enabled()
127
{
128
    local instancename=$1
129
    
130
    if [ -e /var/lib/koha/$instancename/plugins ]; then
131
            local pluginsenabled=`xmlstarlet sel -t -m \
132
                '/yazgfs/config/enable_plugins' \
133
                -v . /etc/koha/sites/$instancename/koha-conf.xml`
134
            
135
            if [ $pluginsenabled == "1" ]; then
136
                return 0
137
            else
138
                return 1
139
            fi      
140
    else
141
        return 1
142
    fi
143
}
144
124
get_instances()
145
get_instances()
125
{
146
{
126
    find /etc/koha/sites -mindepth 1 -maxdepth 1\
147
    find /etc/koha/sites -mindepth 1 -maxdepth 1\
(-)a/debian/scripts/koha-list (-7 / +43 lines)
Lines 32-56 show_instances() Link Here
32
    local show=$1
32
    local show=$1
33
    local show_email=$2
33
    local show_email=$2
34
    local show_sip=$3
34
    local show_sip=$3
35
    local show_plugins=$4
35
36
36
    for instance in $( get_instances ); do
37
    for instance in $( get_instances ); do
37
        case $show in
38
        case $show in
38
          "all")
39
          "all")
39
              if instance_filter_email $instance $show_email && \
40
              if instance_filter_email $instance $show_email && \
40
                 instance_filter_sip $instance $show_sip; then
41
                 instance_filter_sip $instance $show_sip && \
42
                 instance_filter_plugins; then
41
                    echo $instance
43
                    echo $instance
42
              fi ;;
44
              fi ;;
43
          "enabled")
45
          "enabled")
44
              if is_enabled $instance; then
46
              if is_enabled $instance; then
45
                  if instance_filter_email $instance $show_email && \
47
                  if instance_filter_email $instance $show_email && \
46
                     instance_filter_sip $instance $show_sip; then
48
                     instance_filter_sip $instance $show_sip && \
49
                     instance_filter_plugins; then
47
                      echo $instance
50
                      echo $instance
48
                  fi
51
                  fi
49
              fi ;;
52
              fi ;;
50
          "disabled")
53
          "disabled")
51
              if ! is_enabled $instance; then
54
              if ! is_enabled $instance; then
52
                  if instance_filter_email $instance $show_email && \
55
                  if instance_filter_email $instance $show_email && \
53
                     instance_filter_sip $instance $show_sip; then
56
                     instance_filter_sip $instance $show_sip && \
57
                     instance_filter_plugins; then
54
                      echo $instance
58
                      echo $instance
55
                  fi
59
                  fi
56
              fi ;;
60
              fi ;;
Lines 58-64 show_instances() Link Here
58
    done
62
    done
59
}
63
}
60
64
61
62
instance_filter_sip()
65
instance_filter_sip()
63
{
66
{
64
    local instancename=$1
67
    local instancename=$1
Lines 103-108 instance_filter_email() Link Here
103
    return 1
106
    return 1
104
}
107
}
105
108
109
instance_filter_plugins()
110
{
111
    local instancename=$1
112
    local show_plugins=$2;
113
    
114
    case $show_plugins in
115
        "all")
116
            return 0 ;;
117
        "enabled")
118
            if is_pluginsdir_enabled $instancename; then
119
                return 0
120
            fi ;; 
121
        "disabled")
122
            if ! is_pluginsdir_enabled $instancename; then
123
                return 1
124
            fi ;;
125
    esac
126
}
127
106
set_show()
128
set_show()
107
{
129
{
108
    local show_param=$1
130
    local show_param=$1
Lines 136-141 set_show_sip() Link Here
136
    fi
158
    fi
137
}
159
}
138
160
161
set_show_plugins()
162
{
163
    local plugins_param=$1
164
165
    if [ "$show_plugins" = "all" ]; then
166
        show_plugins=$plugins_param
167
    else
168
        die "Error: --plugins and --noplugins are mutually exclusive."
169
    fi
170
}
171
139
usage()
172
usage()
140
{
173
{
141
    local scriptname=$0
174
    local scriptname=$0
Lines 152-157 Options: Link Here
152
    --noemail       Only show instances that do not have email enabled
185
    --noemail       Only show instances that do not have email enabled
153
    --sip           Only show instances that have SIP enabled
186
    --sip           Only show instances that have SIP enabled
154
    --nosip         Only show instances that do not have SIP enabled
187
    --nosip         Only show instances that do not have SIP enabled
188
    --plugins       Only show instances that have Koha plugins enabled
189
    --noplugins     Only show instances that do not have Koha plugins enabled
155
    --help | -h     Show this help
190
    --help | -h     Show this help
156
191
157
The filtering options can be combined, and you probably want to do this
192
The filtering options can be combined, and you probably want to do this
Lines 163-169 show="all" Link Here
163
show_email="all"
198
show_email="all"
164
show_sip="all"
199
show_sip="all"
165
200
166
args=$(getopt -l help,enabled,disabled,email,noemail,sip,nosip -o h -n $0 -- "$@")
201
args=$(getopt -l help,enabled,disabled,email,noemail,sip,nosip,plugins,noplugins -o h -n $0 -- "$@")
167
set -- $args
202
set -- $args
168
203
169
while [ ! -z "$1" ]
204
while [ ! -z "$1" ]
Lines 174-179 do Link Here
174
  --noemail) set_show_email "disabled" ;;
209
  --noemail) set_show_email "disabled" ;;
175
      --sip) set_show_sip "enabled" ;;
210
      --sip) set_show_sip "enabled" ;;
176
    --nosip) set_show_sip "disabled" ;;
211
    --nosip) set_show_sip "disabled" ;;
212
  --plugins) set_show_plugins "enabled" ;;
213
--noplugins) set_show_plugins "disabled" ;;
177
  --enabled) set_show "enabled" ;;
214
  --enabled) set_show "enabled" ;;
178
 --disabled) set_show "disabled" ;;
215
 --disabled) set_show "disabled" ;;
179
          *) break;;
216
          *) break;;
Lines 181-186 do Link Here
181
    shift
218
    shift
182
done
219
done
183
220
184
show_instances $show $show_email $show_sip
221
show_instances $show $show_email $show_sip $show_plugins
185
222
186
exit 0
223
exit 0
187
- 

Return to bug 12805