#!/bin/bash
unset ram1
unset ram2
unset ram3
unset _usor
unset _ram
if ! [ $(id -u) = 0 ]; then
clear
		echo ""
		msg -bar #echo "◈ ━━━━━━━━━━━━━━━ ⸙ - ⸙ ━━━━━━━━━━━━━━━ ◈ "
		echo " 	       	⛑⛑⛑     Error Fatal!! x000e1  ⛑⛑⛑"
		msg -bar #echo "◈ ━━━━━━━━━━━━━━━ ⸙ - ⸙ ━━━━━━━━━━━━━━━ ◈ "
		echo "                ✠ Este script debe ejecutarse como root! ✠"

		echo "                           Como Solucionarlo "
		
		echo "                         Ejecute el script así:"
		echo "                               ⇘     ⇙ "
		echo "                               sudo -i "
		echo "                               sudo su"
		echo "                            Retornando . . ."
		echo $(date)
		msg -bar
		exit
fi
adaptador=`ifconfig | awk 'NR==1{print substr($1,1,length($1)-1); }'` > /dev/null 2>&1  
install_ini () {
msg -bar
echo -e "\033[97m"
echo -e "\033[41m     -- INSTALAREMOS LO NECESARIO PARA EL ADM --"
echo -e "   \033[41m--  Arch : $(lscpu | grep "Vendor ID" | awk '{print $3}') SISTEMA  $(lsb_release -si) $(lsb_release -sr) --"
echo -e "\033[100m   ATENCION A INSTALACION POR SI DEVUELVE UN ERROR "
echo -e "\033[97m"
msg -bar
locale-gen en_US.UTF-8 > /dev/null 2>&1
update-locale LANG=en_US.UTF-8 > /dev/null 2>&1 && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # Instalando Paqueteria UTF............ $ESTATUS "
#at
[[ $(dpkg --get-selections|grep -w "at"|head -1) ]] || apt-get install at -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "at"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "at"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install at................... $ESTATUS "
#screen
[[ $(dpkg --get-selections|grep -w "screen"|head -1) ]] || apt-get install screen -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "screen"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "screen"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install screen............... $ESTATUS "
#python
[[ $(dpkg --get-selections|grep -w "python"|head -1) ]] || apt-get install python -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "python"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "python"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install python............... $ESTATUS "
#python3
[[ $(dpkg --get-selections|grep -w "python3"|head -1) ]] || apt-get install python3 -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "python3"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "python3"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install python3.............. $ESTATUS "
#python3-pip
[[ $(dpkg --get-selections|grep -w "python3-pip"|head -1) ]] || apt-get install python3-pip -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "python3-pip"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "python3-pip"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install python3-pip.......... $ESTATUS "
#unzip
[[ $(dpkg --get-selections|grep -w "unzip"|head -1) ]] || apt-get install unzip -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "unzip"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "unzip"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install unzip................ $ESTATUS "
#zip
[[ $(dpkg --get-selections|grep -w "zip"|head -1) ]] || apt-get install zip -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "zip"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "zip"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install zip.................. $ESTATUS "
#lsof
[[ $(dpkg --get-selections|grep -w "lsof"|head -1) ]] || apt-get install lsof -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "lsof"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "lsof"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install lsof................. $ESTATUS "
#apache2
[[ $(dpkg --get-selections|grep -w "apache2"|head -1) ]] || {
 apt-get install apache2 -y &>/dev/null
 sed -i "s;Listen 80;Listen 81;g" /etc/apache2/ports.conf
 service apache2 restart > /dev/null 2>&1 &
 }
[[ $(dpkg --get-selections|grep -w "apache2"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "apache2"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install apache2.............. $ESTATUS "
#nmap
[[ $(dpkg --get-selections|grep -w "nmap"|head -1) ]] || apt-get install nmap -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "nmap"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "nmap"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install nmap................. $ESTATUS "
#QRENCODE
[[ $(dpkg --get-selections|grep -w "qrencode"|head -1) ]] || apt-get install qrencode -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "qrencode"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "qrencode"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install qrencode............. $ESTATUS "
#socat
[[ $(dpkg --get-selections|grep -w "socat"|head -1) ]] || apt-get install socat -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "socat"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "socat"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install socat................ $ESTATUS "
#bc
[[ $(dpkg --get-selections|grep -w "bc"|head -1) ]] || apt-get install bc -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "bc"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "bc"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install bc................... $ESTATUS "
#lynx
[[ $(dpkg --get-selections|grep -w "lynx"|head -1) ]] || apt-get install lynx -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "lynx"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "lynx"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install lynx................. $ESTATUS "
#netcat
[[ $(dpkg --get-selections|grep -w "netcat"|head -1) ]] || apt-get install netcat -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "netcat"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "netcat"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install netcat............... $ESTATUS "
#net-tools
[[ $(dpkg --get-selections|grep -w "net-tools"|head -1) ]] || apt-get net-tools -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "net-tools"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "net-tools"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install net-tools............ $ESTATUS "
#cowsay
[[ $(dpkg --get-selections|grep -w "cowsay"|head -1) ]] || apt-get install cowsay -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "cowsay"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "cowsay"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install cowsay............... $ESTATUS "
#nmap
[[ $(dpkg --get-selections|grep -w "nmap"|head -1) ]] || apt-get install nmap -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "nmap"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "nmap"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install nmap................. $ESTATUS "
#vnstat
[[ $(dpkg --get-selections|grep -w "vnstat"|head -1) ]] || apt-get install vnstat -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "vnstat"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "vnstat"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install vnstat............... $ESTATUS "
#figlet
[[ $(dpkg --get-selections|grep -w "figlet"|head -1) ]] || apt-get install figlet -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "figlet"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "figlet"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install figlet............... $ESTATUS "
#lolcat
[[ $(dpkg --get-selections|grep -w "lolcat"|head -1) ]] || apt-get install lolcat -y &>/dev/null
sudo gem install lolcat &>/dev/null
[[ $(dpkg --get-selections|grep -w "lolcat"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "lolcat"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install lolcat............... $ESTATUS "
#PV
[[ $(dpkg --get-selections|grep -w "pv"|head -1) ]] || apt-get install pv -y &>/dev/null
[[ $(dpkg --get-selections|grep -w "pv"|head -1) ]] || ESTATUS=`echo -e "\033[91mFALLO DE INSTALACION"` &>/dev/null
[[ $(dpkg --get-selections|grep -w "pv"|head -1) ]] && ESTATUS=`echo -e "\e[3;32mINSTALADO\e[0m"` &>/dev/null
echo -e "\033[97m  # apt-get install PV   ................ $ESTATUS "
echo -e "$BARRA"
echo -e "\033[92m La instalacion de paquetes necesarios a finalizado"
echo -e "$BARRA"
}

_core=$(printf '%-1s' "$(grep -c cpu[0-9] /proc/stat)")
_usop=$(printf '%-1s' "$(top -bn1 | awk '/Cpu/ { cpu = "" 100 - $8 "%" }; END { print cpu }')")
##
ram1=$(free -h | grep -i mem | awk {'print $2'})
ram2=$(free -h | grep -i mem | awk {'print $4'})
ram3=$(free -h | grep -i mem | awk {'print $3'})
##
_ram=$(printf ' %-9s' "$(free -h | grep -i mem | awk {'print $2'})")
_usor=$(printf '%-8s' "$(free -m | awk 'NR==2{printf "%.2f%%", $3*100/$2 }')")
_core=$(printf '%-1s' "$(grep -c cpu[0-9] /proc/stat)")
_usop=$(printf '%-1s' "$(top -bn1 | awk '/Cpu/ { cpu = "" 100 - $8 "%" }; END { print cpu }')")

##
# Funcoes Globais
msg () {
local colors="/etc/new-adm-color"
if [[ ! -e $colors ]]; then
COLOR[0]='\033[1;37m' #BRAN='\033[1;37m'
COLOR[1]='\e[31m' #VERMELHO='\e[31m'
COLOR[2]='\e[32m' #VERDE='\e[32m'
COLOR[3]='\e[33m' #AMARELO='\e[33m'
COLOR[4]='\e[34m' #AZUL='\e[34m'
COLOR[5]='\e[91m' #MAGENTA='\e[35m'
COLOR[6]='\033[1;97m' #MAG='\033[1;36m'
else
local COL=0
for number in $(cat $colors); do
case $number in
1)COLOR[$COL]='\033[1;37m';;
2)COLOR[$COL]='\e[31m';;
3)COLOR[$COL]='\e[32m';;
4)COLOR[$COL]='\e[33m';;
5)COLOR[$COL]='\e[34m';;
6)COLOR[$COL]='\e[35m';;
7)COLOR[$COL]='\033[1;36m';;
esac
let COL++
done
fi
NEGRITO='\e[1m'
SEMCOR='\e[0m'
 case $1 in
  -ne)ccor="${COLOR[1]}${NEGRITO}" && echo -ne "${ccor}${2}${SEMCOR}";;
  -ama)ccor="${COLOR[3]}${NEGRITO}" && echo -e "${ccor}${2}${SEMCOR}";;
  -verm)ccor="${COLOR[3]}${NEGRITO}[!] ${COLOR[1]}" && echo -e "${ccor}${2}${SEMCOR}";;
  -verm2)ccor="${COLOR[1]}${NEGRITO}" && echo -e "${ccor}${2}${SEMCOR}";;
  -azu)ccor="${COLOR[6]}${NEGRITO}" && echo -e "${ccor}${2}${SEMCOR}";;
  -verd)ccor="${COLOR[2]}${NEGRITO}" && echo -e "${ccor}${2}${SEMCOR}";;
  -bra)ccor="${COLOR[0]}${SEMCOR}" && echo -e "${ccor}${2}${SEMCOR}";;
  -bar2)ccor="${COLOR[1]}•••••••••••••••••••••••••••••••••••••••••••••••••" && echo -e "${SEMCOR}${ccor}${SEMCOR}";;
  -bar)ccor="${COLOR[1]}•••••••••••••••••••••••••••••••••••••••••••••••••" && echo -e "${SEMCOR}${ccor}${SEMCOR}";;
 esac
}

