#!/bin/bash
DN="\Z1\ZrDN\Z0\ZR";
UP="\Zr\Z2UP\Z0\ZR";
NA="\Z8\ZrNA\Z0\ZR";
if hostname -I > /etc/hostip; then
badaddr=`cat /etc/hostip | cut -f 4 -d " "`
realaddr=`cat /etc/hostip`
_IP="Priv IP: ${realaddr//$badaddr/}"
# _IP=" Private IP: `cat /etc/hostip`"
_IP="LAN IP: `ifconfig | grep "inet " | sed '/127/d' | tr -s ' ' | cut -f 3 -d " " | tr '\n' ' '`"
if [ -f "/etc/pbx/.phone" ]; then
_PHONE=`cat /etc/pbx/.phone`
else
_PHONE=" "
fi
# _PUBLIC="Public Info: `dig TXT +short o-o.myaddr.l.google.com @ns1.google.com ` $_PHONE"
_PUBLIC="Public: `curl -4 ifconfig.me` $_PHONE"
else
_IP=""
_PUBLIC=""
_PUBLIC="Public: `curl ifconfig.me` $_PHONE"
fi
version=`cat /etc/pbx/.version`
#fusionversion=`export PGPASSWORD="$(cat /etc/fusionpbx/config.conf | grep 'database.0.password =' | cut -d= -f 2 | cut -d" " -f 2)"; psql -h '127.0.0.1' -U 'fusionpbx' -d 'fusionpbx' -t -c 'SELECT software_version FROM v_software;' | cut -d" " -f 2`
fspbxversion=`php -r "echo (require '/var/www/fspbx/config/version.php')['release'] . PHP_EOL;"`
phpversion=`php -v | head -n 1 | head -c 7 | cut -f 2 -d " "`
astversion=`asterisk -rx "core show version" | grep -m 2 ^ | tail -1 | cut -f 2 -d " "`
fpbxversion=`cat /var/www/html/admin/modules/core/module.xml | grep version | head -n 1 | cut -f 2 -d ">" | cut -f 1 -d "<"`
#OSrelease="*Debian `cat /etc/os-release | grep "VERSION=" | cut -f 2 -d "=" | sed 's|"||g' | sed 's| LTS||' | sed 's|(||' | sed 's|)||'`*"
OSrelease=`cat /etc/os-release | grep VERSION | grep "(" | cut -f 2 -d "(" | cut -f 1 -d ")"`
if [ "$OSrelease" = "bullseye" ]; then
OSrelease="Debian Bookworm"
fi
test=`ps aux | grep -c freeswitch`
if [ "$test" -lt "2" ]; then
asterisk="$DN"
else
asterisk="$UP"
fi
test=`ps aux | grep jginx`
if [ "$test" -lt "2" ]; then
apache="$DN"
else
apache="$UP"
fi
test=`ps aux | grep postgres`
if [ "$test" -lt "2" ]; then
mysql="$DN"
else
mysql="$UP"
fi
test=`ps aux | grep -c webmin`
if [ "$test" -lt "2" ]; then
webmin="$DN"
else
webmin="$UP"
fi
test=`ps aux | grep -c sshd`
if [ "$test" -lt "2" ]; then
ssh="$DN"
else
ssh="$UP"
fi
test=`ps aux | grep -c postfix`
if [ "$test" -lt "2" ]; then
postfix="$DN"
else
postfix="$UP"
fi
test=`ps aux | grep -c fail2ban`
if [ "$test" -lt "2" ]; then
fail2ban="$DN"
else
fail2ban="$UP"
fi
test=`ps aux | grep -c ntpd`
if [ "$test" -lt "2" ]; then
ntpd="$DN"
else
ntpd="$UP"
fi
test=`sudo iptables -nL | grep -c DROP`
if [ "$test" -lt "1" ]; then
IPtables="$DN"
else
IPtables="$UP"
fi
IPPORT=`ifconfig|gawk '/flags/{print $1}'|cut -f 1 -d ":"|tail -1`
test=`ifconfig | grep venet0`
if [[ ! -z $test ]]; then
IPPORT='venet0'
eth0="$UP"
else
# IPPORT=`ifconfig | head -n 1 | cut -f 1 -d ":"`
IPPORT=`ifconfig |tail -n 8 | head -n 1 | cut -f 1 -d ":"`
test=`/sbin/ifconfig | grep -c inet`
if [ "$test" -lt "1" ]; then
eth0="$DN"
else
eth0="$UP"
fi
fi
RAM=`free | grep -m 2 ^ | tr -s " " | tail -1 | cut -f 4 -d " "`
DISK=`df -h | grep /dev/ | tr -s " " | head -n 1 | cut -f 4 -d " "`
test=`ps aux | grep -c "node/index.js"`
if [ "$test" -gt "0" ]; then
gvoauth="$NA"
else
gvoauth="$NA"
fi
test=`ps aux | grep -c hfaxd`
if [ "$test" -lt "2" ]; then
hfax="$DN"
else
hfax="$UP"
fi
test=`ps aux | grep -c openvpn`
if [ "$test" -lt "2" ]; then
nrclient="$DN"
else
nrclient="$UP"
fi
test=`ps aux | grep -c faxgetty`
if [ "$test" -lt "2" ]; then
faxgetty="$DN"
else
faxgetty="$UP"
fi
test=`ps aux | grep -c iaxmodem`
if [ "$test" -lt "2" ]; then
iaxmodem="$DN"
else
iaxmodem="$UP"
fi
test=`ps aux | grep -c knockd`
if [ "$test" -lt "2" ]; then
knockd="$DN"
else
knockd="$UP"
fi
#TITLE="Incredible PBX $version for Debian `cat /etc/debian_version` Buster"
#TITLE="Incredible PBX $version for Ubuntu 22.04"
TITLE="FS PBX $fspbxversion for "`cat /etc/os-release | grep PRETTY_NAME | cut -f 2 -d '"' | cut -f 1 -d "("`
NOW=`date`
TOP="\n\ZbFreeSwch\ZB: $asterisk \Zb NGINX/$phpversion\ZB: $apache \ZbPostgrs\ZB: $mysql\n\Zb Postfix\ZB: $postfix \ZbIPtables\ZB: $IPtables \ZbSSH\ZB: $ssh\n\ZbLAN\ZB: $eth0 \ZbFail2Ban\ZB: $fail2ban \ZbOpenVPN\ZB: $nrclient\n\n\Zr\Z4\Zb"
TOP="\n\ZbFreeSwch\ZB: $asterisk \Zb NGINX/$phpversion\ZB: $apache \ZbPostgrs\ZB: $mysql\n\Zb Postfix\ZB: $postfix \ZbIPtables\ZB: $IPtables \Zb SSH\ZB: $ssh\n\ZbLAN port\ZB: $eth0 \ZbFail2Ban\ZB: $fail2ban \ZbOpenVPN\ZB: $nrclient\n\Zb\ZB\Zb\n\Zr\Z4\Zb"
if [ -d "/root/gvsip-naf" ]; then
TOP="\n\ZbFreeSwch\ZB: $asterisk \Zb NGINX/$phpversion\ZB: $apache \ZbPostgrs\ZB: $mysql\n\Zb Postfix\ZB: $postfix \ZbIPtables\ZB: $IPtables \ZbSSH\ZB: $ssh\n\ZbLAN port\ZB: $eth0 \ZbFail2Ban\ZB: $fail2ban \ZbOpenVPN\ZB: $nrclient\n\ZbGVSIPNAF\ZB: $gvoauth \Zb PortKnock\ZB: $knockd \ZbNR VPN\ZB: $nrclient\n\ZbFaxGetty\ZB: $faxgetty \Zb IAX Modem\ZB: $iaxmodem \ZbHylaFax\ZB: $hfax\n\n\Zr\Z4\Zb"
fi
MID="RAM\ZB:$RAM Debian $OSrelease \ZbDisk\ZB:$DISK \ZR\Z0\n\n\Z5\ZB"
BOT="\ZB\Z0\Zb$_IP\n\n$_PUBLIC\ZB\n\n\ZbSystem Time: $NOW\Zb"
MSGLEN=`echo ${#MID}`
if [ "$MSGLEN" -gt "67" ]; then
MID2=`echo $MID| sed -e 's/ / /g'`
MID=`echo $MID2| sed -e 's/Disk/ Disk/g'`
fi
MSG="$TOP $MID$BOT"
dialog --no-lines --colors --title "$TITLE" --msgbox "$MSG" 16 49
clear -x