From 4994d69d1aaf8efa01490fbea450e5b8d35b072e Mon Sep 17 00:00:00 2001
From: Julien Leduc <julien.leduc@cern.ch>
Date: Thu, 7 Feb 2019 13:27:39 +0100
Subject: [PATCH] Adding the needed components to create and install quarkDB

---
 .../cc7/etc/yum.repos.d/eos-quarkdb.repo      |  6 ++++++
 .../ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh |  3 +++
 .../cc7/opt/run/bin/start_quarkdb.sh          | 19 +++++++++++++++++++
 3 files changed, 28 insertions(+)
 create mode 100644 continuousintegration/docker/ctafrontend/cc7/etc/yum.repos.d/eos-quarkdb.repo
 create mode 100644 continuousintegration/docker/ctafrontend/cc7/opt/run/bin/start_quarkdb.sh

diff --git a/continuousintegration/docker/ctafrontend/cc7/etc/yum.repos.d/eos-quarkdb.repo b/continuousintegration/docker/ctafrontend/cc7/etc/yum.repos.d/eos-quarkdb.repo
new file mode 100644
index 0000000000..4c6f3a8583
--- /dev/null
+++ b/continuousintegration/docker/ctafrontend/cc7/etc/yum.repos.d/eos-quarkdb.repo
@@ -0,0 +1,6 @@
+[eos-quarkdb]
+name=EOS QuarkDB Repository
+baseurl=http://storage-ci.web.cern.ch/storage-ci/quarkdb/tag/el7/x86_64/
+gpgcheck=0
+enabled=0
+priority=5
diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh
index 7f29b13cff..c9b4da28c7 100755
--- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh
+++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/ctaeos-mgm.sh
@@ -57,6 +57,9 @@ echo "mgmofs.protowfresource /ctafrontend"  >> /etc/xrd.cf.mgm
 # Add configmap based configuration (initially Namespace)
 test -f /etc/config/eos/xrd.cf.mgm && cat /etc/config/eos/xrd.cf.mgm >> /etc/xrd.cf.mgm
 
+# quarkDB only for systemd initially...
+cat /etc/config/eos/xrd.cf.mgm | grep mgmofs.nslib | grep -qi eosnsquarkdb && /opt/run/bin/start_quarkdb.sh
+
 # prepare eos startup
   # skip systemd for eos initscripts
     export SYSTEMCTL_SKIP_REDIRECT=1
diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/start_quarkdb.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/start_quarkdb.sh
new file mode 100644
index 0000000000..3cb8b21d9f
--- /dev/null
+++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/start_quarkdb.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+QUARKDB_CONFIG=/etc/config/eos/xrootd-quarkdb.cfg
+
+QUARKDB_DIRECTORY=$(cat ${QUARKDB_CONFIG} | grep redis.database | sed -e 's/.*redis.database\ \+//')
+
+yum-config-manager --enable eos-quarkdb
+
+yum install -y quarkdb
+
+quarkdb-create --path ${QUARKDB_DIRECTORY}
+
+chown -R xrootd:xrootd ${QUARKDB_DIRECTORY}
+
+cp -f ${QUARKDB_CONFIG} /etc/xrootd/xrootd-quarkdb.cfg
+
+systemctl start xrootd@quarkdb
+
+systemctl status xrootd@quarkdb
-- 
GitLab