Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INLONG-9922][Agent] Add a script to copy the configuration from the installer to the agent #9923

Merged
merged 5 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions inlong-agent/bin/agent-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/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 'manager.addr'|awk -F = '{print $2}')
localIp=$(cat $installerConfigFile|grep -i '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}')
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 "/manager.addr/s#default#$managerAddr#g" $agentConfigFile
else
echo "manager addr empty"
fi

if [ ${#localIp} -gt 0 ]; then
sed -i "/local.ip/s#default#$localIp#g" $agentConfigFile
else
echo "local ip empty"
fi

if [ ${#clusterTag} -gt 0 ]; then
sed -i "/agent.cluster.tag/s#default#$clusterTag#g" $agentConfigFile
else
echo "cluster tag empty"
fi

if [ ${#clusterName} -gt 0 ]; then
sed -i "/agent.cluster.name/s#default#$clusterName#g" $agentConfigFile
else
echo "cluster name empty"
fi

if [ ${#tdwSecurityUrl} -gt 0 ]; then
sed -i "/export OTEL_EXPORTER_OTLP_ENDPOINT=/a export TDW_SECURITY_URL=$tdwSecurityUrl" ~/inlong/inlong-agent/bin/agent-env.sh
else
echo "tdw security url empty"
fi

if [ ${#auditFlag} -gt 0 ]; then
sed -i "/audit.enable/s#default#$auditFlag#g" $agentConfigFile
else
echo "audit flag empty"
fi

if [ ${#auditProxy} -gt 0 ]; then
sed -i "/audit.proxys/s#default#$auditProxy#g" $agentConfigFile
else
echo "audit proxy empty"
fi
12 changes: 6 additions & 6 deletions inlong-agent/conf/agent.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ agent.fetcher.classname=org.apache.inlong.agent.plugin.fetcher.ManagerFetcher
#######################
# max wait time(s) for thread pool to terminate running
thread.pool.await.time=30
agent.local.ip=127.0.0.1
agent.local.ip=default
agent.local.uuid=
agent.local.uuid.open=false
agent.node.group=default_group
Expand Down Expand Up @@ -75,15 +75,15 @@ task.pull.maxSecond=2
############################
# manager config
############################
agent.manager.addr=http://127.0.0.1:8083
agent.manager.addr=default
agent.manager.auth.secretId=
agent.manager.auth.secretKey=

############################
# cluster config for automatically report and register
############################
agent.cluster.tag=default_cluster
agent.cluster.name=default_agent
agent.cluster.tag=default
agent.cluster.name=default
agent.cluster.inCharges=admin

############################
Expand All @@ -101,6 +101,6 @@ agent.prometheus.exporter.port=9080
# audit config
############################
# whether to enable audit
audit.enable=true
audit.enable=default
# audit proxy address
audit.proxys=127.0.0.1:10081
audit.proxys=default
Loading