#!/bin/bash # Rocky 9 compatible . /usr/src/m2/framework/bash_functions.sh VERSION="1.0.2" SCRIPT_NAME="M2 Alerts (re)Install" script_dir="/usr/local/m2" k_start k_detect_os service m2_alerts stop &> /dev/null killall -9 m2_alerts &> /dev/null cd /usr/src/m2/scripts/m2_alerts_dir gcc -g -Wall -o m2_alerts m2_alerts.c -lcurl -lmysqlclient -lnsl -lm -lz -L/usr/lib/mysql -L/usr/lib64/mysql -lpthread mv -f m2_alerts $script_dir/m2_alerts if [[ $centos_version == 7 || $ROCKY9 == 1 ]]; then rm -fr /etc/init.d/m2_alerts &> /dev/null rm -fr /etc/init.d/keep_alerts_alive &> /dev/null /bin/cp -fr m2_alerts.service_systemd /etc/systemd/system/m2_alerts.service systemctl daemon-reload systemctl enable m2_alerts systemctl start m2_alerts else cp -fr m2_alerts_service_initd /etc/init.d/m2_alerts chmod 777 /etc/init.d/m2_alerts chkconfig --add m2_alerts chkconfig --level 2345 m2_alerts on /etc/init.d/m2_alerts start &> /dev/null fi k_exit $EXIT_CODE