Skip to content

Commit

Permalink
Bug 16974: Make koha-plack should check and fix log files permissions
Browse files Browse the repository at this point in the history
This patch adds a function to the koha-plack script so it checks for log file
existence and its permissions. This function is called from the start_plack function.

If some of this conditions are not fulfilled, it solves the situation by either
touching and/or changing the permissions accordingly for the instances' plack log files.

To test:
- Run (on kohadevbox):
  $ cd kohaclone
  $ debian/scripts/koha-plack --start kohadev
  $ debian/scripts/koha-plack --stop  kohadev
  $ ls /var/log/koha/kohadev/plack*
- Verify ownership of the created files (they might belong to the root user)
- Apply the patch
- Run:
  $ chown root:root /var/log/koha/kohadev/plack*
  $ debian/scripts/koha-plack --start kohadev
  $ ls /var/log/koha/kohadev/plack*
=> SUCCESS: Files belong to kohadev-koha:kohadev-koha
- Run:
  $ debian/scripts/koha-plack --stop  kohadev
  $ rm /var/log/koha/kohadev/plack*
  $ debian/scripts/koha-plack --start kohadev
  $ ls /var/log/koha/kohadev/plack*
=> SUCCESS: Files are created and belong to kohadev-koha:kohadev-koha
- Sign off :-D

Signed-off-by: Mirko Tietgen <[email protected]>

Signed-off-by: Jonathan Druart <[email protected]>

Signed-off-by: Kyle M Hall <[email protected]>
  • Loading branch information
tomascohen authored and kylemhall committed Aug 17, 2016
1 parent ac4a058 commit 007d2fe
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions debian/scripts/koha-plack
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ start_plack()
PSGIFILE="/etc/koha/sites/${instancename}/plack.psgi"
fi # else stick with the default one

_check_and_fix_perms $instancename

STARMANOPTS="-M FindBin --max-requests 50 --workers 2 \
--user=${instancename}-koha --group ${instancename}-koha \
--pid ${PIDFILE} \
Expand Down Expand Up @@ -204,6 +206,22 @@ EOM
fi
}

_check_and_fix_perms()
{
local instance=$1

local files="/var/log/koha/${instance}/plack.log \
/var/log/koha/${instance}/plack-error.log"

for file in ${files}
do
if [ ! -e "${file}" ]; then
touch ${file}
fi
chown "${instance}-koha":"${instance}-koha" ${file}
done
}

set_action()
{
if [ "$op" = "" ]; then
Expand Down

0 comments on commit 007d2fe

Please sign in to comment.