Skip to content

Commit 3fa9a2a

Browse files
authored
Refactor agent service control in zabbix.sh (#8881)
Replaces conditional logic for stopping and starting Zabbix agent services with a variable ($AGENT_SERVICE), simplifying service management.
1 parent 4eedff1 commit 3fa9a2a

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

ct/zabbix.sh

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,8 @@ function update_script() {
4242
fi
4343

4444
msg_info "Stopping Services"
45-
$STD systemctl stop zabbix-server
46-
if systemctl list-unit-files | grep -q zabbix-agent2; then
47-
$STD systemctl stop zabbix-agent2
48-
else
49-
$STD systemctl stop zabbix-agent
50-
fi
45+
systemctl stop zabbix-server
46+
systemctl stop "$AGENT_SERVICE"
5147
msg_ok "Stopped Services"
5248

5349
msg_info "Updating Zabbix"
@@ -88,12 +84,8 @@ function update_script() {
8884
msg_ok "Updated Zabbix"
8985

9086
msg_info "Starting Services"
91-
$STD systemctl start zabbix-server
92-
if systemctl list-unit-files | grep -q zabbix-agent2; then
93-
$STD systemctl start zabbix-agent2
94-
else
95-
$STD systemctl start zabbix-agent
96-
fi
87+
systemctl start zabbix-server
88+
systemctl start "$AGENT_SERVICE"
9789
systemctl restart apache2
9890
msg_ok "Started Services"
9991

0 commit comments

Comments
 (0)