From b1138d677606483abe013a3de7c6cb1e3c5326b2 Mon Sep 17 00:00:00 2001
From: Sergey Yakubov <sergey.yakubov@desy.de>
Date: Mon, 2 Jul 2018 12:31:43 +0200
Subject: [PATCH] nomad and consul packages

---
 deploy/nomad_consul/CMakeLists.txt          | 42 +++++++++++++++++++++
 deploy/nomad_consul/Packages/CMakeLists.txt | 29 ++++++++++++++
 deploy/nomad_consul/Packages/postinst       |  3 ++
 3 files changed, 74 insertions(+)
 create mode 100644 deploy/nomad_consul/CMakeLists.txt
 create mode 100644 deploy/nomad_consul/Packages/CMakeLists.txt
 create mode 100755 deploy/nomad_consul/Packages/postinst

diff --git a/deploy/nomad_consul/CMakeLists.txt b/deploy/nomad_consul/CMakeLists.txt
new file mode 100644
index 000000000..3ae6016ea
--- /dev/null
+++ b/deploy/nomad_consul/CMakeLists.txt
@@ -0,0 +1,42 @@
+cmake_minimum_required(VERSION 3.5)
+
+PROJECT(ASAPO_HA)
+
+add_subdirectory (Packages)
+
+INCLUDE(ExternalProject)
+ExternalProject_Add(
+        consul
+        URL https://releases.hashicorp.com/consul/1.2.0/consul_1.2.0_linux_amd64.zip
+        PATCH_COMMAND ""
+        CONFIGURE_COMMAND ""
+        CMAKE_COMMAND ""
+        BUILD_IN_SOURCE 1
+        BUILD_COMMAND ""
+        INSTALL_COMMAND ""
+)
+
+ExternalProject_Add(
+        nomad
+        URL https://releases.hashicorp.com/nomad/0.8.4/nomad_0.8.4_linux_amd64.zip
+        PATCH_COMMAND ""
+        CONFIGURE_COMMAND ""
+        CMAKE_COMMAND ""
+        BUILD_IN_SOURCE 1
+        BUILD_COMMAND ""
+        INSTALL_COMMAND ""
+)
+
+
+ExternalProject_Get_Property(consul SOURCE_DIR)
+set (CONSUL_SOURCE_DIR ${SOURCE_DIR})
+ExternalProject_Get_Property(nomad SOURCE_DIR)
+set (NOMAD_SOURCE_DIR ${SOURCE_DIR})
+
+install(PROGRAMS ${CONSUL_SOURCE_DIR}/consul DESTINATION bin)
+install(PROGRAMS ${NOMAD_SOURCE_DIR}/nomad DESTINATION bin)
+
+install(PROGRAMS ${NOMAD_SOURCE_DIR}/nomad DESTINATION bin)
+
+install(DIRECTORY ${CMAKE_SOURCE_DIR}/usr/lib/systemd/system/
+        DESTINATION  /usr/lib/systemd/system)
\ No newline at end of file
diff --git a/deploy/nomad_consul/Packages/CMakeLists.txt b/deploy/nomad_consul/Packages/CMakeLists.txt
new file mode 100644
index 000000000..b50b9696a
--- /dev/null
+++ b/deploy/nomad_consul/Packages/CMakeLists.txt
@@ -0,0 +1,29 @@
+# create debian package
+
+SET(CPACK_BINARY_DEB ON)
+SET(CPACK_BINARY_RPM ON)
+
+#SET (CPACK_DEBIAN_PACKAGE_MAINTAINER "Sergey Yakubov (sergey.yakubov@desy.de)")
+#SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
+
+SET (CPACK_PACKAGE_CONTACT "Sergey Yakubov (sergey.yakubov@desy.de)")
+SET(CPACK_PACKAGE_ARCHITECTURE "amd64")
+
+
+SET(CPACK_PACKAGE_NAME "asapo-ha")
+SET(CPACK_PACKAGE_VENDOR "DESY")
+SET(CPACK_PACKAGE_VERSION_MAJOR "1")
+SET(CPACK_PACKAGE_VERSION_MINOR "2")
+SET(CPACK_PACKAGE_VERSION_PATCH "2")
+
+SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Nomad and Consul for Asapo Debian package")
+
+SET(CPACK_BINARY_STGZ OFF)
+SET(CPACK_BINARY_TBZ2 OFF)
+SET(CPACK_BINARY_TGZ OFF)
+SET(CPACK_BINARY_TZ OFF)
+SET(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/postinst")
+set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/postinst")
+
+INCLUDE(CPack)
+
diff --git a/deploy/nomad_consul/Packages/postinst b/deploy/nomad_consul/Packages/postinst
new file mode 100755
index 000000000..54d8d8ac7
--- /dev/null
+++ b/deploy/nomad_consul/Packages/postinst
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+useradd -r -s /bin/false asapo || true
-- 
GitLab