Skip to content

Commit 6ea94a6

Browse files
authored
Copy instance group during V2 to V3 upgrade (#1016)
1 parent 50853fc commit 6ea94a6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

scripts/packages/preinstall.sh

+15-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ NO_COLOUR='\033[0m'
2020
. /etc/os-release
2121

2222
AGENT_CONFIG_FILE=${AGENT_CONFIG_FILE:-"/etc/nginx-agent/nginx-agent.conf"}
23+
AGENT_DYNAMIC_CONFIG_FILE=${AGENT_DYNAMIC_CONFIG_FILE:-"/var/lib/nginx-agent/agent-dynamic.conf"}
2324

2425
#
2526
# Functions
@@ -66,6 +67,19 @@ update_config_file() {
6667
token=`grep "token:" "${v2_config_file}"`
6768
token=`echo $token | cut -d ":" -f 2 | xargs`
6869

70+
instance_group=`grep "instance_group:" "${AGENT_DYNAMIC_CONFIG_FILE}"`
71+
instance_group=`echo $instance_group | cut -d ":" -f 2 | xargs`
72+
73+
labels=""
74+
75+
if [ -n "${instance_group}" ]; then
76+
echo "Adding config sync group to NGINX Agent configuration"
77+
labels="
78+
labels:
79+
config-sync-group: ${instance_group}
80+
"
81+
fi
82+
6983
config_dirs=`grep "config_dirs:" "${v2_config_file}"`
7084
config_dirs=`echo $config_dirs | cut -d "\"" -f 2`
7185

@@ -91,7 +105,7 @@ log:
91105
path: /var/log/nginx-agent/
92106
93107
allowed_directories: ${allowed_directories}
94-
108+
${labels}
95109
command:
96110
server:
97111
host: ${NGINX_ONE_HOST}

0 commit comments

Comments
 (0)