File obs-server-2.9-0018-dist-api-backend-Make-backend-ports-configurable.patch of Package obs-server

From f2efaeefa75d78ebf12b2c062b95190421ec81c2 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 36c1a5a7e4..94b8cc3b66 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -11,6 +11,9 @@ OBS_APIDOCS_PREFIX=$(OBS_DOCUMENT_ROOT)/docs
 OBS_FILLUP_DIR=/var/adm/fillup-templates
 OBS_FILLUP_FILE=sysconfig.obs-server
 OBS_DEVEL_DOC_DIR=/usr/share/doc/packages/obs-devel
+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 897106f47f..6eb5772e50 100644
--- a/dist/Makefile
+++ b/dist/Makefile
@@ -41,6 +41,9 @@ install_initscripts: system_dirs
 	    -e 's|wwwrun:www|$(APACHE_USER):$(APACHE_GROUP)|g' \
 	    -e 's|/srv/www/obs/api|$(OBS_API_PREFIX)|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)|' \
 	    $(INIT_SCRIPTS:%=$(DESTDIR)$(INITDDIR)/%)
 
 install_systemd_services: system_dirs
@@ -64,11 +67,19 @@ install_fillups: system_dirs
 	    $(DESTDIR)$(OBS_FILLUP_DIR)/$(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)$(OBS_FILLUP_DIR)/$(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)) )
diff --git a/src/api/Makefile b/src/api/Makefile
index 918c4c216c..7919497b71 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 9e9f621f0b..a08f45cb3a 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.20.1