#! /bin/bash . /usr/src/m2/framework/bash_functions.sh _centos_7_check # ---- VARS ----- VERSION="1.0.1" SCRIPT_NAME="Heplify install and add to Homer" PORT="9060" # ---- MAIN ----- echo k_kolmisoft_logo echo k_start if [ ! -f /usr/local/bin/heplify ]; then report "Installing packets" 3 yum -y install libpcap-devel wget net-tools nc yum -y install mlocate && updatedb report "Installing heplify" 3 curl -s https://packagecloud.io/install/repositories/qxip/sipcapture/script.rpm.sh | sudo bash yum -y install heplify report "Creating log dir" 3 mkdir -p /var/log/heplify else report "Heplify is already installed" 3 fi report "Configuring heplify" 3 echo echo -n "Enter Homer's IP:PORT (if port is not entered default $PORT will be used): " read HOMER_IPPORT echo # check for length if [ ${#HOMER_IPPORT} -le 8 ]; then report "Please enter correct IP address" 1 k_exit 1 fi # port if echo $HOMER_IPPORT | grep -v -q ":" ; then #node_ip="$node_ip:$port" report "Default port will be used: $PORT" 3 HOMER_IP=$HOMER_IPPORT else PORT=`echo $HOMER_IPPORT | awk -F':' '{print $2}'` HOMER_IP=`echo $HOMER_IPPORT | awk -F':' '{print $1}'` report "Custom port will be used: $PORT" 3 fi report "Testing connection to Homer server -> $HOMER_IP:$PORT" 3 rm -fr /tmp/udp_test nc -z -v -u $HOMER_IP $PORT > /tmp/udp_test 2>&1 if cat /tmp/udp_test | grep -q "UDP packet sent successfully"; then report "Homer connection OK" 0 else report "Homer connection FAILED" 1 k_exit 1 fi rm -fr /tmp/udp_test echo "[Unit] Description=Captures packets from wire and sends them to Homer After=network.target [Service] WorkingDirectory=/var/log/heplify ExecStart=/usr/local/bin/heplify -hs $HOMER_IP:$PORT -m SIPRTCP -l \"warning\" -zf ExecStop=/bin/kill \${MAINPID} Restart=on-failure RestartSec=10s Type=simple [Install] WantedBy=multi-user.target" > /etc/systemd/system/heplify.service systemctl daemon-reload systemctl enable heplify systemctl restart heplify if (systemctl -q is-active heplify.service); then report "Heplify is active" 0 else report "Heplify is not active" 1 k_exit 1 fi k_exit 0