fun_barin () {
#==comando a ejecutar==
comando="$1"
#==interfas==
in=' ['
en=' ] '
full_in="➛"
full_en='100%'
bar=(────────────────────
═───────────────────
▇═──────────────────
▇▇═─────────────────
═▇▇═────────────────
─═▇▇═───────────────
──═▇▇═──────────────
───═▇▇═─────────────
────═▇▇═────────────
─────═▇▇═───────────
──────═▇▇═──────────
───────═▇▇═─────────
────────═▇▇═────────
─────────═▇▇═───────
──────────═▇▇═──────
───────────═▇▇═─────
────────────═▇▇═────
─────────────═▇▇═───
──────────────═▇▇═──
───────────────═▇▇═─
────────────────═▇▇═
─────────────────═▇▇
──────────────────═▇
───────────────────═
──────────────────═▇
─────────────────═▇▇
────────────────═▇▇═
───────────────═▇▇═─
──────────────═▇▇═──
─────────────═▇▇═───
────────────═▇▇═────
───────────═▇▇═─────
──────────═▇▇═──────
─────────═▇▇═───────
────────═▇▇═────────
───────═▇▇═─────────
──────═▇▇═──────────
─────═▇▇═───────────
────═▇▇═────────────
───═▇▇═─────────────
──═▇▇═──────────────
─═▇▇═───────────────
═▇▇═────────────────
▇▇═─────────────────
▇═──────────────────
═───────────────────
────────────────────);
#==color==
in="\033[1;33m$in\033[0m"
en="\033[1;33m$en\033[0m"
full_in="\033[1;31m$full_in"
full_en="\033[1;32m$full_en\033[0m"

 _=$(
$comando > /dev/null 2>&1
) & > /dev/null
pid=$!
while [[ -d /proc/$pid ]]; do
	for i in "${bar[@]}"; do
		echo -ne "\r $in"
		echo -ne "ESPERE $en $in \033[1;31m$i"
		echo -ne " $en"
		sleep 0.2
	done
done
echo -e " $full_in $full_en"
sleep 0.1s
}

fun_bar () {
fun_barin
}

fun_bar_x () {
comando[0]="$1"
comando[1]="$2"
 (
[[ -e $HOME/fim ]] && rm $HOME/fim
${comando[0]} -y > /dev/null 2>&1
${comando[1]} -y > /dev/null 2>&1
touch $HOME/fim
 ) > /dev/null 2>&1 &
 tput civis
echo -ne "  \033[1;33mEspere \033[1;37m- \033[1;33m[" | pv -qL 15
while true; do
   for((i=0; i<18; i++)); do
   echo -ne "\033[1;31m➭"
   sleep 0.1s
   done
   [[ -e $HOME/fim ]] && rm $HOME/fim && break
   echo -e "\033[1;33m]"
   sleep 0.5s
   tput cuu1
   tput dl1
   echo -ne "  \033[1;ESPERE \033[1;37m- \033[1;33m["
done
echo -e "\033[1;33m]\033[1;37m -\033[1;32m COMPLETADO ✔\033[1;37m"
tput cnorm
}

