|
@@ -10,29 +10,18 @@ cur_dir=$(pwd)
|
|
|
# check root
|
|
|
[[ $EUID -ne 0 ]] && echo -e "${red}Fatal error:${plain} Please run this script with root privilege \n " && exit 1
|
|
|
|
|
|
-# Check OS
|
|
|
-if [[ -f /etc/redhat-release ]]; then
|
|
|
- release="centos"
|
|
|
- if grep -q "Fedora" /etc/redhat-release; then
|
|
|
- release="fedora"
|
|
|
- fi
|
|
|
-elif cat /etc/issue | grep -Eqi "debian"; then
|
|
|
- release="debian"
|
|
|
-elif cat /etc/issue | grep -Eqi "ubuntu"; then
|
|
|
- release="ubuntu"
|
|
|
-elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
|
|
|
- release="centos"
|
|
|
-elif cat /proc/version | grep -Eqi "debian"; then
|
|
|
- release="debian"
|
|
|
-elif cat /proc/version | grep -Eqi "ubuntu"; then
|
|
|
- release="ubuntu"
|
|
|
-elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
|
|
|
- release="centos"
|
|
|
-elif grep -q "Fedora" /etc/*-release; then
|
|
|
- release="fedora"
|
|
|
+# Check OS and set release variable
|
|
|
+if [[ -f /etc/os-release ]]; then
|
|
|
+ source /etc/os-release
|
|
|
+ release=$ID
|
|
|
+elif [[ -f /usr/lib/os-release ]]; then
|
|
|
+ source /usr/lib/os-release
|
|
|
+ release=$ID
|
|
|
else
|
|
|
- echo -e "${red} Check system OS failed, please contact the author! ${plain}\n" && exit 1
|
|
|
+ echo "Failed to check the system OS, please contact the author!" >&2
|
|
|
+ exit 1
|
|
|
fi
|
|
|
+echo "The OS release is: $release"
|
|
|
|
|
|
arch=$(arch)
|
|
|
|
|
@@ -53,39 +42,30 @@ if [ $(getconf WORD_BIT) != '32' ] && [ $(getconf LONG_BIT) != '64' ]; then
|
|
|
fi
|
|
|
|
|
|
os_version=""
|
|
|
+os_version=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1)
|
|
|
|
|
|
-# get OS version
|
|
|
-if [[ -f /etc/os-release ]]; then
|
|
|
- os_version=$(awk -F'[= ."]' '/VERSION_ID/{print $3}' /etc/os-release)
|
|
|
-fi
|
|
|
-if [[ -z "$os_version" && -f /etc/lsb-release ]]; then
|
|
|
- os_version=$(awk -F'[= ."]+' '/DISTRIB_RELEASE/{print $2}' /etc/lsb-release)
|
|
|
-fi
|
|
|
+if [[ x"${release}" == x"centos" ]]; then
|
|
|
+ if [[ ${os_version} -lt 8 ]]; then
|
|
|
+ echo -e "${red} Please use CentOS 8 or higher ${plain}\n" && exit 1
|
|
|
+ fi
|
|
|
+elif [[ x"${release}" == "ubuntu" ]]; then
|
|
|
+ if [[ ${os_version} -lt 20 ]]; then
|
|
|
+ echo -e "${red}please use Ubuntu 20 or higher version!${plain}\n" && exit 1
|
|
|
+ fi
|
|
|
+
|
|
|
+elif [[ x"${release}" == "fedora" ]]; then
|
|
|
+ if [[ ${os_version} -lt 36 ]]; then
|
|
|
+ echo -e "${red}please use Fedora 36 or higher version!${plain}\n" && exit 1
|
|
|
+ fi
|
|
|
|
|
|
-# set minimum version number for each OS
|
|
|
-case ${release} in
|
|
|
- centos)
|
|
|
- min_version=8
|
|
|
- ;;
|
|
|
- ubuntu)
|
|
|
- min_version=20
|
|
|
- ;;
|
|
|
- debian)
|
|
|
- min_version=10
|
|
|
- ;;
|
|
|
- fedora)
|
|
|
- min_version=29
|
|
|
- ;;
|
|
|
- *)
|
|
|
- echo -e "${red} Unsupported OS ${plain}\n" && exit 1
|
|
|
- ;;
|
|
|
-esac
|
|
|
-
|
|
|
-# check if OS version meets minimum version requirement
|
|
|
-if [[ ${os_version} -lt ${min_version} ]]; then
|
|
|
- echo -e "${red} Please use ${release^} ${min_version} or higher ${plain}\n" && exit 1
|
|
|
+elif [[ x"${release}" == "debian" ]]; then
|
|
|
+ if [[ ${os_version} -lt 10 ]]; then
|
|
|
+ echo -e "${red} Please use Debian 10 or higher ${plain}\n" && exit 1
|
|
|
+ fi
|
|
|
+
|
|
|
fi
|
|
|
|
|
|
+
|
|
|
install_base() {
|
|
|
if [[ x"${release}" == x"centos" ]]; then
|
|
|
yum install wget curl tar -y
|
|
@@ -93,7 +73,6 @@ install_base() {
|
|
|
apt install wget curl tar -y
|
|
|
fi
|
|
|
}
|
|
|
-
|
|
|
#This function will be called when user installed x-ui out of sercurity
|
|
|
config_after_install() {
|
|
|
echo -e "${yellow}Install/update finished! For security it's recommended to modify panel settings ${plain}"
|
|
@@ -120,7 +99,6 @@ config_after_install() {
|
|
|
echo -e "###############################################"
|
|
|
echo -e "${green}user name:${usernameTemp}${plain}"
|
|
|
echo -e "${green}user password:${passwordTemp}${plain}"
|
|
|
- echo -e "${red}web port:${portTemp}${plain}"
|
|
|
echo -e "###############################################"
|
|
|
echo -e "${red}if you forgot your login info,you can type x-ui and then type 7 to check after installation${plain}"
|
|
|
else
|
|
@@ -134,20 +112,20 @@ install_x-ui() {
|
|
|
cd /usr/local/
|
|
|
|
|
|
if [ $# == 0 ]; then
|
|
|
- last_version=$(curl -Ls "https://api.github.com/repos/mhsanaei/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
|
|
+ last_version=$(curl -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
|
|
if [[ ! -n "$last_version" ]]; then
|
|
|
echo -e "${red}Failed to fetch x-ui version, it maybe due to Github API restrictions, please try it later${plain}"
|
|
|
exit 1
|
|
|
fi
|
|
|
echo -e "Got x-ui latest version: ${last_version}, beginning the installation..."
|
|
|
- wget -N --no-check-certificate -O /usr/local/x-ui-linux-${arch}.tar.gz https://github.com/mhsanaei/3x-ui/releases/download/${last_version}/x-ui-linux-${arch}.tar.gz
|
|
|
+ wget -N --no-check-certificate -O /usr/local/x-ui-linux-${arch}.tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${last_version}/x-ui-linux-${arch}.tar.gz
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
echo -e "${red}Downloading x-ui failed, please be sure that your server can access Github ${plain}"
|
|
|
exit 1
|
|
|
fi
|
|
|
else
|
|
|
last_version=$1
|
|
|
- url="https://github.com/mhsanaei/3x-ui/releases/download/${last_version}/x-ui-linux-${arch}.tar.gz"
|
|
|
+ url="https://github.com/MHSanaei/3x-ui/releases/download/${last_version}/x-ui-linux-${arch}.tar.gz"
|
|
|
echo -e "Begining to install x-ui $1"
|
|
|
wget -N --no-check-certificate -O /usr/local/x-ui-linux-${arch}.tar.gz ${url}
|
|
|
if [[ $? -ne 0 ]]; then
|
|
@@ -165,7 +143,7 @@ install_x-ui() {
|
|
|
cd x-ui
|
|
|
chmod +x x-ui bin/xray-linux-${arch}
|
|
|
cp -f x-ui.service /etc/systemd/system/
|
|
|
- wget --no-check-certificate -O /usr/bin/x-ui https://raw.githubusercontent.com/mhsanaei/3x-ui/main/x-ui.sh
|
|
|
+ wget --no-check-certificate -O /usr/bin/x-ui https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.sh
|
|
|
chmod +x /usr/local/x-ui/x-ui.sh
|
|
|
chmod +x /usr/bin/x-ui
|
|
|
config_after_install
|