Last active
December 13, 2024 03:21
-
-
Save musahi0128/7252c38afd9dbb0d29e103d05eba263b to your computer and use it in GitHub Desktop.
Zabbix Server setup script for Ubuntu Noble ARM64/AArch64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export DEBIAN_FRONTEND=dialog | |
echo "Zabbix Server installation script started." | |
echo "Installing packages required to run this script, please wait." | |
apt update && apt install dialog tzdata -yq && apt clean | |
PG_PASS=$(dialog --insecure --passwordbox 'Set a password for the zabbix user in postgres' 10 40 2>&1 >/dev/tty) | |
if [ -z "$PG_PASS" ]; then | |
echo "Password cannot be empty! aborting" | |
exit 1 | |
fi | |
ZX_PORT=$(dialog --inputbox 'Set nginx `port` value for the frontend, default: 8080' 10 40 8080 2>&1 >/dev/tty) | |
ZX_HOST=$(dialog --inputbox 'Set nginx `server_name` value for the frontend, default: localhost' 10 40 localhost 2>&1 >/dev/tty) | |
dpkg-reconfigure tzdata | |
echo "Setting up the repo, please wait." | |
wget https://repo.zabbix.com/zabbix/7.0/ubuntu-arm64/pool/main/z/zabbix-release/zabbix-release_latest_7.0+ubuntu24.04_all.deb | |
dpkg -i zabbix-release_latest_7.0+ubuntu24.04_all.deb | |
rm zabbix-release_latest_7.0+ubuntu24.04_all.deb | |
apt update | |
echo "Installing packages and dependencies." | |
apt install -yq \ | |
zabbix-server-pgsql zabbix-frontend-php php8.3-pgsql zabbix-nginx-conf zabbix-sql-scripts \ | |
zabbix-agent2 zabbix-agent2-plugin-* postgresql | |
sudo -u postgres createuser zabbix | |
sudo -u postgres psql -c "ALTER USER zabbix WITH PASSWORD '${PG_PASS}';" > /dev/null 2>&1 | |
echo "Initializing database, please wait." | |
sudo -u postgres createdb -O zabbix zabbix | |
zcat /usr/share/zabbix-sql-scripts/postgresql/server.sql.gz | sudo -u zabbix psql zabbix > /dev/null 2>&1 | |
sed -i "s/# DBPassword=/DBPassword=${PG_PASS}/g" /etc/zabbix/zabbix_server.conf | |
sed -i "s/# listen 8080;/ listen ${ZX_PORT};/g" /etc/zabbix/nginx.conf | |
sed -i "s/# server_name example.com;/ server_name ${ZX_HOST};/g" /etc/zabbix/nginx.conf | |
echo "Restarting relevant services." | |
systemctl restart zabbix-server zabbix-agent2 nginx php8.3-fpm | |
echo "Enabling relevant services." | |
systemctl enable zabbix-server zabbix-agent2 nginx php8.3-fpm | |
echo "Zabbix Server installation script finished. Access the frontend on http://${ZX_HOST}:${ZX_PORT} to continue with the setup." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment