mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-02-16 18:23:27 +01:00
Compare commits
1 Commits
hf_zabbix_
...
hf_alpine_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2171f51569 |
15
ct/zabbix.sh
15
ct/zabbix.sh
@@ -35,18 +35,15 @@ function update_script() {
|
||||
exit
|
||||
fi
|
||||
|
||||
if systemctl cat zabbix-agent2.service &>/dev/null; then
|
||||
if systemctl list-unit-files | grep -q zabbix-agent2.service; then
|
||||
AGENT_SERVICE="zabbix-agent2"
|
||||
elif systemctl cat zabbix-agent.service &>/dev/null; then
|
||||
AGENT_SERVICE="zabbix-agent"
|
||||
else
|
||||
AGENT_SERVICE=""
|
||||
msg_warn "No Zabbix Agent service found, skipping agent actions"
|
||||
AGENT_SERVICE="zabbix-agent"
|
||||
fi
|
||||
|
||||
msg_info "Stopping Services"
|
||||
systemctl stop zabbix-server
|
||||
[[ -n "$AGENT_SERVICE" ]] && systemctl stop "$AGENT_SERVICE"
|
||||
systemctl stop "$AGENT_SERVICE"
|
||||
msg_ok "Stopped Services"
|
||||
|
||||
read -rp "Choose Zabbix version [1] 7.0 LTS [2] 7.4 (Latest Stable) [3] Latest available (default: 2): " ZABBIX_CHOICE
|
||||
@@ -86,13 +83,13 @@ function update_script() {
|
||||
|
||||
$STD apt install --only-upgrade zabbix-server-pgsql zabbix-frontend-php php8.4-pgsql
|
||||
|
||||
if [[ "$AGENT_SERVICE" == "zabbix-agent2" ]]; then
|
||||
if [ "$AGENT_SERVICE" = "zabbix-agent2" ]; then
|
||||
$STD apt install --only-upgrade zabbix-agent2 zabbix-agent2-plugin-postgresql
|
||||
if [ -f /etc/zabbix/zabbix_agent2.d/plugins.d/nvidia.conf ]; then
|
||||
sed -i 's|^Plugins.NVIDIA.System.Path=.*|# Plugins.NVIDIA.System.Path=/usr/libexec/zabbix/zabbix-agent2-plugin-nvidia-gpu|' \
|
||||
/etc/zabbix/zabbix_agent2.d/plugins.d/nvidia.conf
|
||||
fi
|
||||
elif [[ "$AGENT_SERVICE" == "zabbix-agent" ]]; then
|
||||
else
|
||||
$STD apt install --only-upgrade zabbix-agent
|
||||
fi
|
||||
|
||||
@@ -108,7 +105,7 @@ function update_script() {
|
||||
|
||||
msg_info "Starting Services"
|
||||
systemctl start zabbix-server
|
||||
[[ -n "$AGENT_SERVICE" ]] && systemctl start "$AGENT_SERVICE"
|
||||
systemctl start "$AGENT_SERVICE"
|
||||
systemctl restart apache2
|
||||
msg_ok "Started Services"
|
||||
msg_ok "Updated successfully!"
|
||||
|
||||
@@ -34,42 +34,6 @@ EOF
|
||||
fi
|
||||
}
|
||||
|
||||
set -Eeuo pipefail
|
||||
trap 'error_handler $? $LINENO "$BASH_COMMAND"' ERR
|
||||
trap on_exit EXIT
|
||||
trap on_interrupt INT
|
||||
trap on_terminate TERM
|
||||
|
||||
error_handler() {
|
||||
local exit_code="$1"
|
||||
local line_number="$2"
|
||||
local command="$3"
|
||||
|
||||
if [[ "$exit_code" -eq 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
printf "\e[?25h"
|
||||
echo -e "\n${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}\n"
|
||||
exit "$exit_code"
|
||||
}
|
||||
|
||||
on_exit() {
|
||||
local exit_code="$?"
|
||||
[[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile"
|
||||
exit "$exit_code"
|
||||
}
|
||||
|
||||
on_interrupt() {
|
||||
echo -e "\n${RD}Interrupted by user (SIGINT)${CL}"
|
||||
exit 130
|
||||
}
|
||||
|
||||
on_terminate() {
|
||||
echo -e "\n${RD}Terminated by signal (SIGTERM)${CL}"
|
||||
exit 143
|
||||
}
|
||||
|
||||
# This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection
|
||||
setting_up_container() {
|
||||
msg_info "Setting up Container OS"
|
||||
|
||||
@@ -172,7 +172,7 @@ network_check() {
|
||||
fi
|
||||
|
||||
set -e
|
||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||
trap 'error_handler' ERR
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user