浏览代码

HPCC-19965 Check for declared component before service configuration

Signed-off-by: Michael Gardner <michael.gardner@lexisnexisrisk.com>
Michael Gardner 7 年之前
父节点
当前提交
3b26904e9e

+ 2 - 1
initfiles/bash/etc/systemd/system/configmgr-conf.service.in

@@ -7,5 +7,6 @@ Requires=hpcc-conf@configmgr.service
 Type=oneshot
 User=@RUNTIME_USER@
 Group=@RUNTIME_GROUP@
-ExecStartPre=/bin/mkdir -p @RUNTIME_PATH@/configmgr @LOG_PATH@/configmgr @PID_PATH@ @LOCK_PATH@/configmgr
+ExecStart=@ADMIN_PATH@/check-component-exists.sh %i
+ExecStart=/bin/mkdir -p @RUNTIME_PATH@/configmgr @LOG_PATH@/configmgr @PID_PATH@ @LOCK_PATH@/configmgr
 ExecStart=/bin/bash -c "/bin/cp @CONFIG_DIR@/configmgr/esp.xml @RUNTIME_PATH@/configmgr/esp.xml"

+ 1 - 0
initfiles/bash/etc/systemd/system/hpcc-conf@instance.service.in

@@ -6,6 +6,7 @@ After=network.target remote-fs.target
 Type=oneshot
 User=@RUNTIME_USER@
 Group=@RUNTIME_GROUP@
+ExecStart=@ADMIN_PATH@/check-component-exists.sh %i
 ExecStart=/bin/mkdir -p @RUNTIME_PATH@/%i @LOG_PATH@/%i @PID_PATH@ @LOCK_PATH@/%i
 ExecStart=@ADMIN_PATH@/configgen -env @CONFIG_DIR@/@ENV_XML_FILE@ -od @RUNTIME_PATH@ -id @COMPONENTFILES_PATH@/configxml -c %i
 ExecStart=/bin/bash -c '/bin/echo "PATH=$PATH:@EXEC_PATH@:@ADMIN_PATH@:@RUNTIME_PATH@/%i" > @RUNTIME_PATH@/%i/%i.cfg'

+ 2 - 1
initfiles/bash/etc/systemd/system/thor-conf@instance.service.in

@@ -7,5 +7,6 @@ Requires=hpcc-conf@%i.service
 Type=oneshot
 User=@RUNTIME_USER@
 Group=@RUNTIME_GROUP@
-ExecStartPre=/bin/mkdir -p @RUNTIME_PATH@/%i @LOG_PATH@/%i @PID_PATH@ @LOCK_PATH@/%i
+ExecStart=@ADMIN_PATH@/check-component-exists.sh %i
+ExecStart=/bin/mkdir -p @RUNTIME_PATH@/%i @LOG_PATH@/%i @PID_PATH@ @LOCK_PATH@/%i
 ExecStart=/bin/bash -c "/bin/sed -e 's/export //g' @RUNTIME_PATH@/%i/setvars >> @RUNTIME_PATH@/%i/%i.cfg"

+ 1 - 0
initfiles/sbin/CMakeLists.txt

@@ -27,6 +27,7 @@ GENERATE_BASH(processor ${bash-vars} "hpcc-push.sh.in" outFiles)
 GENERATE_BASH(processor ${bash-vars} "hpcc-run.sh.in" outFiles)
 GENERATE_BASH(processor ${bash-vars} "remote-install-engine.sh.in" outFiles)
 GENERATE_BASH(processor ${bash-vars} "deploy-java-files.sh.in" outFiles)
+GENERATE_BASH(processor ${bash-vars} "check-component-exists.sh.in" outFiles)
 
 SET(noInstall)
 GENERATE_BASH(processor ${bash-vars} "prerm.in" noInstall)

+ 38 - 0
initfiles/sbin/check-component-exists.sh.in

@@ -0,0 +1,38 @@
+#!/bin/bash
+###############################################################################
+#    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#
+#    limitations under the License.
+#    along with All rights reserved. This program is free software: you can
+#    redistribute program.  If not, see <http://www.gnu.org/licenses/>.
+###############################################################################
+
+###<REPLACE>###
+
+
+if [[ $# != 1 ]]; then
+    echo "Incorrect number of arguments to check-component-exists.sh"
+    exit 1
+else
+    component=${1}
+fi
+
+configgen_output="$(${INSTALL_DIR}/sbin/configgen -env ${CONFIG_DIR}/${ENV_XML_FILE} -list -c ${component})"
+
+if echo "${configgen_output}" | grep -q ${component}; then
+    echo "Found component: ${component}"
+    exit 0
+else
+    echo "Undeclared Component: ${component}"
+    exit 1
+fi