#!/bin/bash
# //====================================================
# //	System Request:Debian 9+/Ubuntu 18.04+/20+
# //	Author:	bhoikfostyahya
# //	Dscription: Xray Menu Management
# //	email: admin@bhoikfostyahya.com
# //  telegram: https://t.me/bhoikfost_yahya
# //====================================================
# // font color configuration | BHOIKFOST YAHYA AUTOSCRIPT
# COLOR VALIDATION

RED='\033[0;31m'
NC='\033[0m'
gray="\e[1;30m"
Blue="\033[36m"
GREEN='\033[0;32m'
grenbo="\e[92;1m"
yellow='\033[0;33m'
ISP=$(cat /etc/xray/isp)
CITY=$(cat /etc/xray/city)
domain=$(cat /etc/xray/domain)
WKT=$(curl -s ipinfo.io/timezone)
IPVPS=$(curl -s ipv4.icanhazip.com)
tram=$(free -m | awk 'NR==2 {print $2}')
swap=$(free -m | awk 'NR==4 {print $2}')
freq=$(awk -F: ' /cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo)
cores=$(awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo)
cname=$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo)
Exp=$(curl -sS https://kytvpn.xcodehoster.com/izin | grep $IPVPS | awk '{print $3}')
Name=$(curl -sS https://kytvpn.xcodehoster.com/izin | grep $IPVPS | awk '{print $2}')
Open_SSH=$(systemctl status ssh | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
Dropbear=$(systemctl status dropbear | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
Dropbear_Websocket=$(systemctl status dropbear | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
SSH_Websocket=$(systemctl status ws | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
OpenVPN=$(systemctl status openvpn | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
Nginx_Webserver=$(systemctl status nginx | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
Haproxy=$(systemctl status haproxy | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
DNS_Server=$(systemctl status server | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
DNS_Client=$(systemctl status client | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
OpenVPN_Websocket=$(systemctl status ws | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
XRAY_Vmess_TLS=$(systemctl status haproxy | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
XRAY_Vmess_gRPC=$(systemctl status haproxy | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
XRAY_Vmess_None_TLS=$(systemctl status haproxy | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
XRAY_Vless_TLS=$(systemctl status haproxy | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
XRAY_Vless_gRPC=$(systemctl status haproxy | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
XRAY_Vless_None_TLS=$(systemctl status haproxy | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
Trojan_gRPC=$(systemctl status haproxy | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
Trojan_WS=$(systemctl status haproxy | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
Shadowsocks_WS=$(systemctl status haproxy | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
Shadowsocks_gRPC=$(systemctl status haproxy | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
Iptables=$(systemctl status netfilter-persistent | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
Squid=$(systemctl status squid | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
BadVPN=$(systemctl status badvpn3 | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
RClocal=$(systemctl status rc-local | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
Autorebot=$(systemctl status rc-local | grep active | awk '{print $3}' | sed 's/(//g' | sed 's/)//g')
OSSSS=$(cat /etc/os-release | grep -w PRETTY_NAME | head -n1 | sed 's/=//g' | sed 's/"//g' | sed 's/PRETTY_NAME//g')
if [[ $Open_SSH == "running" ]]; then
    status_1="🟢 Online"
else
    status_1="🔴 Offline"
fi

if [[ $Dropbear == "running" ]]; then
    status_2="🟢 Online"
else
    status_2="🔴 Offline"
fi

if [[ $Dropbear_Websocket == "running" ]]; then
    status_3="🟢 Online"
else
    status_3="🔴 Offline"
fi

if [[ $SSH_Websocket == "running" ]]; then
    status_4="🟢 Online"
else
    status_4="🔴 Offline"
fi

if [[ $OpenVPN == "exited" ]]; then
    status_5="🟢 Online"
else
    status_5="🔴 Offline"
fi

if [[ $Nginx_Webserver == "running" ]]; then
    status_6="🟢 Online"
else
    status_6="🔴 Offline"
fi

if [[ $Haproxy == "running" ]]; then
    status_7="🟢 Online"
else
    status_7="🔴 Offline"
fi

if [[ $DNS_Server == "running" ]]; then
    status_8="🟢 Online"
else
    status_8="🔴 Offline"
fi

if [[ $DNS_Client == "running" ]]; then
    status_9="🟢 Online"
else
    status_9="🔴 Offline"
fi

if [[ $OpenVPN_Websocket == "running" ]]; then
    status_10="🟢 Online"
else
    status_10="🔴 Offline"
fi

if [[ $XRAY_Vmess_TLS == "running" ]]; then
    status_11="🟢 Online"
else
    status_11="🔴 Offline"
fi

if [[ $XRAY_Vmess_gRPC == "running" ]]; then
    status_12="🟢 Online"
else
    status_12="🔴 Offline"
fi

if [[ $XRAY_Vmess_None_TLS == "running" ]]; then
    status_13="🟢 Online"
else
    status_13="🔴 Offline"
fi

if [[ $XRAY_Vless_TLS == "running" ]]; then
    status_14="🟢 Online"
else
    status_14="🔴 Offline"
fi

if [[ $XRAY_Vless_gRPC == "running" ]]; then
    status_15="🟢 Online"
else
    status_15="🔴 Offline"
fi

if [[ $XRAY_Vless_None_TLS == "running" ]]; then
    status_16="🟢 Online"
else
    status_16="🔴 Offline"
fi

if [[ $Trojan_gRPC == "running" ]]; then
    status_17="🟢 Online"
else
    status_17="🔴 Offline"
fi

if [[ $Trojan_WS == "running" ]]; then
    status_18="🟢 Online"
else
    status_18="🔴 Offline"
fi

if [[ $Shadowsocks_WS == "running" ]]; then
    status_19="🟢 Online"
else
    status_19="🔴 Offline"
fi

if [[ $Shadowsocks_gRPC == "running" ]]; then
    status_20="🟢 Online"
else
    status_20="🔴 Offline"
fi

if [[ $Iptables == "exited" ]]; then
    status_21="🟢 Online"
else
    status_21="🔴 Offline"
fi

if [[ $Squid == "running" ]]; then
    status_22="🟢 Online"
else
    status_22="🔴 Offline"
fi

if [[ $BadVPN == "running" ]]; then
    status_23="🟢 Online"
else
    status_23="🔴 Offline"
fi

if [[ $RClocal == "exited" ]]; then
    status_24="🟢 Online"
else
    status_24="🔴 Offline"
fi

if [[ $Autorebot == "exited" ]]; then
    status_25="🟢 Online"
else
    status_25="🔴 Offline"
fi
printf "
◇━━━━━━━━━━━━━━━━━━━━━━━◇
  🔥⇱ Service Info ⇲🔥   
◇━━━━━━━━━━━━━━━━━━━━━━━◇
Open_SSH        : $status_1
Dropbear        : $status_2
Dropbear_WS     : $status_3
SSH_Websocket   : $status_4
OpenVPN         : $status_5
Nginx_Webserver : $status_6
Haproxy         : $status_7
DNS_Server      : $status_8
DNS_Client      : $status_9
OpenVPN_WS      : $status_10
Xray_Vmess_TLS  : $status_11
Xray_Vmess_gRPC : $status_12
Xray_Vmess_NTLS : $status_13
Xray_Vless_TLS  : $status_14
Xray_Vless_gRPC : $status_15
Xray_Vless_NTLS : $status_16
Trojan_gRPC     : $status_17
Trojan_WS       : $status_18
Shadowsocks_WS  : $status_19
Shadowsocks_gRPC: $status_20
Iptables        : $status_21
Squid           : $status_22
BadVPN          : $status_23
RClocal         : $status_24
Autoreboot      : $status_25
◇━━━━━━━━━━━━━━━━━━━━━━━◇
"

