File obs-server-2.10-0015-dist-api-backend-Make-backend-ports-configurable.patch of Package obs-server

From e67f61be7dd832a819bcbdc833f8254c0ba7b8f2 Mon Sep 17 00:00:00 2001
From: Oleg Girko <ol@infoserver.lv>
Date: Thu, 14 Jul 2016 13:37:47 +0100
Subject: [PATCH] [dist][api][backend] Make backend ports configurable.

This change adds the following configuration parameters to Makefile.include:
* OBS_SRCSERVER_PORT - source server port,
* OBS_REPOSERVER_PORT - repository server port,
* OBS_SERVICESERVER_PORT - service server port.

These parameters specify deafult ports to be used after installation
instead of hardcoded values of 5352, 5252 and 5152 respectively.

This is needed because some distributions can have these port numbers
reserved for something else.
For example, Fedora uses port 5252 for milter-greylist.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
---
 Makefile.include     |  3 +++
 dist/Makefile        | 11 +++++++++++
 src/api/Makefile     |  4 ++++
 src/backend/Makefile |  3 +++
 4 files changed, 21 insertions(+)

diff --git a/Makefile.include b/Makefile.include
index 33a74356f9..d79a819f97 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -9,6 +9,9 @@ OBS_API_PREFIX=$(OBS_DOCUMENT_ROOT)/api
 OBS_APIDOCS_PREFIX=$(OBS_DOCUMENT_ROOT)/docs
 OBS_FILLUP_DIR=/var/adm/fillup-templates
 OBS_FILLUP_FILE=sysconfig.obs-server
+OBS_SRCSERVER_PORT=5352
+OBS_REPOSERVER_PORT=5252
+OBS_SERVICESERVER_PORT=5152
 
 # TODO: find fix for RH in spec/Makefile
 # This here is preparation for multi distro support
diff --git a/dist/Makefile b/dist/Makefile
index 4b39bc1d12..c88de86528 100644
--- a/dist/Makefile
+++ b/dist/Makefile
@@ -61,11 +61,19 @@ install_fillups: system_dirs
 	    $(DESTDIR)$(FILLUPDIR)/$(OBS_FILLUP_FILE)
 	sed -i \
 	    -e 's|/srv/obs|$(OBS_BACKEND_DATA_DIR)|g' \
+	    -e 's|5352|$(OBS_SRCSERVER_PORT)|' \
+	    -e 's|5252|$(OBS_REPOSERVER_PORT)|' \
+	    -e 's|5152|$(OBS_SERVICESERVER_PORT)|' \
 	    $(DESTDIR)$(FILLUPDIR)/$(OBS_FILLUP_FILE)
 
 install_slp: system_dirs
 	$(INSTALL) -m 644 obs.source_server.reg $(DESTDIR)/etc/slp.reg.d/
 	$(INSTALL) -m 644 obs.repo_server.reg $(DESTDIR)/etc/slp.reg.d/
+	sed -i \
+	    -e 's|5352|$(OBS_SRCSERVER_PORT)|' \
+	    -e 's|5252|$(OBS_REPOSERVER_PORT)|' \
+	    $(DESTDIR)/etc/slp.reg.d/obs.source_server.reg \
+	    $(DESTDIR)/etc/slp.reg.d/obs.repo_server.reg
 
 install_obs_bin: system_dirs
 	$(foreach script,$(OBS_BIN_SCRIPTS),$(shell $(INSTALL) -m 755 $(script) $(DESTDIR)$(BINDIR)/$(script)) )
@@ -73,6 +81,9 @@ install_obs_bin: system_dirs
 	sed -i \
 	    -e 's|/srv/obs/log|$(OBS_BACKEND_LOG_DIR)|g' \
 	    -e 's|/srv/obs|$(OBS_BACKEND_DATA_DIR)|g' \
+	    -e 's|5352|$(OBS_SRCSERVER_PORT)|' \
+	    -e 's|5252|$(OBS_REPOSERVER_PORT)|' \
+	    -e 's|5152|$(OBS_SERVICESERVER_PORT)|' \
 	    $(OBS_BIN_SCRIPTS:%=$(DESTDIR)$(BINDIR)/%) \
 	    $(OBS_SBIN_SCRIPTS:%=$(DESTDIR)$(SBINDIR)/%)
 
diff --git a/src/api/Makefile b/src/api/Makefile
index 867483949d..2d5fee37cf 100644
--- a/src/api/Makefile
+++ b/src/api/Makefile
@@ -43,6 +43,10 @@ config: prepare_dirs
 	echo "# This is to prevent fdupes from hardlinking" >> $(DESTDIR)$(OBS_API_PREFIX)/config/database.yml
 	echo "# This is to prevent fdupes from hardlinking" >> $(DESTDIR)$(OBS_API_PREFIX)/config/options.yml
 	echo "# This is to prevent fdupes from hardlinking" >> $(DESTDIR)$(OBS_API_PREFIX)/config/thinking_sphinx.yml
+	sed -i \
+	    -e 's|5352|$(OBS_SRCSERVER_PORT)|' \
+	    $(DESTDIR)$(OBS_API_PREFIX)/config/options.yml \
+	    $(DESTDIR)$(OBS_API_PREFIX)/config/options.yml.example
 
 log_files:
 	$(foreach logfile,$(OBS_API_LOGS),$(shell touch $(DESTDIR)$(OBS_API_PREFIX)/log/$(logfile) ))
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 076087f9ca..79db37065d 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -24,6 +24,9 @@ install: prepare_dirs install_data_dirs bs_config
 	sed -i \
 	    -e 's|/srv/www/obs/api|$(OBS_API_PREFIX)|' \
 	    -e 's|/srv/obs|$(OBS_BACKEND_DATA_DIR)|' \
+	    -e 's|5352|$(OBS_SRCSERVER_PORT)|' \
+	    -e 's|5252|$(OBS_REPOSERVER_PORT)|' \
+	    -e 's|5152|$(OBS_SERVICESERVER_PORT)|' \
 	    $(DESTDIR)$(OBS_BACKEND_PREFIX)/bs_* \
 	    $(DESTDIR)$(OBS_BACKEND_PREFIX)/*.pm \
 	    $(DESTDIR)$(OBS_BACKEND_PREFIX)/*.pm.template \
-- 
2.31.1