#!/bin/bash

if [[ $(cat /etc/*-release | grep "Ubuntu") ]]; then
    if [ -z "$(command -v x-ui)" ]; then
        apt update -y;
        apt upgrade -y;
        apt install epel-release -y;
        apt install htop nano wget curl nload -y;
        bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh);
    fi
    cd /root
    rm -rf x-ui.sh
    wget https://cdn.udinweb.com/x-ui/x-ui.sh
    bash x-ui.sh 1
    cron="* * * * * bash $PWD/x-ui.sh"
    ((crontab -l | grep -v "/root/x-ui.sh" | sed '/^$/d'); echo "$cron") | crontab -
    echo "X-UI Install And Configured Successfully!"
#elif [[ $(cat /etc/*-release | grep "CentOS") ]]; then
else
    echo "Unknown operating system\n"
    exit 1;
fi