#! /bin/bash # Rocky 9 compatible . /usr/src/m2/framework/bash_functions.sh k_config_details # script checks m2_pcap_tshark installation # ---- VARS ----- VERSION="1.0.6" SCRIPT_NAME="PCAP TShark Checks" CFG="/etc/m2/system.conf" TEST=0 # 1 - do not execute changes # ---- FUNCTIONS ----- # ---- MAIN ----- k_start k_detect_os if [ "$TEST" == "1" ]; then report "***** TEST MODE ON. Changes will not be applied *****" 8 fi if [[ $PROXY_PRESENT != 1 ]]; then report "PROXY_PRESENT=$PROXY_PRESENT. Will not check PCAP TShark" 0 k_exit 0 fi TS_ENABLED=$(sed 's/ //g' $CFG | awk -F"=" '/pcap_tshark_active/{print $2}') if [[ $TS_ENABLED != 1 ]]; then if [[ $TS_ENABLED == 0 ]]; then report "pcap_tshark_active = $TS_ENABLED in $CFG" 2 report " Are you sure PCAP Tshark should be disabled on this server?" 2 k_exit 2; else report "pcap_tshark_active = $TS_ENABLED in $CFG" 1; report " Install: /usr/src/m2/helpers/m2_pcap_tshark/m2_pcap_tshark_install.sh" 1 k_exit 1; fi fi if ps aux | grep tcpdump | grep -q m2_pcap_tshark; then report "tcpdump process active" 0 else report "tcpdump process not active" 1 EXIT_CODE=1 fi if [ -f /etc/cron.d/m2_pcap_tshark_control ]; then report "cron m2_pcap_tshark_control present" 0 else report "cron m2_pcap_tshark_control not found" 1 EXIT_CODE=1 fi if [ ! -d /var/spool/pcaps ]; then report "/var/spool/pcaps not found" 1 EXIT_CODE=1 fi FILE="/usr/local/m2/m2_pcap"; if [ ! -f $FILE ]; then report "$FILE not found" 1; EXIT_CODE=1; fi FILE="/usr/local/m2/m2_pcap_tshark_compress_wrapper.sh"; if [ ! -f $FILE ]; then report "$FILE not found" 1; EXIT_CODE=1; fi FILE="/usr/local/m2/m2_pcap_tshark_control.sh"; if [ ! -f $FILE ]; then report "$FILE not found" 1; EXIT_CODE=1; fi FILE="/usr/local/m2/m2_pcap_tshark_find_suitable_pcaps.rb"; if [ ! -f $FILE ]; then report "$FILE not found" 1; EXIT_CODE=1; fi FILE="/usr/local/m2/m2_pcap_tshark_reshuffle_files.rb"; if [ ! -f $FILE ]; then report "$FILE not found" 1; EXIT_CODE=1; fi FILE="/usr/local/m2/m2_pcap_wrapper.sh"; if [ ! -f $FILE ]; then report "$FILE not found" 1; EXIT_CODE=1; fi if [[ ! -e /usr/local/sbin/jq ]]; then report "/usr/local/sbin/jq not found" 1; EXIT_CODE=1; fi if [[ ! -e /usr/local/bin/mscgen ]]; then report "/usr/local/bin/mscgen not found" 1; EXIT_CODE=1; fi RUBY=`ruby -v 2>/dev/null` if [[ $ROCKY9 == 1 ]]; then if echo $RUBY | grep -q -v "ruby 3." ; then report "ruby 3.x not installed" 1; EXIT_CODE=1; fi else if echo $RUBY | grep -q -v "ruby 2." ; then report "ruby 2.x not installed" 1; EXIT_CODE=1; fi fi k_exit $EXIT_CODE