x86 Arch Support

This commit is contained in:
MHSanaei
2024-02-20 20:41:40 +03:30
parent 343e7a9f15
commit d608961af8
5 changed files with 56 additions and 22 deletions

View File

@@ -50,6 +50,6 @@ jobs:
with: with:
context: . context: .
push: true push: true
platforms: linux/amd64,linux/arm64/v8, linux/arm/v7 platforms: linux/amd64,linux/arm64/v8, linux/arm/v7, linux/386
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}

View File

@@ -10,7 +10,11 @@ jobs:
build: build:
strategy: strategy:
matrix: matrix:
platform: [amd64, arm64, arm] platform:
- amd64
- arm64
- armv7
- 386
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Checkout repository - name: Checkout repository
@@ -20,14 +24,16 @@ jobs:
uses: actions/setup-go@v5.0.0 uses: actions/setup-go@v5.0.0
with: with:
go-version: '1.22' go-version: '1.22'
- name: Install dependencies for arm64 and arm - name: Install dependencies
if: matrix.platform == 'arm64' || matrix.platform == 'arm'
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt install gcc-aarch64-linux-gnu if [ "${{ matrix.platform }}" == "arm64" ]; then
if [ "${{ matrix.platform }}" == "arm" ]; then sudo apt install gcc-aarch64-linux-gnu
elif [ "${{ matrix.platform }}" == "armv7" ]; then
sudo apt install gcc-arm-linux-gnueabihf sudo apt install gcc-arm-linux-gnueabihf
elif [ "${{ matrix.platform }}" == "386" ]; then
sudo apt install gcc-i686-linux-gnu
fi fi
- name: Build x-ui - name: Build x-ui
@@ -36,9 +42,15 @@ jobs:
export GOOS=linux export GOOS=linux
export GOARCH=${{ matrix.platform }} export GOARCH=${{ matrix.platform }}
if [ "${{ matrix.platform }}" == "arm64" ]; then if [ "${{ matrix.platform }}" == "arm64" ]; then
export GOARCH=arm64
export CC=aarch64-linux-gnu-gcc export CC=aarch64-linux-gnu-gcc
elif [ "${{ matrix.platform }}" == "arm" ]; then elif [ "${{ matrix.platform }}" == "armv7" ]; then
export GOARCH=arm
export GOARM=7
export CC=arm-linux-gnueabihf-gcc export CC=arm-linux-gnueabihf-gcc
elif [ "${{ matrix.platform }}" == "386" ]; then
export GOARCH=386
export CC=i686-linux-gnu-gcc
fi fi
go build -o xui-release -v main.go go build -o xui-release -v main.go
@@ -60,12 +72,16 @@ jobs:
wget ${Xray_URL}Xray-linux-arm64-v8a.zip wget ${Xray_URL}Xray-linux-arm64-v8a.zip
unzip Xray-linux-arm64-v8a.zip unzip Xray-linux-arm64-v8a.zip
rm -f Xray-linux-arm64-v8a.zip rm -f Xray-linux-arm64-v8a.zip
else elif [ "${{ matrix.platform }}" == "armv7" ]; then
wget ${Xray_URL}Xray-linux-arm32-v7a.zip wget ${Xray_URL}Xray-linux-arm32-v7a.zip
unzip Xray-linux-arm32-v7a.zip unzip Xray-linux-arm32-v7a.zip
rm -f Xray-linux-arm32-v7a.zip rm -f Xray-linux-arm32-v7a.zip
elif [ "${{ matrix.platform }}" == "386" ]; then
wget ${Xray_URL}Xray-linux-32.zip
unzip Xray-linux-32.zip
rm -f Xray-linux-32.zip
fi fi
rm -f geoip.dat geosite.dat geoip_IR.dat geosite_IR.dat rm -f geoip.dat geosite.dat
wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
wget -O geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat wget -O geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat
@@ -76,12 +92,11 @@ jobs:
- name: Package - name: Package
run: tar -zcvf x-ui-linux-${{ matrix.platform }}.tar.gz x-ui run: tar -zcvf x-ui-linux-${{ matrix.platform }}.tar.gz x-ui
- name: Upload - name: Upload files to GH release
uses: svenstaro/upload-release-action@2.7.0 uses: MHSanaei/upload-release-action@2.8.0
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }} tag: ${{ github.ref }}
file: x-ui-linux-${{ matrix.platform }}.tar.gz file: x-ui-linux-${{ matrix.platform }}.tar.gz
asset_name: x-ui-linux-${{ matrix.platform }}.tar.gz asset_name: x-ui-linux-${{ matrix.platform }}.tar.gz
prerelease: true prerelease: true
overwrite: true

View File

@@ -4,6 +4,10 @@ case $1 in
ARCH="64" ARCH="64"
FNAME="amd64" FNAME="amd64"
;; ;;
i386)
ARCH="32"
FNAME="i386"
;;
armv8 | arm64 | aarch64) armv8 | arm64 | aarch64)
ARCH="arm64-v8a" ARCH="arm64-v8a"
FNAME="arm64" FNAME="arm64"

View File

