This is an automated email from the ASF dual-hosted git repository.

dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 49932d6f59 [INLONG-9922][Agent] Add a script to copy the configuration 
from the installer to the agent (#9923)
49932d6f59 is described below

commit 49932d6f59d7b3ac09e85bd48f103ed5a93a6912
Author: justinwwhuang <[email protected]>
AuthorDate: Sun Apr 7 20:27:57 2024 +0800

    [INLONG-9922][Agent] Add a script to copy the configuration from the 
installer to the agent (#9923)
---
 inlong-agent/bin/agent-config.sh   | 70 ++++++++++++++++++++++++++++++++++++++
 inlong-agent/conf/agent.properties |  2 +-
 2 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/inlong-agent/bin/agent-config.sh b/inlong-agent/bin/agent-config.sh
new file mode 100755
index 0000000000..5750e8416a
--- /dev/null
+++ b/inlong-agent/bin/agent-config.sh
@@ -0,0 +1,70 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+BASE_DIR=$(cd "$(dirname "$0")"/../../;pwd)
+installerConfigFile=$BASE_DIR/agent-installer/conf/installer.properties
+agentConfigFile=$BASE_DIR/inlong-agent/conf/agent.properties
+
+managerAddr=$(cat $installerConfigFile|grep -i 'agent.manager.addr'|awk -F = 
'{print $2}')
+localIp=$(cat $installerConfigFile|grep -i 'agent.local.ip'|awk -F = '{print 
$2}')
+clusterTag=$(cat $installerConfigFile|grep -i 'agent.cluster.tag'|awk -F = 
'{print $2}')
+clusterName=$(cat $installerConfigFile|grep -i 'agent.cluster.name'|awk -F = 
'{print $2}')
+tdwSecurityUrl=$(cat $installerConfigFile|grep -i 'tdw.security.url'|awk -F = 
'{print $2}')
+auditFlag=$(cat $installerConfigFile|grep -i 'audit.enable'|awk -F = '{print 
$2}')
+auditProxy=$(cat $installerConfigFile|grep -i 'audit.proxys'|awk -F = '{print 
$2}')
+
+if [ ${#managerAddr} -gt 0 ]; then
+  sed -i "/agent.manager.addr=*/c\agent.manager.addr=$managerAddr" 
$agentConfigFile
+else
+  echo "manager addr empty"
+fi
+
+if [ ${#localIp} -gt 0 ]; then
+  sed -i "/agent.local.ip=*/c\agent.local.ip=$localIp" $agentConfigFile
+else
+  echo "agent local ip empty"
+fi
+
+if [ ${#clusterTag} -gt 0 ]; then
+   sed -i "/agent.cluster.tag=*/c\agent.cluster.tag=$clusterTag" 
$agentConfigFile
+else
+  echo "cluster tag empty"
+fi
+
+if [ ${#clusterName} -gt 0 ]; then
+   sed -i "/agent.cluster.name=*/c\agent.cluster.name=$clusterName" 
$agentConfigFile
+else
+   echo "cluster name empty"
+fi
+
+if [ ${#tdwSecurityUrl} -gt 0 ]; then
+  sed -i "/tdw.security.url=*/c\tdw.security.url=$tdwSecurityUrl" 
$BASE_DIR/inlong-agent/bin/agent-env.sh
+else
+  echo "tdw security url empty"
+fi
+
+if [ ${#auditFlag} -gt 0 ]; then
+  sed -i "/audit.enable=*/c\audit.enable=$auditFlag" $agentConfigFile
+else
+  echo "audit flag empty"
+fi
+
+if [ ${#auditProxy} -gt 0 ]; then
+  sed -i "/audit.proxys=*/c\audit.proxys=$auditProxy" $agentConfigFile
+else
+  echo "audit proxy empty"
+fi
diff --git a/inlong-agent/conf/agent.properties 
b/inlong-agent/conf/agent.properties
index d67b0b90a4..3a2c4631b2 100755
--- a/inlong-agent/conf/agent.properties
+++ b/inlong-agent/conf/agent.properties
@@ -103,4 +103,4 @@ agent.prometheus.exporter.port=9080
 # whether to enable audit
 audit.enable=true
 # audit proxy address
-audit.proxys=127.0.0.1:10081
+audit.proxys=127.0.0.1:10081
\ No newline at end of file

Reply via email to