File obs-server-2.10-0017-api-Make-api-log-directory-configurable.patch of Package obs-server

From ce75ad29bed974d96e0977d91ade5a106189ef6f Mon Sep 17 00:00:00 2001
From: Oleg Girko <ol@infoserver.lv>
Date: Sun, 17 Jul 2016 01:01:31 +0100
Subject: [PATCH] [api] Make api log directory configurable.

This change adds OBS_API_LOG_DIR configuration parameter
to Makefile.include that specifies directory where api (and webui)
logs will be written.

Some distributions (like Fedora) have giudelines stating that
logs should be written in /var/log directory.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
---
 Makefile.include | 1 +
 src/api/Makefile | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/Makefile.include b/Makefile.include
index 73d290e6dd..4291094421 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -8,6 +8,7 @@ OBS_BACKEND_LOG_DIR=$(OBS_BACKEND_DATA_DIR)/log
 OBS_BACKEND_SERVICE_LOG_DIR=$(OBS_BACKEND_DATA_DIR)/service/log
 OBS_DOCUMENT_ROOT=/srv/www/obs
 OBS_API_PREFIX=$(OBS_DOCUMENT_ROOT)/api
+OBS_API_LOG_DIR=$(OBS_API_PREFIX)/log
 OBS_APIDOCS_PREFIX=$(OBS_DOCUMENT_ROOT)/docs
 OBS_FILLUP_DIR=/var/adm/fillup-templates
 OBS_FILLUP_FILE=sysconfig.obs-server
diff --git a/src/api/Makefile b/src/api/Makefile
index 2d5fee37cf..7984b2aef3 100644
--- a/src/api/Makefile
+++ b/src/api/Makefile
@@ -6,6 +6,14 @@ OBS_API_LOGS := access.log backend_access.log delayed_job.log error.log lasteven
 all:
 
 install: prepare_dirs prepare_rake docs config log_files build
+ifneq ($(OBS_API_LOG_DIR),$(OBS_API_PREFIX)/log)
+	$(INSTALL) -d -m 755 $(DESTDIR)$(OBS_API_LOG_DIR)
+	test -n "`ls -A $(DESTDIR)$(OBS_API_PREFIX)/log`" && \
+	    mv $(DESTDIR)$(OBS_API_PREFIX)/log/* \
+	       $(DESTDIR)$(OBS_API_LOG_DIR) || :
+	rmdir $(DESTDIR)$(OBS_API_PREFIX)/log
+	ln -s $(OBS_API_LOG_DIR) $(DESTDIR)$(OBS_API_PREFIX)/log
+endif
 
 prepare_dirs:
 	$(INSTALL) -d -m 755 $(DESTDIR)$(OBS_API_PREFIX)
-- 
2.31.1