@@ -62,6 +62,7 @@ bash <(curl -Ls https://raw.githubusercontent.com/alireza0/x-ui/master/install.s
ARCH=$(uname -m) ARCH=$(uname -m)
case "${ARCH}" in case "${ARCH}" in
x86_64 | x64 | amd64) XUI_ARCH="amd64" ;; x86_64 | x64 | amd64) XUI_ARCH="amd64" ;;
i*86 | x86) XUI_ARCH="386" ;;
armv8* | armv8 | arm64 | aarch64) XUI_ARCH="arm64" ;; armv8* | armv8 | arm64 | aarch64) XUI_ARCH="arm64" ;;
armv7* | armv7) XUI_ARCH="armv7" ;; armv7* | armv7) XUI_ARCH="armv7" ;;
*) XUI_ARCH="amd64" ;; *) XUI_ARCH="amd64" ;;
@@ -76,6 +77,7 @@ wget https://github.com/alireza0/x-ui/releases/latest/download/x-ui-linux-${XUI_
ARCH=$(uname -m) ARCH=$(uname -m)
case "${ARCH}" in case "${ARCH}" in
x86_64 | x64 | amd64) XUI_ARCH="amd64" ;; x86_64 | x64 | amd64) XUI_ARCH="amd64" ;;
i*86 | x86) XUI_ARCH="386" ;;
armv8* | armv8 | arm64 | aarch64) XUI_ARCH="arm64" ;; armv8* | armv8 | arm64 | aarch64) XUI_ARCH="arm64" ;;
armv7* | armv7) XUI_ARCH="armv7" ;; armv7* | armv7) XUI_ARCH="armv7" ;;
*) XUI_ARCH="amd64" ;; *) XUI_ARCH="amd64" ;;

View File

@@ -26,8 +26,9 @@ echo "The OS release is: $release"
arch() { arch() {
case "$(uname -m)" in case "$(uname -m)" in
x86_64 | x64 | amd64) echo 'amd64' ;; x86_64 | x64 | amd64) echo 'amd64' ;;
i*86 | x86) echo '386' ;;
armv8* | armv8 | arm64 | aarch64) echo 'arm64' ;; armv8* | armv8 | arm64 | aarch64) echo 'arm64' ;;
armv7* | armv7 | arm | arm32 ) echo 'arm' ;; armv7* | armv7 | arm) echo 'armv7' ;;
*) echo -e "${green}Unsupported CPU architecture! ${plain}" && rm -f install.sh && exit 1 ;; *) echo -e "${green}Unsupported CPU architecture! ${plain}" && rm -f install.sh && exit 1 ;;
esac esac
} }
@@ -40,7 +41,7 @@ if [[ "${release}" == "centos" ]]; then
if [[ ${os_version} -lt 8 ]]; then if [[ ${os_version} -lt 8 ]]; then
echo -e "${red} Please use CentOS 8 or higher ${plain}\n" && exit 1 echo -e "${red} Please use CentOS 8 or higher ${plain}\n" && exit 1
fi fi
elif [[ "${release}" == "ubuntu" ]]; then elif [[ "${release}" == "ubuntu" ]]; then
if [[ ${os_version} -lt 20 ]]; then if [[ ${os_version} -lt 20 ]]; then
echo -e "${red}please use Ubuntu 20 or higher version! ${plain}\n" && exit 1 echo -e "${red}please use Ubuntu 20 or higher version! ${plain}\n" && exit 1
fi fi
@@ -58,13 +59,18 @@ else
echo -e "${red}Failed to check the OS version, please contact the author!${plain}" && exit 1 echo -e "${red}Failed to check the OS version, please contact the author!${plain}" && exit 1
fi fi
install_dependencies() { install_dependencies() {
if [[ "${release}" == "centos" ]] || [[ "${release}" == "fedora" ]] ; then case "${release}" in
yum install wget curl tar -y centos)
else yum -y update && yum install -y -q wget curl tar tzdata
apt install wget curl tar -y ;;
fi fedora)
dnf -y update && dnf install -y -q wget curl tar tzdata
;;
*)
apt-get update && apt install -y -q wget curl tar tzdata
;;
esac
} }
#This function will be called when user installed x-ui out of sercurity #This function will be called when user installed x-ui out of sercurity
@@ -152,6 +158,13 @@ install_x-ui() {
tar zxvf x-ui-linux-$(arch).tar.gz tar zxvf x-ui-linux-$(arch).tar.gz
rm x-ui-linux-$(arch).tar.gz -f rm x-ui-linux-$(arch).tar.gz -f
cd x-ui cd x-ui
chmod +x x-ui
# Check the system's architecture and rename the file accordingly
if [[ $(arch) == "armv7" ]]; then
mv bin/xray-linux-$(arch) bin/xray-linux-arm
chmod +x bin/xray-linux-arm
fi
chmod +x x-ui bin/xray-linux-$(arch) chmod +x x-ui bin/xray-linux-$(arch)
cp -f x-ui.service /etc/systemd/system/ cp -f x-ui.service /etc/systemd/system/
wget --no-check-certificate -O /usr/bin/x-ui https://raw.githubusercontent.com/alireza0/x-ui/main/x-ui.sh wget --no-check-certificate -O /usr/bin/x-ui https://raw.githubusercontent.com/alireza0/x-ui/main/x-ui.sh
@@ -172,7 +185,7 @@ install_x-ui() {
echo -e "" echo -e ""
echo "X-UI Control Menu Usage" echo "X-UI Control Menu Usage"
echo "------------------------------------------" echo "------------------------------------------"
echo "SUBCOMMANDS:" echo "SUBCOMMANDS:"
echo "x-ui - Admin Management Script" echo "x-ui - Admin Management Script"
echo "x-ui start - Start" echo "x-ui start - Start"
echo "x-ui stop - Stop" echo "x-ui stop - Stop"