#!/bin/bash
#Version 2: Mayo 2025

sudo apt-get install dialog -y
sudo apt-get install curl -y

FECHA=$(date +"%Y-%m-%d")

# Definición de colores (opcional, para resaltar)
GREEN='\033[0;32m'
NC='\033[0m' # No Color

txtred=$(tput bold ; tput setaf 1) 
txtgreen=$(tput bold ; tput setaf 2) 
txtyellow=$(tput bold ; tput setaf 3) 
clear

satlink_info() {
  clear
  cat <<"EOF"
              https://t.me/Satlink502
███████╗ █████╗ ████████╗██╗     ██╗███╗   ██╗██╗  ██╗
██╔════╝██╔══██╗╚══██╔══╝██║     ██║████╗  ██║██║ ██╔╝
███████╗███████║   ██║   ██║     ██║██╔██╗ ██║█████╔╝
╚════██║██╔══██║   ██║   ██║     ██║██║╚██╗██║██╔═██╗
███████║██║  ██║   ██║   ███████╗██║██║ ╚████║██║  ██╗
╚══════╝╚═╝  ╚═╝   ╚═╝   ╚══════╝╚═╝╚═╝  ╚═══╝╚═╝  ╚═╝
IPTV-CATV-RESTREAM                  info@satlink.com.gt
EOF
}


items=(1 "ACCESO REMOTO-NGROK"
       2 "ASTRA Y COMPLEMENTOS"
       3 "XTREAM Y COMPLEMENTOS"
       4 "REINICIAR Y APLICAR CAMBIOS")

while choice=$(dialog --title "SATLINK" \
                      --backtitle "https://t.me/Satlink502" \
                      --menu "          MENU DE INSTALACION V.2" 15 55 5 "${items[@]}" \
                      2>&1 >/dev/tty)
    do
    case $choice in
        1)
satlink_info
bash <(curl -s https://menu.satlink.com.gt/ngrok/ngrok.sh) ; echo "" > ~/.bash_history && history -c ; clear

        ;;
        
        2)
satlink_info
bash <(curl -s https://menu.satlink.com.gt/astra/astra.sh) ; echo "" > ~/.bash_history && history -c ; clear

        ;;
        
        3)
satlink_info
bash <(curl -s https://menu.satlink.com.gt/xtream/xtream.sh) ; echo "" > ~/.bash_history && history -c ; clear  

        ;;
        
        4)
satlink_info
echo -e "┌────── SATLINK MENU INSTALL - https://t.me/Satlink502 ─────┐ "
echo -e "                    ${GREEN}Aplicando Cambios...${NC}         "
echo -e "└───────────────────────────────────────────────────────────┘ "

sleep 5s

echo -e "┌────── SATLINK MENU INSTALL - https://t.me/Satlink502 ─────┐ "
echo -e "                ${GREEN}Reiniciando Servdidor...${NC}         "
echo -e "└───────────────────────────────────────────────────────────┘ "

sleep 5s ; rm -r /tmp/; mkdir -m 777 /tmp/ ; echo "" > ~/.bash_history && history -c ; clear && reboot 

        ;;
        
        
        *) ;; # some action on other
    esac
done
clear # clear after user pressed Cancel