mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-03-01 01:20:49 +03:00
fedora and centos install fixed
This commit is contained in:
parent
b77001973a
commit
68da556bd2
@ -46,7 +46,7 @@ After you set ssl on settings
|
||||
- Ubuntu 20.04+
|
||||
- Debian 10+
|
||||
- CentOS 8+
|
||||
- Fedora 29+
|
||||
- Fedora 36+
|
||||
|
||||
# Pictures
|
||||
|
||||
|
90
install.sh
90
install.sh
@ -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,38 +42,29 @@ 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)
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
install_base() {
|
||||
if [[ x"${release}" == x"centos" ]]; then
|
||||
@ -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
|
||||
|
94
x-ui.sh
94
x-ui.sh
@ -21,26 +21,12 @@ function LOGI() {
|
||||
[[ $EUID -ne 0 ]] && LOGE "ERROR: You must be root to run this script! \n" && exit 1
|
||||
|
||||
# Check OS and set release variable
|
||||
if [[ -f /etc/redhat-release ]]; then
|
||||
if grep -Eqi "CentOS" /etc/redhat-release; then
|
||||
release="centos"
|
||||
elif grep -Eqi "Fedora" /etc/redhat-release; then
|
||||
release="fedora"
|
||||
fi
|
||||
elif grep -Eqi "debian" /etc/issue; then
|
||||
release="debian"
|
||||
elif grep -Eqi "ubuntu" /etc/issue; then
|
||||
release="ubuntu"
|
||||
elif grep -Eqi "centos" /etc/issue; then
|
||||
release="centos"
|
||||
elif grep -Eqi "debian" /proc/version; then
|
||||
release="debian"
|
||||
elif grep -Eqi "ubuntu" /proc/version; then
|
||||
release="ubuntu"
|
||||
elif grep -Eqi "centos" /proc/version; then
|
||||
release="centos"
|
||||
elif grep -Eqi "fedora" /proc/version; then
|
||||
release="fedora"
|
||||
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 "Failed to check the system OS, please contact the author!" >&2
|
||||
exit 1
|
||||
@ -48,48 +34,30 @@ fi
|
||||
|
||||
echo "The OS release is: $release"
|
||||
|
||||
|
||||
os_version=""
|
||||
os_version=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1)
|
||||
|
||||
# os version
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
os_version=$(awk -F'[= ."]' '/VERSION_ID/{print $3}' /etc/os-release)
|
||||
elif [[ -f /etc/lsb-release ]]; then
|
||||
os_version=$(awk -F'[= ."]+' '/DISTRIB_RELEASE/{print $2}' /etc/lsb-release)
|
||||
elif [[ -f /etc/fedora-release ]]; then
|
||||
os_version=$(awk -F'[= ]+' '/release/{print $3}' /etc/fedora-release)
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
case "${release}" in
|
||||
centos)
|
||||
if [[ ${os_version} -le 8 ]]; then
|
||||
echo "Please use CentOS 8 or higher version!"
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
ubuntu)
|
||||
if [[ ${os_version} -lt 20 ]]; then
|
||||
echo "Please use Ubuntu 20 or higher version!"
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
debian)
|
||||
if [[ ${os_version} -lt 10 ]]; then
|
||||
echo "Please use Debian 10 or higher version!"
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
fedora)
|
||||
if [[ ${os_version} -lt 29 ]]; then
|
||||
echo "Please use Fedora 29 or higher version!"
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown release type '${release}'"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
confirm() {
|
||||
if [[ $# > 1 ]]; then
|
||||
@ -122,7 +90,7 @@ before_show_menu() {
|
||||
}
|
||||
|
||||
install() {
|
||||
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/main/install.sh)
|
||||
bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/main/install.sh)
|
||||
if [[ $? == 0 ]]; then
|
||||
if [[ $# == 0 ]]; then
|
||||
start
|
||||
@ -141,7 +109,7 @@ update() {
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/main/install.sh)
|
||||
bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/main/install.sh)
|
||||
if [[ $? == 0 ]]; then
|
||||
LOGI "Update is complete, Panel has automatically restarted "
|
||||
exit 0
|
||||
@ -354,7 +322,7 @@ fi
|
||||
}
|
||||
|
||||
update_shell() {
|
||||
wget -O /usr/bin/x-ui -N --no-check-certificate https://github.com/mhsanaei/3x-ui/raw/main/x-ui.sh
|
||||
wget -O /usr/bin/x-ui -N --no-check-certificate https://github.com/MHSanaei/3x-ui/raw/main/x-ui.sh
|
||||
if [[ $? != 0 ]]; then
|
||||
echo ""
|
||||
LOGE "Failed to download script,Please check whether the machine can connect Github"
|
||||
@ -709,8 +677,8 @@ show_menu() {
|
||||
${green}11.${plain} Check x-ui Status
|
||||
${green}12.${plain} Check x-ui Logs
|
||||
————————————————
|
||||
${green}13.${plain} Enable x-ui On Sysyem Startup
|
||||
${green}14.${plain} Disabel x-ui On Sysyem Startup
|
||||
${green}13.${plain} Enable x-ui On System Startup
|
||||
${green}14.${plain} Disabel x-ui On System Startup
|
||||
————————————————
|
||||
${green}15.${plain} Enable BBR
|
||||
${green}16.${plain} Issuse Certs
|
||||
|
Loading…
Reference in New Issue
Block a user