[Koha] koha-plack --enable does not enable plack when plack has never been enabled

www retive wwwretive at yahoo.fr
Thu Jan 21 02:30:51 NZDT 2016

When running koha-plack --enable, the script assumes that there is already
a commented line that includes the plack configuration in the apache virtual host's
config of the instance :

(from /usr/sbin/koha-plack line 148) :

           sed -i 's:^\s*#\(\s*Include /etc/koha/apache-shared-opac-plack.conf\)$:\1:' "$instancefile"
           sed -i 's:^\s*#\(\s*Include /etc/koha/apache-shared-intranet-plack.conf\)$:\1:' "$instancefile"

For old fashioned installs this is not always the case. In my config (we've set up koha 3 years ago) i had to put the line directly in the apache virtual host config.

Since the included files use the ${instance} variable, i had to define that variable as well :

       Define instance myinstancename

It is possible to find where the "/etc/koha/apache-shared-{opac,intranet}.conf" files
are included and add the two relevant lines :

--- a/koha-plack
+++ b/koha-plack
@@ -144,9 +144,9 @@ enable_plack()
local instancefile=$(get_apache_config_for "$instancename")

if ! is_plack_enabled $instancename; then
-        # Uncomment the plack related lines for OPAC and intranet
-        sed -i 's:^\s*#\(\s*Include /etc/koha/apache-shared-opac-plack.conf\)$:\1:' "$instancefile"
-        sed -i 's:^\s*#\(\s*Include /etc/koha/apache-shared-intranet-plack.conf\)$:\1:' "$instancefile"
+        # Add the plack related lines for OPAC and intranet and define the instance name in vhost
+        sed -i "s:^\(\s*\)\(Include /etc/koha/apache-shared-opac.conf\):\1\2\n\1Define instance $instancename\n\1Include /etc/koha/apache-shared-opac-plack.conf:" "$instancefile"
+        sed -i "s:^\(\s*\)\(Include /etc/koha/apache-shared-intranet.conf\):\1\2\n\1Define instance $instancename\n\1Include /etc/koha/apache-shared-intranet-plack.conf:" "$instancefile"
[ "${quiet}" != "yes" ] && warn "Plack enabled for ${instancename}"
return 0

Philippe K.

More information about the Koha mailing list