#! /bin/sh # Rocky 9 compatible . /usr/src/m2/framework/bash_functions.sh . /usr/src/m2/framework/settings.sh k_config_details # ---- VARS ----- VERSION="1.0.3" SCRIPT_NAME="Logrotate Enable" TEST=0 # 1 - do not execute changes # ---- FUNCTIONS ----- # ---- MAIN ----- k_start if [ "$TEST" == "1" ]; then report "***** TEST MODE ON. Changes will not be applied *****" 8 fi #cp -fr /usr/src/m2/freeswitch/freeswitch_logrotate /etc/logrotate.d/freeswitch # optimize fs log space #/usr/src/m2/maintenance/logrotates/fs_logrotate_tune.sh > /dev/null 2>&1 cp -fr /usr/src/m2/freeradius/radius_logrotate /etc/logrotate.d/radius echo "0 * * * * root /usr/sbin/logrotate /etc/logrotate.conf" > /etc/cron.d/logrotate cp -fr /usr/src/m2/maintenance/logrotates/"$SYSTEM_GUI_DIR"_gui_production /etc/logrotate.d/ chmod 644 /etc/logrotate.d/"$SYSTEM_GUI_DIR"_gui_production # global logrotate which rotates all *.log files in /var/log/m2 # no need to create one logrotate for one file cp -fr /usr/src/m2/maintenance/logrotates/m2_global_logrotate /etc/logrotate.d/ # deleting old logrotates rm -fr /etc/logrotate.d/m2_invoices rm -fr /etc/logrotate.d/gui_debug rm -fr /etc/logrotate.d/m2_aggregates rm -fr /etc/logrotate.d/m2_alerts rm -fr /etc/logrotate.d/m2_background_tasks rm -fr /etc/logrotate.d/m2_server_loadstats rm -fr /etc/logrotate.d/m2_delete_old_rate rm -fr /etc/logrotate.d/email2tariff rm -fr /etc/logrotate.d/m2_block_ip rm -fr /etc/logrotate.d/m2_unblock_ip rm -fr /etc/logrotate.d/m2_get_blocked_ip rm -fr /etc/logrotate.d/m2_elasticsearch_restart rm -fr /etc/logrotate.d/m2_es_sync_control rm -fr /etc/logrotate.d/m2_partitions_delete rm -fr /etc/logrotate.d/m2_partitions_calls rm -fr /etc/logrotate.d/m2_partitions_calls_old rm -fr /etc/logrotate.d/m2_rates_effective_from_cache_control rm -fr /etc/logrotate.d/m2_pcap_control rm -fr /etc/logrotate.d/m2_pcap_check_space rm -fr /etc/logrotate.d/m2_pcap_tshark_control rm -fr /etc/logrotate.d/m2_pcap_tshark # Add changed ES internal logging file if needed if [[ "$ES_PRESENT" == "1" ]]; then if ! diff /usr/src/m2/elasticsearch/logging.yml /etc/elasticsearch/logging.yml >/dev/null; then cp -f /usr/src/m2/elasticsearch/logging.yml /etc/elasticsearch/logging.yml #delete old logs with date timestamp, as ES internal logging will not delete them even after change rm -f /var/log/elasticsearch/cluster_*.log.20* service elasticsearch restart fi fi k_exit $EXIT_CODE