44# shellcheck source=/dev/null
55. /etc/os-release
66
7- if [ " $ID " = " freebsd" ]; then
8- BSD_HIER=" /usr/local"
9- AGENT_EXE=" ${BSD_HIER} /bin/nginx-agent"
10- else
11- AGENT_EXE=" /usr/bin/nginx-agent"
12- BSD_HIER=" "
13- fi
7+
8+ AGENT_EXE=" /usr/bin/nginx-agent"
149AGENT_RUN_DIR=" /var/run/nginx-agent"
1510AGENT_LOG_DIR=" /var/log/nginx-agent"
1611AGENT_UNIT_LOCATION=" /etc/systemd/system"
@@ -107,18 +102,6 @@ create_agent_group() {
107102 fi
108103 fi
109104
110- if [ " $ID " = " freebsd" ]; then
111- printf " PostInstall: Adding nginx-agent group %s\n" " ${AGENT_GROUP} "
112- pw groupadd " ${AGENT_GROUP} "
113-
114- printf " PostInstall: Adding NGINX / agent user %s to group %s\n" " ${AGENT_USER} " " ${AGENT_GROUP} "
115- pw groupmod " ${AGENT_GROUP} " -M " ${AGENT_USER} "
116- if [ " ${WORKER_USER} " ]; then
117- printf " PostInstall: Adding NGINX Worker user %s to group %s\n" " ${WORKER_USER} " " ${AGENT_GROUP} "
118- pw groupmod " ${AGENT_GROUP} " -M " ${WORKER_USER} "
119- fi
120- fi
121-
122105 if [ " $ID " = " alpine" ]; then
123106 printf " PostInstall: Adding nginx-agent group %s\n" " ${AGENT_GROUP} "
124107 addgroup " ${AGENT_GROUP} "
@@ -168,118 +151,9 @@ update_unit_file() {
168151 printf " PostInstall: Set the enabled flag for the service unit\n"
169152 systemctl enable " ${AGENT_UNIT_FILE} "
170153 fi
171-
172- if [ " $ID " = " freebsd" ]; then
173- printf " PostInstall: Enabling NGINX Agent Service\n"
174- sysrc nginx_agent_enable=YES
175- fi
176- }
177-
178- add_default_config_file () {
179- if [ ! -f " ${BSD_HIER} " /etc/nginx-agent/nginx-agent.conf ]; then
180- printf " PostInstall: Creating default nginx-agent.conf file\n"
181- cat << EOF > "${BSD_HIER} "/etc/nginx-agent/nginx-agent.conf
182- #
183- # /etc/nginx-agent/nginx-agent.conf
184- #
185- # Configuration file for NGINX Agent.
186- #
187- # This file is to track NGINX Agent configuration values that are meant to be statically set. There
188- # are additional NGINX Agent configuration values that are set via the API and NGINX Agent install script
189- # which can be found in /var/lib/nginx-agent/agent-dynamic.conf.
190-
191- # specify the server grpc port to connect to
192- server:
193- # host of the control plane
194- host: 127.0.0.1
195- grpcPort: 54789
196- # provide servername overrides if using SNI
197- # metrics: ""
198- # command: ""
199- # tls options
200- tls:
201- # enable tls in the nginx-agent setup for grpcs
202- # default to enable to connect with tls connection but without client cert for mtls
203- enable: false
204- # specify the absolute path to the CA certificate file to use for verifying
205- # the server certificate (also requires 'skip_verify: false' below)
206- # by default, this will be the trusted root CAs found in the OS CA store
207- # ca: /etc/nginx-agent/ca.pem
208- # specify the absolute path to the client cert, when mtls is enabled
209- # cert: /etc/nginx-agent/client.crt
210- # specify the absolute path to the client cert key, when mtls is enabled
211- # key: /etc/nginx-agent/client.key
212- # controls whether the server certificate chain and host name are verified.
213- # for production use, see instructions for configuring TLS
214- skip_verify: true
215- log:
216- # set log level (panic, fatal, error, info, debug, trace; default "info")
217- level: info
218- # set log path. if empty, don't log to file.
219- path: /var/log/nginx-agent/
220- # data plane status message / 'heartbeat'
221- nginx:
222- # path of NGINX logs to exclude
223- exclude_logs: ""
224- socket: "unix:/var/run/nginx-agent/nginx.sock"
225-
226- dataplane:
227- status:
228- # poll interval for data plane status - the frequency the NGINX Agent will query the dataplane for changes
229- poll_interval: 30s
230- # report interval for data plane status - the maximum duration to wait before syncing dataplane information if no updates have being observed
231- report_interval: 24h
232- metrics:
233- # specify the size of a buffer to build before sending metrics
234- bulk_size: 20
235- # specify metrics poll interval
236- report_interval: 1m
237- collection_interval: 15s
238- mode: aggregated
239-
240- # OSS NGINX default config path
241- # path to aux file dirs can also be added
242- allowed_directories:
243- - /etc/nginx
244- - /usr/local/etc/nginx
245- - /usr/share/nginx/modules
246- - /etc/nms
247- api:
248- # default port for NGINX Agent API, this is for the server configuration of the REST API
249- port: 8081
250- EOF
251- printf " PostInstall: Updating file permissions for nginx-agent.conf to 0640\n"
252- chmod 0640 " ${BSD_HIER} " /etc/nginx-agent/nginx-agent.conf
253- fi
254- }
255-
256- upgrade_config_file () {
257- if [ -f " ${BSD_HIER} " /etc/nginx-agent/nginx-agent.conf ]; then
258- extensions=" "
259- if grep -q " advanced_metrics:" " ${BSD_HIER} " /etc/nginx-agent/nginx-agent.conf; then
260- extensions=" ${extensions} advanced-metrics"
261- fi
262- if grep -q " nginx_app_protect:" " ${BSD_HIER} " /etc/nginx-agent/nginx-agent.conf; then
263- extensions=" ${extensions} nginx-app-protect"
264- fi
265- if grep -q " nap_monitoring:" " ${BSD_HIER} " /etc/nginx-agent/nginx-agent.conf; then
266- extensions=" ${extensions} nap-monitoring"
267- fi
268- if ! grep -q " extensions:" " ${BSD_HIER} " /etc/nginx-agent/nginx-agent.conf && [ " ${# extensions} " -ne " 0" ]; then
269- printf " PostInstall: Updating nginx-agent.conf to include extensions array\n"
270- printf " \nextensions:\n" >> " ${BSD_HIER} " /etc/nginx-agent/nginx-agent.conf
271- for extension in ${extensions} ; do
272- echo " - $extension " >> " ${BSD_HIER} " /etc/nginx-agent/nginx-agent.conf
273- done
274- fi
275- fi
276154}
277155
278156restart_agent_if_required () {
279- if [ " ${ID} " = " freebsd" ]; then
280- # https://github.com/freebsd/pkg/pull/2128
281- return
282- fi
283157 if service nginx-agent status > /dev/null 2>&1 ; then
284158 printf " PostInstall: Restarting nginx agent\n"
285159 service nginx-agent restart || true
@@ -291,15 +165,10 @@ summary() {
291165 echo " NGINX Agent package has been successfully installed."
292166 echo " "
293167 echo " Please follow the next steps to start the software:"
294- if [ " $ID " = " freebsd" ]; then
295- echo " sudo service nginx-agent start"
296- echo " "
297- else
298- echo " sudo systemctl start nginx-agent"
299- echo " "
300- fi
168+ echo " sudo systemctl start nginx-agent"
169+ echo " "
301170 echo " Configuration settings can be adjusted here:"
302- echo " ${BSD_HIER} /etc/nginx-agent/nginx-agent.conf"
171+ echo " /etc/nginx-agent/nginx-agent.conf"
303172 echo " "
304173 echo " ----------------------------------------------------------------------"
305174}
@@ -314,8 +183,6 @@ summary() {
314183 create_agent_group
315184 create_run_dir
316185 update_unit_file
317- add_default_config_file
318- upgrade_config_file
319186 restart_agent_if_required
320187 summary
321188}
0 commit comments