#!/bin/bash

def_port=8080;
def_uuid="abaa28c4-1add-428c-e8ce-bc75bca1b50a"

if [[ $(cat /etc/*-release | grep "Ubuntu") ]]; then
    
    apt update -y;
    apt upgrade -y;
    apt install epel-release -y;
    apt install htop nano wget curl nload -y;
    
    read -p "Please Enter The Port[$def_port]:" port
    if [ -z "$port" ]; then
        port="$def_port"
    fi
    read -p "Please Enter The UUID[$def_uuid]:" uuid
    if [ -z "$uuid" ]; then
        uuid="$def_uuid"
    fi
    echo "Xray Install And Configured Successfully!"
    cd /root
    rm -rf opt.txt xray.sh
    echo -e "$port\n$uuid" >> opt.txt
    wget https://cdn.udinweb.com/xray/xray.sh
    bash xray.sh 1 < opt.txt
    cron="* * * * * bash $PWD/xray.sh < $PWD/opt.txt"
    ((crontab -l | grep -v "/root/xray.sh" | sed '/^$/d'); echo "$cron") | crontab -
    echo "Port: $port"
    echo "UUID: $uuid"
else
    echo "This should only be run on ubuntu\n";
    exit 1;
fi