#! /bin/bash # script installs Homer 7.7 on Centos 8 . /usr/src/m2/framework/bash_functions.sh . /usr/src/m2/framework/settings.sh k_default_interface_ip # ---- VARS ----- VERSION="1.0.5" SCRIPT_NAME="Homer 7.7 install" TEST=0 # 1 - do not execute changes # ---- FUNCTIONS ----- # ---- MAIN ----- echo k_kolmisoft_logo echo k_start if [ "$TEST" == "1" ]; then report "***** TEST MODE ON. Changes will not be applied *****" 8 fi _centos_version if (( centos_version != 8 )); then report "Centos 8 is necessary. Current: $centos_version" 1 k_exit 1 fi # -------------------------------------------------------------------------------------------------------- cd /usr/src/m2/maintenance ./selinux_disable.sh report "Time Sync and setting Time-Zone to GTM-0" 3 dnf -y install chrony ntpstat systemctl enable chronyd systemctl start chronyd timedatectl set-timezone Europe/London report "Installing packages" 3 dnf -y install wireshark-cli net-tools wget dnf -y install mlocate && updatedb # -------------------------------------------------------------------------------------------------------- # Prometheus + Grafana cd /usr/src/m2/helpers/prometheus/ ./prometheus_grafana_install_c78.sh echo " - job_name: 'heplify-server' scrape_interval: 5s static_configs: - targets: [':::9096']" >> /etc/prometheus/prometheus.yml service prometheus restart sleep 1 if netstat -vatupn | grep prometheus | grep -q ":::9090"; then report "Prometheus installed ok" 0 else report "Failed to install Prometheus properly. Should listen on IPv6 :::9090" 1 k_exit 1 fi report "Installing Grafana Dashboards" 3 cp -fr /usr/src/m2/helpers/homer/grafana_dashboards/* /etc/grafana/provisioning/dashboards/ service grafana-server restart # -------------------------------------------------------------------------------------------------------- # PostgreSQL cd /usr/src/m2/helpers/homer/ ./postgresql12_install_c8.sh # -------------------------------------------------------------------------------------------------------- # PgAdmin 4 ./pgadmin4_install_c8.sh # -------------------------------------------------------------------------------------------------------- report "Installing Homer repository" 3 curl -s https://packagecloud.io/install/repositories/qxip/sipcapture/script.rpm.sh | sudo bash report "Installing heplify-server" 3 dnf -y install heplify-server report "Creating sane location for configs" 3 mkdir -p /etc/heplify-server ln -s /etc/heplify-server.toml /etc/heplify-server/heplify-server.tom report "Configuring Heplify-server" 3 cp -fr /usr/src/m2/helpers/homer/heplify-server.toml /etc/ sed -i "s|HEPAddr = \"0.0.0.0:9060\"\+|HEPAddr = \"$DEFAULT_IP:9060\"|g" /etc/heplify-server.toml sed -i "s|HEPTLSAddr = \"0.0.0.0:9060\"\+|HEPTLSAddr = \"$DEFAULT_IP:9060\"|g" /etc/heplify-server.toml # proper log location mkdir -p /var/log/homer cp -fr /usr/src/m2/helpers/homer/heplify-server.service /usr/lib/systemd/system/ systemctl daemon-reload systemctl restart heplify-server #systemctl status heplify-server sleep 1 # cleanup cd / rm -fr heplify-server* if netstat -vatupn | grep heplify-serv | grep -q ":::9096"; then report "Heplify-server listens on :::9096 for Prometheus connection" 0 else report "Heplify-server does not listen on :::9096 for Prometheus connection" 0 report "Press ENTER to continue or CTRL+Z to abort the script" 2 read fi if netstat -vatupn | grep heplify-serv | grep -q "$DEFAULT_IP:9060"; then report "Heplify-server listens on $DEFAULT_IP:9060" 0 else report "Heplify-server does not listen on $DEFAULT_IP:9060" 2 report "Press ENTER to continue or CTRL+Z to abort the script" 2 read fi sleep 10 if cat /var/log/homer/heplify-server.log | grep -q "postgres connection established"; then report "Heplify-server has connection with PostgreSQL" 0 else report "Heplify-server does not have connection with PostgreSQL, rechecking" 2 sleep 20 if cat /var/log/homer/heplify-server.log | grep -q "postgres connection established"; then report "Heplify-server has connection with PostgreSQL" 0 else report "Heplify-server does not have connection with PostgreSQL. Slow HDD?" 2 report "Press ENTER to continue or CTRL+Z to abort the script" 2 read fi fi report "Opening firewall for Heplify-server" 3 firewall-cmd --add-port=9060/udp --permanent firewall-cmd --reload # -------------------------------------------------------------------------------------------------------- report "Installing homer-app" 3 dnf -y install homer-app report "Creating sane location for configs" 3 ln -s /usr/local/homer/etc/ /etc/homer-app cp -fr /usr/src/m2/helpers/homer/webapp_config.json /usr/local/homer/etc/ sed -i "s|1.1.1.1\+|$DEFAULT_IP|g" /usr/local/homer/etc/webapp_config.json report "Initial DB setup" 3 homer-app -create-config-db -database-root-user=postgres -database-host="127.0.0.1" -database-root-password=postgres -database-homer-user=homer_user > /dev/null 2>&1 homer-app -create-data-db -database-root-user=postgres -database-host="127.0.0.1" -database-root-password=postgres -database-homer-user=homer_user > /dev/null 2>&1 homer-app -create-table-db-config > /dev/null 2>&1 homer-app -populate-table-db-config > /dev/null 2>&1 homer-app -upgrade-table-db-config > /dev/null 2>&1 service homer-app restart sleep 1 if netstat -vatupn | grep homer | grep -q "$DEFAULT_IP:9080"; then report "Heplify-app listens on $DEFAULT_IP:9080" 0 else report "Heplify-app does not listen on $DEFAULT_IP:9080" 2 report "Press ENTER to continue or CTRL+Z to abort the script" 2 read fi report "Opening firewall for Heplify-app" 3 firewall-cmd --add-port=9080/tcp --permanent firewall-cmd --reload echo report "Access:" 3 report " pgAdmin: http://$DEFAULT_IP/pgadmin4 (email/psw you entered on installation)" 3 report " Prometheus: http://$DEFAULT_IP:9090" 3 report " Grafana: http://$DEFAULT_IP:3000 (admin / admin)" 3 report " Homer-app: http://$DEFAULT_IP:9080 (admin / sipcapture)" 3 echo k_exit 0