From ca03e2c193e4abd4f8df5cc4a928f469ae37c3f6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 3 May 2018 17:10:33 -0300 Subject: [PATCH] Bug 20692: Return and display and error if koha-plack failed If koha-plack did not comment/uncomment the line it should fails and display an error instead of success. Useful for old apache config files --- debian/scripts/koha-plack | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/debian/scripts/koha-plack b/debian/scripts/koha-plack index 1677ee0ec1..1726a054cc 100755 --- a/debian/scripts/koha-plack +++ b/debian/scripts/koha-plack @@ -178,8 +178,19 @@ enable_plack() 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" + + if grep -q '^\s*#\(\s*Include /etc/koha/apache-shared-opac-plack.conf\)$' "$instancefile"; then + sed -i 's:^\s*#\(\s*Include /etc/koha/apache-shared-opac-plack.conf\)$:\1:' "$instancefile" + else + warn "Cannot enable plack for opac - update your apache config files" + return 1 + fi + if grep -q '^\s*#\(\s*Include /etc/koha/apache-shared-intranet-plack.conf\)$' "$instancefile"; then + sed -i 's:^\s*#\(\s*Include /etc/koha/apache-shared-intranet-plack.conf\)$:\1:' "$instancefile" + else + warn "Cannot enable plack for intranet -- update your apache config files" + return 1 + fi [ "${quiet}" != "yes" ] && warn "Plack enabled for ${instancename}" return 0 else @@ -195,8 +206,18 @@ disable_plack() if is_plack_enabled $instancename; then # Comment out the plack related lines for OPAC and intranet - sed -i 's:^\(\s*Include /etc/koha/apache-shared-opac-plack.conf\)$:#\1:' "$instancefile" - sed -i 's:^\(\s*Include /etc/koha/apache-shared-intranet-plack.conf\)$:#\1:' "$instancefile" + if grep -q '^\(\s*Include /etc/koha/apache-shared-opac-plack.conf\)$' "$instancefile"; then + sed -i 's:^\(\s*Include /etc/koha/apache-shared-opac-plack.conf\)$:#\1:' "$instancefile" + else + warn "Cannot disable plack for opac - update your apache config files" + return 1 + fi + if grep -q '^\(\s*Include /etc/koha/apache-shared-intranet-plack.conf\)$' "$instancefile"; then + sed -i 's:^\(\s*Include /etc/koha/apache-shared-intranet-plack.conf\)$:#\1:' "$instancefile" + else + warn "Cannot disable plack for intranet - update your apache config files" + return 1 + fi [ "${quiet}" != "yes" ] && warn "Plack disabled for ${instancename}" return 0 else -- 2.11.0