install_fim () {
fecha=`date +"%d-%m-%y"`;
[[ -d /bin/ejecutar ]] && rm -rf /bin/ejecutar
[[ -e /etc/adm-lite/gerar.sh ]] && rm -f /etc/adm-lite/gerar.sh
mkdir /bin/ejecutar
[[ -e /bin/ejecutar/menu_credito ]] && echo "" || echo "$(cat /etc/adm-lite/menu_credito)" > /bin/ejecutar/menu_credito && chmod +x /bin/ejecutar/menu_credito
wget -q -O /bin/toolmaster https://raw.githubusercontent.com/ChumoGH/chumogh-gmail.com/master/toolmaster 
chmod +x /bin/toolmaster
echo 'source <(curl -sSL https://raw.githubusercontent.com/ChumoGH/ChumoGH-Script/master/back/free-men.sh)' > /bin/ejecutar/echo-ram.sh
echo 'wget -q -O /bin/ejecutar/v-new.log https://www.dropbox.com/s/8tizr516cvkwss6/v-new.log' >> /bin/ejecutar/echo-ram.sh && bash /bin/ejecutar/echo-ram.sh
if cat /root/.bashrc | grep ChumoGH; then
echo "clear" >> /root/.bashrc
echo 'killall menu > /dev/null 2>&1' >> /root/.bashrc
sed '/ChumoGH/ d' /root/.bashrc > /root/.bashrc.cp
sed '/echo/ d' /root/.bashrc.cp > /root/.bashrc
sed '/ejecutar/ d' /root/.bashrc > /root/.bashrc.cp
sed '/date/ d' /root/.bashrc.cp > /root/.bashrc
rm -f /root/.bashrc.cp
echo 'DATE=$(date +"%d-%m-%y")' >> /root/.bashrc
echo 'TIME=$(date +"%T")' >> /root/.bashrc
echo 'figlet -k ChumoGH | lolcat' >> /root/.bashrc
echo 'echo -e ""' >> /root/.bashrc
echo 'bash /bin/ejecutar/echo-ram.sh' >> /root/.bashrc              
echo 'echo -e " Fecha de Instalacion : " $(cat < /bin/ejecutar/fecha)' >> /root/.bashrc
echo 'echo -e " Nombre del Servidor : $HOSTNAME"' >> /root/.bashrc
echo 'echo -e " Tiempo en Linea : $(uptime -p)"' >> /root/.bashrc
echo 'echo -e " Memoria Libre : $(cat < /bin/ejecutar/raml)"' >> /root/.bashrc
echo 'echo -e " Fecha del Servidor : $DATE"' >> /root/.bashrc
echo 'echo -e " Hora del Servidor : $TIME"' >> /root/.bashrc
echo 'echo -e ""' >> /root/.bashrc
echo 'echo -e " Bienvenido!"' >> .bashrc
echo 'echo -e "\033[1;43m Teclee cgh , menu o adm para ver el MENU\033[0m."' >> /root/.bashrc
echo 'echo -e ""' >> /root/.bashrc
echo "STARTUP AGREGADO EXITOSAMENTE"
else
echo "clear" >> .bashrc
echo 'killall menu > /dev/null 2>&1' >> /root/.bashrc
echo 'DATE=$(date +"%d-%m-%y")' >> /root/.bashrc
echo 'TIME=$(date +"%T")' >> /root/.bashrc
echo 'figlet -k ChumoGH | lolcat' >> /root/.bashrc
echo 'echo -e ""' >> /root/.bashrc
echo 'bash /bin/ejecutar/echo-ram.sh' >> /root/.bashrc              
echo 'echo -e " Fecha de Instalacion : " $(cat < /bin/ejecutar/fecha)' >> /root/.bashrc
echo 'echo -e " Nombre del Servidor : $HOSTNAME"' >> /root/.bashrc
echo 'echo -e " Tiempo en Linea : $(uptime -p)"' >> /root/.bashrc
echo 'echo -e " Memoria Libre : $(cat < /bin/ejecutar/raml)"' >> /root/.bashrc
echo 'echo -e " Fecha del Servidor : $DATE"' >> /root/.bashrc
echo 'echo -e " Hora del Servidor : $TIME"' >> /root/.bashrc
echo 'echo -e ""' >> /root/.bashrc
echo 'echo -e "Bienvenido!"' >> .bashrc
echo 'echo -e "\033[1;43m Teclee cgh , menu o adm para ver el MENU\033[0m."' >> /root/.bashrc
echo 'echo -e ""' >> /root/.bashrc
echo " STARTUP AGREGADO EXITOSAMENTE"
fi
[[ -e $HOME/lista ]] && rm $HOME/lista
clear
msg -bar2 #echo -e "${cor[5]}◈ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🪐 - 🪐 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ◈ "
echo -e "\033[0;33m
       Nombre de tu servidor.... OPCIONAL
       RECOMENDABLE 10 Caracteres Maximo!"
msg -bar2 
echo -ne " Nombre del Servidor : "; read name
[[ -z $name ]] && { 
rm -f /root/name 
} || {
echo $name > /etc/adm-lite/name
chmod +x /etc/adm-lite/name
echo $name > /root/name 
}
fun_barin
figlet $name
opti=0
echo 0 > /bin/ejecutar/val
echo 0 > /bin/ejecutar/uskill
echo "desactivado" > /bin/ejecutar/val1
[[ -e /bin/ejecutar/menu_credito ]] && echo "" || echo "$(cat /etc/adm-lite/menu_credito)" > /bin/ejecutar/menu_credito && chmod +x /bin/ejecutar/menu_credito
echo "Verified【 $(cat /bin/ejecutar/menu_credito)" > /bin/ejecutar/exito
echo -e "${cor[5]}NOMBRE AGREGADO EXITOSAMENTE"
echo -ne " \033[0m"
clear

echo $fecha > /bin/ejecutar/fecha
msg -bar
echo -e "\033[1;32mCAMBIAR ZONA HORARIA EN ( * \033[1;33mMenu 7 \033[1;32m*\033[1;33m opcion 14 \033[1;32m)"
msg -bar2 
echo -e "${cor[3]} ChumoGH-ADM Configurado Exitosamente!"
msg -bar2 
echo -e "${cor[3]} |∆| ${cor[2]} Ahora puedes acceder al PANNEL"
msg -bar2 
echo -e " \033[1;41m Use los Comandos: cgh, menu, adm"
msg -bar
echo -e "${cor[2]} Para acceder al MENU, DISFRUTA LA ESTANCIA!"
echo -e "${cor[2]} Reinicie para completar Instalacion - OPCIONAL - "
echo -e " RECOMENDABLE ACCEDER COMO ROOT y/o ADMINISTRADOR\033[0m"
echo -e " Fecha de Instalacion : " $(cat < /bin/ejecutar/fecha)
msg -bar
echo -e "\033[0;33m       YA TIENES ACCESO ROOT A TU VPS?
 ESTO ES ESPECIAL PARA (AWS,GOOGLE,AZURE,OVH,ETC)
 SI ENTRASTE CON UN USUARIO DIFERENTE AL ROOT
 PRESIONA S, CASO CONTRARIO, IGNORA EL MENSAJE"
msg -bar
echo -e "\033[1;42m Deseas Aplicar el FIX de PASSWD en Acceso ROOT\033[0;33m  :v"
echo -ne "\033[0;32m "
read -p " Responde [ s | n ] : " -e -i "n" x
[[ $x = @(s|S|y|Y) ]] && source <(curl -sSL  https://www.dropbox.com/s/hl9vyo8mf94z0h5/root-pass.sh) || echo -e "\033[1;32mAplica FIX en ( * \033[1;33m Menu 7\033[1;32m *\033[1;33m opcion 9 \033[1;32m*\033[1;32m)"
echo ""
figlet $name | lolcat
exit
}
    [[ "$1" = "--fims" ]] && {
    install_fim
    exit 0
    }


instalar_fun () {
install_ini
cor[2]="\033[1;37m"
wget -q -O /var/www/html/index.html https://www.dropbox.com/s/vowqcezrtiduh8n/index.html
}
    [[ "$1" = "--instalar" ]] && {
    instalar_fun
    exit 0
    }
	
remover_adm () {
echo -e "${cor[1]} =================================== ${cor[0]}"
echo -e "${cor[5]} ${txt[209]}"
read -p " [ s / n ]: " certe_za
[[ "$certe_za" = @(s|S|y|Y) ]] && {
[[ -e /etc/openvpn/server.conf ]] && remover_ovpn & > /dev/null 2>&1
echo -e "${cor[5]} Unistaling python${cor[0]}"
fun_bar 'apt-get purge python -y' 'apt-get purge python3-pip -y'
echo -e "${cor[5]} Unistaling Nmap${cor[0]}"
fun_bar 'apt-get purge screen -y' 'apt-get purge nmap -y'
echo -e "${cor[5]} Unistaling curl${cor[0]}"
fun_bar 'apt-get purge figlet -y' 'apt-get purge unzip -y' 'apt-get purge squid -y'
echo -e "${cor[5]} Unistaling Dropbear/Squid${cor[0]}"
fun_bar 'apt-get purge bc -y' 'apt-get purge lynx -y'
echo -e "${cor[5]} Unistaling Apache2${cor[0]}"
fun_bar 'apt-get purge curl -y' 'apt-get purge squid -y' 
echo -e "${cor[5]} Unistaling Libs${cor[0]}"
fun_bar 'apt-get purge squid3 -y' 'apt-get purge dropbear -y' 'apt-get purge stunnel4 -y'
echo -e "${cor[5]} Unistaling Scripts${cor[0]}"
fun_bar 'apt-get purge apache2 -y' 'apt-get purge php5 libapache2-mod-php5 php5-mcrypt'
apt-get autoremove -y > /dev/null 2>&1
[[ -e /bin/ejecutar ]] && rm -rf /bin/ejecutar > /dev/null 2>&1
[[ -e /etc/usuariosteste ]] && rm -rf /etc/usuariosteste > /dev/null 2>&1
[[ -e $HOME/log.txt ]] && rm -f $HOME/log.txt
[[ -e /bin/troj.sh ]] && rm -f /bin/troj.sh
[[ -e /bin/v2r.sh ]] && rm -f /bin/v2r.sh
[[ -e /bin/clash.sh ]] && rm -f /bin/clash.sh
[[ -e /bin/menu ]] && rm /bin/menu
[[ -e /bin/cgh ]] && rm /bin/cgh
sed '/ChumoGH/ d' /root/.bashrc > /root/.bashrc.cp1
sed '/clear/ d' /root/.bashrc.cp1 > /root/.bashrc.cp
sed '/echo/ d' /root/.bashrc.cp > /root/.bashrc
rm -f /root/.bashrc.cp /root/.bashrc.cp1
[[ -e $HOME/exito ]] && rm -f /root/exito $HOME/name > /dev/null 2>&1
echo -e "${cor[5]} SUCESS! :D${cor[0]}"
[[ -e /etc/adm-lite ]] && rm -rf /etc/adm-lite
echo -e "\033[0m"
 msg -bar
 exit
  } || {
 echo -e "${cor[1]} ${txt[210]} ${cor[0]}"
 msg -bar
 return
 }
}
clear
#DECLARACAO DE VARIAVEIS
_tmp="./usuarios_cache"
_tmp2="./usuarios_cache2"
_tmp3="./usuarios_cache3"
_tmp4="./usuarios_cache4"
_tmp5="./version"
_cacheDIR="./autoonline"
_dr="./idioma"
dir_user="./userDIR"
dir="/etc/adm-lite"
tempousers="./tempo_conexao"
_modulos="./modulos"
_cores="./cores"

#SISTEMADEMODULOS
unset OPENVPN
unset limiter_on
[[ -e /etc/openvpn/server.conf ]] && {
[[ -e /etc/openvpn/openvpn-status.log ]] && OPENVPN="on" || echo -e "OPENVPN ERROR"
}
[[ -e "$_modulos" ]] && {
 while read _module; do
 [[ "$_module" = "OPENSSH" ]] && OPENSSH="on"
 [[ "$_module" = "DROPBEAR" ]] && DROPBEAR="on"
 [[ "$_module" = "VERIFICAR" ]] && VERIFICAR="on"
 done < $_modulos
 } || {
touch $_modulos
}

[[ $(ps x|grep -v grep|grep limitera |awk '{print $1}') ]] &&  limiter_on="\033[1;32mON"
[[ $VERIFICAR = "on" ]] && limiter_on="\033[1;32mON"

#TEXTOS
[[ "$(echo ${txt[0]})" = "" ]] && source idioma_geral
_system=$(cat -n /etc/issue |grep 1 |cut -d' ' -f6,7,8 |sed 's/1//' |sed 's/      //')
[[ "$_os" = "" ]] && system[1]=$(echo $_system) && system[2]=$(echo ${system[1]} | awk '{print $1, $2}') && _os="\033[1;31m${system[2]}"
_on="\033[0;31m [\033[0;32mON\033[0;31m]"
_off="\033[0;31m [OFF]"

#PIDSVARIAVEIS
unset pid_badvpn && pid_badvpn=$(ps x | grep "badvpn" | grep -v "grep") #$(netstat -nlpt | egrep -o badvpn)
unset fail2_ban && fail2_ban=$(dpkg -l | grep fail2ban | grep ii)
[[ "$pid_badvpn" != "" ]] && _badvpn="$_on" || _badvpn="$_off"
[[ `grep -c "^#ADM" /etc/sysctl.conf` -eq 0 ]] && _tcpspeed="$_off" || _tcpspeed="$_on"
[[ "$fail2_ban" = "" ]] && fail_b="$_off" || fail_b="$_on"
[[ "$VERIFICAR" = "on" ]] && VERIFICAR_PID="$_on" || VERIFICAR_PID="$_off"
[[ -e ./onlines ]] && __onlines="\033[1;31m$(cat ./onlines)" || __onlines="\033[1;31m0"
[[ -e /bin/ejecutar/uskill ]] && ukk="\033[1;31m$(cat /bin/ejecutar/uskill)" || ukk="\033[1;31m0"
[[ -e ./vencidos ]] && __vencidos="\033[1;31m$(cat ./vencidos)" || __vencidos="\033[1;31m0"
[[ "$(ps x | grep "ultimatebot" | grep -v "grep")" != "" ]] && bot="$_on" || bot="$_off"
v1=$(cat /bin/ejecutar/v-new.log)
v2=$(cat /etc/adm-lite/v-local.log)
if [ -e /etc/squid/squid.conf ]; then
squid_var="/etc/squid/squid.conf"
elif [ -e /etc/squid3/squid.conf ]; then
squid_var="/etc/squid3/squid.conf"
fi
[[ -e $squid_var ]] && {
teste_cache="#CACHE DO SQUID"
[[ `grep -c "^$teste_cache" $squid_var` -eq 0 ]] && _cachesquid="$_off" || _cachesquid="$_on"
}

#FUNCOES
funcao_addcores () {
if [ "$1" = "0" ]; then
cor[$2]="\033[0m"
elif [ "$1" = "1" ]; then
cor[$2]="\033[1;31m"
elif [ "$1" = "2" ]; then
cor[$2]="\033[1;32m"
elif [ "$1" = "3" ]; then
cor[$2]="\033[1;33m"
elif [ "$1" = "4" ]; then
cor[$2]="\033[1;34m"
elif [ "$1" = "5" ]; then
cor[$2]="\033[1;35m"
elif [ "$1" = "6" ]; then
cor[$2]="\033[1;36m"
elif [ "$1" = "7" ]; then
cor[$2]="\033[1;37m"
fi
}

funcao_cores1 () {
if [ "$6" = "" ]; then
echo -e "${cor[5]} ${txt[24]} ${cor[0]}"
sleep 2s
return
fi
echo "0" > $1
funcao_cores2 $2 $1
funcao_cores2 $3 $1
funcao_cores2 $4 $1
funcao_cores2 $5 $1
funcao_cores2 $6 $1
funcao_cores2 $7 $1
}

funcao_cores2 () {
if [ "$1" = "1" ]; then
echo -e "\033[1;31m${txt[25]}"
sleep 1s
echo "1" >> $2
elif [ "$1" = "2" ]; then
echo -e "\033[1;32m${txt[25]}"
sleep 1s
echo "2" >> $2
elif [ "$1" = "3" ]; then
echo -e "\033[1;33m${txt[25]}"
sleep 1s
echo "3" >> $2
elif [ "$1" = "4" ]; then
echo -e "\033[1;34m${txt[25]}"
sleep 1s
echo "4" >> $2
elif [ "$1" = "5" ]; then
echo -e "\033[1;35\]m${txt[25]}"
sleep 1s
echo "5" >> $2
elif [ "$1" = "6" ]; then
echo -e "\033[1;36m${txt[25]}"
sleep 1s
echo "6" >> $2
elif [ "$1" = "7" ]; then
echo -e "\033[1;37m${txt[25]}"
sleep 1s
echo "7" >> $2
elif [ "$1" -gt "7" ]; then
rm $2
funcao_cores1
fi
}

funcao_cores () {
echo -e "${cor[1]} =================================== ${cor[0]}"
echo -e "${cor[5]} ${txt[21]}"
echo -e "${cor[1]} • AABBCCDDEEFF"
echo -e "${cor[2]} • AABBCCDDEEFF"
echo -e "${cor[3]} • AABBCCDDEEFF"
echo -e "${cor[4]} • AABBCCDDEEFF"
echo -e "${cor[5]} • AABBCCDDEEFF"
echo -e "${cor[6]} • AABBCCDDEEFF"
ncor[1]="\033[1;31m"
ncor[2]="\033[1;32m"
ncor[3]="\033[1;33m"
ncor[4]="\033[1;34m"
ncor[5]="\033[1;35m"
ncor[6]="\033[1;36m"
ncor[7]="\033[1;37m"
echo -e "${cor[1]} =================================== ${cor[0]}"
echo -e "${ncor[1]} [1]•AA ${ncor[2]} [2]•AA ${ncor[3]} [3]•AA"
echo -e "${ncor[4]} [4]•AA ${ncor[5]} [5]•AA ${ncor[6]} [6]•AA"
echo -e "${ncor[7]} [7]•AA"
echo -e "${cor[1]} =================================== ${cor[0]}"
echo -e "${cor[5]} ${txt[22]}"
unset ncor
read -p " ${txt[23]} " _cores_
funcao_cores1 $_cores $_cores_
}

[[ -e $_cores ]] && {
_cont="0"
while read _cor; do
funcao_addcores ${_cor} ${_cont}
_cont=$(($_cont + 1))
done < $_cores
} || {
cor[0]="\033[0m"
cor[1]="\033[1;34m"
cor[2]="\033[1;32m"
cor[3]="\033[1;37m"
cor[4]="\033[1;36m"
cor[5]="\033[1;33m"
cor[6]="\033[1;35m"
}

vary_rex () {
echo -e $(echo "$1"| sed 's/../\\x&/g;s/$/ /') && return 0 || return 1
}

funcao_verificacao () {
if [[ $limiter_on = "" ]]; then
unset limiter_on
killall limiter.sh > /dev/null 2>&1
kill -9 $(ps x|grep -v grep|grep limiter.sh|awk '{print $1}')
fi  
[[ ! -e $_modulos ]] && touch $_modulos
  [[ "$VERIFICAR" = "on" ]] && {
  active_verif=$(cat $_modulos | egrep -v "VERIFICAR")
  echo "$active_verif" > $_modulos
  for _pids_ in `atq | awk '{print $1}'`; do
   atrm $_pids_
  done
  [[ -e ./vencidos ]] && rm ./vencidos
  [[ -e ./onlines ]] && rm ./onlines
    } || {
  echo "VERIFICAR" >> $_modulos
  echo "at -f /bin/cron now + 1 min" > /bin/cron
  echo "/etc/adm-lite/verifica &" >> /bin/cron
  chmod 777 /bin/cron
  chmod 777 /etc/adm-lite/*
  bash /bin/cron
  }
unset VERIFICAR
unset __onlines
unset __vencidos
}


#PREENXE_VARIAVEL $select_name
select_users () {
_cont="1"
[[ -e $_tmp3 ]] && rm $_tmp3
touch $_tmp3
for u in `awk -F : '$3 > 900 { print $1 }' /etc/passwd |grep -v "nobody" |grep -vi polkitd |grep -vi systemd-[a-z] |grep -vi systemd-[0-9] |sort`; do
echo "$_cont $u --" >> $_tmp3
[[ -e $dir_user/$u.block ]] && echo -e "\033[0;35m [\033[0;36m$_cont\033[0;35m]\033[0;31m ➮${cor[5]} $u \033[1;34m<--\033[1;31m SUSPENDIDIO" || echo -e "\033[0;35m [\033[0;36m$_cont\033[0;35m]\033[0;31m ➮${cor[5]} $u"
[[ "$u" = "" ]] && break
_cont=$(($_cont + 1))
done
msg -bar
echo -e "${cor[5]} NUMERO DE USUARIO, O ESCRIBRE EL NOMBRE"
echo -ne "${cor[6]}"
read -p " ❐ OPCION : " select_user
tput cuu1 && tput dl1
if [ "$select_user" = "" ]; then
echo -e "${cor[5]} NO SELECCIONO USUARIO . . ."
return
 fi
 if [ "$select_user" -le "$_cont" ] 1> /dev/null 2> /dev/null
then
select_name=$(cat $_tmp3 | head -$select_user | tail -1 | awk '{print $2}')
echo -e "${cor[5]} $name"
 else
 if cat /etc/passwd |grep $select_user: > /dev/null
then
select_name="$select_user"
else
echo -e "${cor[5]}   USUARIO ESCOJIDO, NO EXISTE"
echo -e "${cor[5]} SELECCION DE USUARIO INCORRECTA"
return
  fi
 fi
unset select_user
}

#PREENXE A VARIAVEL $IP
meu_ip () {
[[ -e /etc/catIPlocal && -e /etc/catIP ]] && {
MEU_IP=$(cat < /etc/catIPlocal)
MEU_IP2=$(cat < /etc/catIP)
[[ "$MEU_IP" != "$MEU_IP2" ]] && IP="$MEU_IP2" || IP="$MEU_IP"
} || {
MEU_IP=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1) && echo $MEU_IP > /etc/catIPlocal
MEU_IP2=$(wget -qO- ipv4.icanhazip.com) && echo $MEU_IP2 > /etc/catIP
[[ "$MEU_IP" != "$MEU_IP2" ]] && IP="$MEU_IP2" || IP="$MEU_IP" 
}
}

ofus () {
unset txtofus
number=$(expr length $1)
for((i=1; i<$number+1; i++)); do
txt[$i]=$(echo "$1" | cut -b $i)
case ${txt[$i]} in
".")txt[$i]="x";;
"x")txt[$i]=".";;
"1")txt[$i]="@";;
"@")txt[$i]="1";;
"2")txt[$i]="?";;
"?")txt[$i]="2";;
"4")txt[$i]="%";;
"%")txt[$i]="4";;
"/")txt[$i]="K";;
"K")txt[$i]="/";;
esac
txtofus+="${txt[$i]}"
done
echo "$txtofus" | rev
}

fun_atualizar () {
cd /etc/adm-lite
chmod 777 ./*
echo -e "${cor[3]} ¿DESEAS CONTINUAR CON UPDATE DEL SCRIPT ? "
read -p " [S/N]: " -e -i s sshsn
[[ "$sshsn" = @(s|S|y|Y) ]] && {
[[ -e /etc/adm-lite/idioma ]] && rm /etc/adm-lite/idioma
source <(curl -sSL https://www.dropbox.com/s/57xibc03arhjo7w/updateadm) "alx"
}
}

#GERA NOVO CLIENTE
newclient () {

	# Generates the custom client.ovpn
	rm -rf /etc/openvpn/easy-rsa/pki/reqs/$1.req
	rm -rf /etc/openvpn/easy-rsa/pki/issued/$1.crt
	rm -rf /etc/openvpn/easy-rsa/pki/private/$1.key
	cd /etc/openvpn/easy-rsa/
	./easyrsa build-client-full $1 nopass > /dev/null 2>&1
	cd
	cp /etc/openvpn/client-common.txt ~/$1.ovpn
	echo "<ca>" >> ~/$1.ovpn
	cat /etc/openvpn/easy-rsa/pki/ca.crt >> ~/$1.ovpn
	echo "</ca>" >> ~/$1.ovpn
	echo "<cert>" >> ~/$1.ovpn
	cat /etc/openvpn/easy-rsa/pki/issued/$1.crt >> ~/$1.ovpn
	echo "</cert>" >> ~/$1.ovpn
	echo "<key>" >> ~/$1.ovpn
	cat /etc/openvpn/easy-rsa/pki/private/$1.key >> ~/$1.ovpn
	echo "</key>" >> ~/$1.ovpn
	echo "<tls-auth>" >> ~/$1.ovpn
	cat /etc/openvpn/ta.key >> ~/$1.ovpn
	echo "</tls-auth>" >> ~/$1.ovpn
}

open_1 () {
CLIENT="$1"
senha="$2"
daysrnf="$3"
limit="$4"
#cd /etc/openvpn/easy-rsa/
#./easyrsa build-client-full $CLIENT nopass
newclient "$CLIENT"
#echo ""
#echo "$CLIENT KEY" ~/"$CLIENT.ovpn"
valid=$(date '+%C%y-%m-%d' -d " +$daysrnf days")
datexp=$(date "+%d/%m/%Y" -d "+ $daysrnf days")
useradd -M -s /bin/false -d /home/ovpn/ $CLIENT -e $valid
usermod -p $(openssl passwd -1 $senha) $CLIENT
#Arquivo
  while [[ ${newfile} != @(s|S|y|Y|n|N) ]]; do
	msg -bar
   read -p "Crear Archivo OpenVPN? [S/N]: " -e -i S newfile
   tput cuu1 && tput dl1
  done
  [[ ${newfile} = @(s|S|y|Y) ]] && {
    while [[ ${ovpnauth} != @(s|S|y|Y|n|N) ]]; do
    read -p " Colocar autenticacion de usuario en el archivo? [S/N]: " -e -i S ovpnauth
    tput cuu1 && tput dl1
  done
  [[ ${ovpnauth} = @(s|S|y|Y) ]] && sed -i "s;auth-user-pass;<auth-user-pass>\n$CLIENT\n$senha\n</auth-user-pass>;g" $HOME/$CLIENT.ovpn
  cd $HOME
  zip ./$CLIENT.zip ./$CLIENT.ovpn > /dev/null 2>&1
  echo -e "\033[1;31m Archivo generado en: ($HOME/$CLIENT.zip)"
  echo -e "\033[1;32m ${txt[321]} ( * menu * opcion 2 * opcion 8 )"
  }
rm -f ./$CLIENT.ovpn
cd /etc/adm-lite
echo "senha: $senha" > $dir_user/$CLIENT
echo "limite: $limit" >> $dir_user/$CLIENT
echo "data: $valid" >> $dir_user/$CLIENT
}

open_2 () {
CLIENT="$1"
userdel --force $CLIENT
cd /etc/adm-lite
[[ -e $dir_user/$CLIENT ]] && rm $dir_user/$CLIENT
}

#SISTEMA PORTAS
open_port () {
tmp_arq="/tmp/arq-tmp"
 while read arquivo; do
if [ ! -e "$tmp_arq" ]; then
echo "$arquivo" > $tmp_arq
else
echo "$arquivo" >> $tmp_arq
fi
if [ "$(echo "$arquivo" | awk '{print $1}')" = "$2" ]; then
 [[ "$(cat $tmp_arq | grep "$2 $3" | wc -l)" = "0" ]] && echo "$2 $3" >> $tmp_arq
fi
done < $1
mv -f $tmp_arq $1
}

open_dropbear () {
tmp_arq="/tmp/arq-tmp"
arquivo="/etc/default/dropbear"
echo -e "${cor[2]} |1| >${cor[5]} ${txt[279]}"
echo -e "${cor[2]} |2| >${cor[5]} ${txt[280]}\033[1;37m"
read -p " [ 1 / 2 ]: " escolhaas
if [ "$escolhaas" = "1" ]; then
porta="$1"
sed "s;-p $porta ;;g" $arquivo > $tmp_arq
mv -f $tmp_arq $arquivo
service dropbear restart > /dev/null 2>&1 &
sleep 1s
echo -e "${cor[5]} ${txt[281]}"
return
elif [ "$escolhaas" = "2" ]; then
read -p " Nuevo Puerto: " newport
porta="$newport"
sed -i "s/443/$porta -p 443/g" $arquivo
service dropbear restart > /dev/null 2>&1 &
sleep 1s
echo -e "${cor[5]} ${txt[281]}"
return
fi
}

open_squid () {
tmp_arq="/tmp/arq-tmp"
if [ -d "/etc/squid" ]; then
arquivo="/etc/squid/squid.conf"
elif [ -d "/etc/squid3" ]; then
arquivo="/etc/squid3/squid.conf"
fi
echo -e "${cor[2]} |1| >${cor[5]} ${txt[279]}"
echo -e "${cor[2]} |2| >${cor[5]} ${txt[280]}\033[1;37m"
read -p " [ 1 / 2 ]: " escolhaas
if [ "$escolhaas" = "1" ]; then
porta="$1"
cat $arquivo | grep -v "http_port $porta" > $tmp_arq
mv -f $tmp_arq $arquivo
service squid3 restart > /dev/null 2>&1 &
service squid restart > /dev/null 2>&1 &
sleep 1s
echo -e "${cor[5]} ${txt[281]}"
return
elif [ "$escolhaas" = "2" ]; then
read -p " Nova Porta: " newport
open_port "$arquivo" "http_port" "$newport"
service squid3 restart > /dev/null 2>&1 &
service squid restart > /dev/null 2>&1 &
sleep 1s
echo -e "${cor[5]} ${txt[281]}"
return
fi
}

open_ssh () {
tmp_arq="/tmp/arq-tmp"
arquivo="/etc/ssh/sshd_config"
echo -e "${cor[2]} |1| >${cor[5]} ${txt[279]}"
echo -e "${cor[2]} |2| >${cor[5]} ${txt[280]}\033[1;37m"
read -p " [ 1 / 2 ]: " escolhaas
if [ "$escolhaas" = "1" ]; then
porta="$1"
cat $arquivo | grep -v "Port $porta" > $tmp_arq
mv -f $tmp_arq $arquivo
service ssh restart > /dev/null 2>&1 &
service sshd restart > /dev/null 2>&1 &
sleep 1s
echo -e "${cor[5]} ${txt[281]}"
return
elif [ "$escolhaas" = "2" ]; then
read -p " Nova Porta: " newport
open_port "$arquivo" "Port" "$newport"
service ssh restart > /dev/null 2>&1 &
service sshd restart > /dev/null 2>&1 &
sleep 1s
echo -e "${cor[5]} ${txt[281]}"
return
fi
}

open_python () {
echo -e "${cor[2]} ${cor[5]}${txt[279]}"
read -p " [S/N]: " -e -i n pthsn
[[ "$pthsn" = @(s|S|y|Y) ]] && {
echo -e "${cor[1]} ▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪ ${cor[0]}"
porta="$1"
fuser -k $porta/tcp > /dev/null 2>&1
sleep 1s
echo -e "${cor[5]} ${txt[281]}"
return
}
}

minhas_portas () {
echo -e "${cor[1]} ▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪ ${cor[4]}"
portas_var="/tmp/portas"
porta_var="/tmp/portas2"
lsof -V -i tcp -P -n | grep -v "ESTABLISHED" |grep -v "COMMAND" | grep "LISTEN" > $portas_var
while read port; do
var1=$(echo $port | awk '{print $1}')
var2=$(echo $port | awk '{print $9}' | awk -F ":" '{print $2}')
 if [ ! -e "$porta_var" ]; then
 echo -e "$var1 $var2" > $porta_var
 fi
 if [ "$(cat $porta_var | grep "$var1" | grep "$var2")" = "" ]; then
 echo -e "$var1 $var2" >> $porta_var
 fi
done < $portas_var
i=1
while read pts; do
[[ "$pts" = "" ]] && break
service_porta[$i]=$(echo "$pts" | awk '{print $2}')
service_serv[$i]=$(echo "$pts" | awk '{print $1}')
echo -e " \033[1;37m[$i] -> \033[1;31m${service_serv[$i]} : \033[1;32m${service_porta[$i]}"
i=$(($i+1))
done < $porta_var
echo -e "${cor[5]} ${txt[277]}"
echo -e "${cor[1]} ▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪ \033[1;37m"
read -p " [1-$(($i-1))]: " nun
echo -e "\033[1;31m ${txt[283]} \033[1;32m${service_porta[$nun]}\033[1;31m : \033[1;32m${service_serv[$nun]}\033[0m"
rm $portas_var
rm $porta_var
echo -e "${cor[1]} ▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪ ${cor[0]}"
if [ "${service_serv[$nun]}" = "dropbear" ]; then
open_dropbear ${service_porta[$nun]}
elif [ "${service_serv[$nun]}" = "sshd" ]; then
open_ssh ${service_porta[$nun]}
elif [ "${service_serv[$nun]}" = "squid3" ]; then
open_squid ${service_porta[$nun]}
elif [ "${service_serv[$nun]}" = "squid" ]; then
open_squid ${service_porta[$nun]}
elif [ "${service_serv[$nun]}" = "python" ]; then
open_python ${service_porta[$nun]}
elif [ "${service_serv[$nun]}" = "python3" ]; then
open_python ${service_porta[$nun]}
else
echo -e "\033[1;31m ${txt[278]}\033[0m"
fi
echo -e "${cor[1]} ▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪ ${cor[0]}"
}

#VERIFICA SE E NUMERICO
number_var () {
unset var_number
if (echo "$1" | egrep '[^0-9]' &> /dev/null); then
echo -e "${cor[5]} ${txt[98]}"
else
var_number="$1"
fi
}


ports_ () {
PT=$(lsof -V -i tcp -P -n | grep -v "ESTABLISHED" |grep -v "COMMAND" | grep "LISTEN")
x=1
for porta in `echo -e "$PT" | cut -d: -f2 | cut -d' ' -f1 | uniq`; do
	porta[$x]="$porta"
    svcs[$x]="$(echo -e "$PT" | grep -w "$porta" | awk '{print $1}' | uniq)"
	x=$(($x+1))
done

for((i=1; i<$x; i++)); do
[[ ! -z ${svcs[$i]} ]] && texto="\033[1;34m ▸ \033[1;37m${svcs[$i]}: \033[1;31m${porta[$i]}" || texto=''

[[ ${svcs[$i]} = "apache2" ]] && texto="\033[1;34m ▸ \033[1;37mAPACHE: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "node" ]] && texto="\033[1;34m ▸ \033[1;37mWebSocket: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "clash" ]] && texto="\033[1;34m ▸ \033[1;37mClash: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "psiphond" ]] && texto="\033[1;34m ▸ \033[1;37mPSIPHON: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "xray-v2-u" ]] && texto="\033[1;34m ▸ \033[1;37mXRAY/UI: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "v2-ui" ]] && texto="\033[1;34m ▸ \033[1;37mV2-UI/WEB: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "xray-linu" ]] && texto="\033[1;34m ▸ \033[1;37mXRAY/UI: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "x-ui" ]] && texto="\033[1;34m ▸ \033[1;37mXUI/WEB: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "openvpn" ]] && texto="\033[1;34m ◂ \033[1;37mOPENVPN-TCP: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "squid" ]] && texto="\033[1;34m ◂ \033[1;37mSQUID: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "squid3" ]] && texto="\033[1;34m ◂ \033[1;37mSQUID: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "dropbear" ]] && texto="\033[1;34m ▸ \033[1;37mDROPBEAR: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "python3" ]] && texto="\033[1;34m ▸ \033[1;37mSOCKS/PYTHON: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "python" ]] && texto="\033[1;34m ▸ \033[1;37mSOCKS/PYTHON: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "obfs-serv" ]] && texto="\033[1;34m ▸ \033[1;37mSSR (OBFS): \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "ss-server" ]] && texto="\033[1;34m ▸ \033[1;37mSSR (LIV): \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "sshd" ]] && texto="\033[1;34m ▸ \033[1;37mSSH: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "ssh" ]] && texto="\033[1;34m ▸ \033[1;37mSSH: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "systemd-r" ]] && texto="\033[1;34m ▸ \033[1;37mSystem-DNS: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "stunnel4" ]] && texto="\033[1;34m ▸ \033[1;37mSSL: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "v2ray" ]] && texto="\033[1;34m ◂ \033[1;37mV2RAY: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "xray" ]] && texto="\033[1;34m ◂ \033[1;37mXRAY: \033[1;31m${porta[$i]}"
#[[ ${svcs[$i]} = "badvpn-ud" ]] && texto="\033[1;34m ▸ \033[1;37mBadVPN: \033[1;31mON"
[[ ${porta[$i]} = "7200" ]] && texto="\033[1;34m ▸ \033[1;37mBadVPN: \033[1;31m${porta[$i]}"
[[ ${porta[$i]} = "7300" ]] && texto="\033[1;34m ▸ \033[1;37mBadVPN: \033[1;31m${porta[$i]}"
[[ ${porta[$i]} = "7100" ]] && texto="\033[1;34m ▸ \033[1;37mBadVPN: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "trojan" ]] && texto="\033[1;34m ◂ \033[1;37mTrojan-GO: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "sslh" ]] && texto="\033[1;34m ◂ \033[1;37mSSLH: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "nc.tradit" ]] && texto="\033[1;34m ◂ \033[1;37mKeyGen: \033[1;31mON"

    i=$(($i+1))
	
[[ ! -z ${svcs[$i]} ]] && texto_="\033[1;34m ▸ \033[1;37m${svcs[$i]}: \033[1;31m${porta[$i]}" || texto_=''

[[ ${svcs[$i]} = "apache2" ]] && texto_="\033[1;34m ▸ \033[1;37mAPACHE: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "node" ]] && texto_="\033[1;34m ▸ \033[1;37mWebSocket: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "clash" ]] && texto_="\033[1;34m ▸ \033[1;37mClash: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "psiphond" ]] && texto_="\033[1;34m ▸ \033[1;37mPSIPHON: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "xray-v2-u" ]] && texto_="\033[1;34m ▸ \033[1;37mXRAY/UI: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "v2-ui" ]] && texto_="\033[1;34m ▸ \033[1;37mV2-UI/WEB: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "xray-linu" ]] && texto_="\033[1;34m ▸ \033[1;37mXRAY/UI: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "x-ui" ]] && texto_="\033[1;34m ▸ \033[1;37mXUI/WEB: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "openvpn" ]] && texto_="\033[1;34m ◂ \033[1;37mOPENVPN-TCP: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "squid" ]] && texto_="\033[1;34m ◂ \033[1;37mSQUID: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "squid3" ]] && texto_="\033[1;34m ◂ \033[1;37mSQUID: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "dropbear" ]] && texto_="\033[1;34m ▸ \033[1;37mDROPBEAR: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "python3" ]] && texto_="\033[1;34m ▸ \033[1;37mSOCKS/PYTHON: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "python" ]] && texto_="\033[1;34m ▸ \033[1;37mSOCKS/PYTHON: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "obfs-serv" ]] && texto_="\033[1;34m ▸ \033[1;37mSSR (OBFS): \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "ss-server" ]] && texto_="\033[1;34m ▸ \033[1;37mSSR (LIV): \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "sshd" ]] && texto_="\033[1;34m ▸ \033[1;37mSSH: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "ssh" ]] && texto_="\033[1;34m ▸ \033[1;37mSSH: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "systemd-r" ]] && texto_="\033[1;34m ▸ \033[1;37mSystem-DNS: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "stunnel4" ]] && texto_="\033[1;34m ▸ \033[1;37mSSL: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "v2ray" ]] && texto_="\033[1;34m ◂ \033[1;37mV2RAY: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "xray" ]] && texto_="\033[1;34m ◂ \033[1;37mXRAY: \033[1;31m${porta[$i]}"
#[[ ${svcs[$i]} = "badvpn-ud" ]] && texto_="\033[1;34m ▸ \033[1;37mBadVPN: \033[1;31mON"
[[ ${porta[$i]} = "7200" ]] && texto_="\033[1;34m ▸ \033[1;37mBadVPN: \033[1;31m${porta[$i]}"
[[ ${porta[$i]} = "7300" ]] && texto_="\033[1;34m ▸ \033[1;37mBadVPN: \033[1;31m${porta[$i]}"
[[ ${porta[$i]} = "7100" ]] && texto_="\033[1;34m ▸ \033[1;37mBadVPN: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "trojan" ]] && texto_="\033[1;34m ◂ \033[1;37mTrojan-GO: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "sslh" ]] && texto_="\033[1;34m ◂ \033[1;37mSSLH: \033[1;31m${porta[$i]}"
[[ ${svcs[$i]} = "nc.tradit" ]] && texto_="\033[1;34m ◂ \033[1;37mKeyGen: \033[1;31mON"
	echo -e "$texto  $texto_"
done
PIDGEN=$(ps x | grep "teleBotGen" | grep -v grep |awk '{print $1}')
[[ ! -z $PIDGEN ]] && {
botG="\033[1;34m ▸ \033[1;37m BotGen Telegram 🤖 : \033[1;31m ⚡ ACTIVO ⚡"
msg -bar
echo -e "$botG"
}
}


exitokey="\033[3;49;32m$(cat < /bin/ejecutar/exito)©"
[[ $v1 = $v2 ]] && vesaoSCT="\033[1;37m Key: $exitokey 】\033[0m\033[0;33m($v2)" || vesaoSCT="\033[1;31m${txt[316]}\033[0;33m($v2) ► \033[1;32m($v1)\033[1;31m"
cpuss=$(cat /proc/cpuinfo | grep processor | wc -l)
modelo1=$(lscpu | grep Arch | sed 's/\s\+/,/g' | cut -d , -f2)
[[ $modelo1 = "aarch64" ]] && modelo1=" ARM64" 
meu_ip
[[ -e /root/name ]] && figlet -p -f smslant < /root/name | lolcat || echo -e "\033[7;49;35m    =====>>►► 🐲 New ChumoGH💥VPS 🐲 ◄◄<<=====      \033[0m"
msg -bar #echo -e "${cor[1]} ▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪▪ ${cor[0]}"
[[ "$VERIFICAR" = "on" ]] && echo -e "${cor[2]} ‣ \033[1;37mActivos: $__onlines ${cor[2]} ‣ \033[1;37mCaducados: $__vencidos ${cor[2]} ‣ \033[1;37m Eliminados: $ukk"
echo -e "${cor[2]} ‣ \033[1;37mS.O:$_os ${cor[2]} ‣ \033[1;37mBase:\033[1;31m$modelo1 ${cor[2]}‣ \033[1;37mCores:\033[1;31m $_core "
echo -e "${cor[2]} ‣ \033[1;37mIP: \033[1;31m$IP ${cor[2]}‣ \033[1;37mFECHA: \033[1;31m$(date +"%d/%m/%Y")-$(date +"%H:%M")" 
msg -bar #echo -e "${cor[2]} •••••••••••••••••••••••••••••••••••••••••••••••••  ${cor[0]}"
echo -e "${vesaoSCT} "
msg -bar
[[ $1 = "ports_" ]] && ports_