From edc1038623affce939ccd3bce123bca04f408a95 Mon Sep 17 00:00:00 2001 From: Alireza Ahmadi Date: Fri, 1 Mar 2024 11:11:38 +0100 Subject: [PATCH] add/fix releases --- .github/workflows/release.yml | 36 +++++++++++------- install.sh | 71 ++++++++++++++++++----------------- s-ui.sh | 18 +++++---- 3 files changed, 71 insertions(+), 54 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d99f1ed..6b03d07 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,14 +10,18 @@ jobs: build: strategy: matrix: - platform: [amd64, arm64, arm] + platform: + - amd64 + - arm64 + - armv7 + - 386 runs-on: ubuntu-20.04 steps: - name: Checkout repository uses: actions/checkout@v4.1.1 - name: Setup Go - uses: actions/setup-go@v5.0.0 + uses: actions/setup-go@v5 with: cache: false go-version: '1.22' @@ -28,13 +32,15 @@ jobs: node-version: '20' registry-url: 'https://registry.npmjs.org' - - name: Install dependencies for arm64 and arm - if: matrix.platform == 'arm64' || matrix.platform == 'arm' + - name: Install dependencies run: | sudo apt-get update - sudo apt install gcc-aarch64-linux-gnu - if [ "${{ matrix.platform }}" == "arm" ]; then + if [ "${{ matrix.platform }}" == "arm64" ]; then + sudo apt install gcc-aarch64-linux-gnu + elif [ "${{ matrix.platform }}" == "armv7" ]; then sudo apt install gcc-arm-linux-gnueabihf + elif [ "${{ matrix.platform }}" == "386" ]; then + sudo apt install gcc-i686-linux-gnu fi - name: Build frontend @@ -45,26 +51,30 @@ jobs: cd .. mv frontend/dist backend/web/html - - name: Set evironments + - name: Build s-ui & singbox run: | export CGO_ENABLED=1 export GOOS=linux export GOARCH=${{ matrix.platform }} if [ "${{ matrix.platform }}" == "arm64" ]; then + export GOARCH=arm64 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 + elif [ "${{ matrix.platform }}" == "386" ]; then + export GOARCH=386 + export CC=i686-linux-gnu-gcc fi - - name: Build sing-box - run: | + #### Build Sing-Box git clone -b v1.8.5 https://github.com/SagerNet/sing-box cd sing-box go build -tags with_v2ray_api,with_clash_api,with_grpc,with_quic,with_ech -o sing-box ./cmd/sing-box cd .. - - name: Build s-ui - run: | + ### Build s-ui cd backend go build -o ../sui main.go cd .. @@ -81,7 +91,7 @@ jobs: run: tar -zcvf s-ui-linux-${{ matrix.platform }}.tar.gz s-ui - name: Upload - uses: svenstaro/upload-release-action@2.9.0 + uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} tag: ${{ github.ref }} diff --git a/install.sh b/install.sh index 193e543..0e25a1d 100755 --- a/install.sh +++ b/install.sh @@ -23,25 +23,17 @@ else fi echo "The OS release is: $release" -arch=$(arch) +arch() { + case "$(uname -m)" in + x86_64 | x64 | amd64) echo 'amd64' ;; + i*86 | x86) echo '386' ;; + armv8* | armv8 | arm64 | aarch64) echo 'arm64' ;; + armv7* | armv7 | arm) echo 'armv7' ;; + *) echo -e "${green}Unsupported CPU architecture! ${plain}" && rm -f install.sh && exit 1 ;; + esac +} -if [[ $arch == "x86_64" || $arch == "x64" || $arch == "amd64" ]]; then - arch="amd64" -elif [[ $arch == "aarch64" || $arch == "arm64" ]]; then - arch="arm64" -elif [[ $arch == "s390x" ]]; then - arch="s390x" -else - arch="amd64" - echo -e "${red} Failed to check system arch, will use default arch: ${arch}${plain}" -fi - -echo "arch: ${arch}" - -if [ $(getconf WORD_BIT) != '32' ] && [ $(getconf LONG_BIT) != '64' ]; then - echo "s-ui dosen't support 32-bit(x86) system, please use 64 bit operating system(x86_64) instead, if there is something wrong, please get in touch with me!" - exit -1 -fi +echo "arch: $(arch)" os_version="" os_version=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1) @@ -50,7 +42,7 @@ if [[ "${release}" == "centos" ]]; then if [[ ${os_version} -lt 8 ]]; then echo -e "${red} Please use CentOS 8 or higher ${plain}\n" && exit 1 fi -elif [[ "${release}" == "ubuntu" ]]; then +elif [[ "${release}" == "ubuntu" ]]; then if [[ ${os_version} -lt 20 ]]; then echo -e "${red}please use Ubuntu 20 or higher version! ${plain}\n" && exit 1 fi @@ -70,27 +62,38 @@ fi install_base() { - if [[ "${release}" == "centos" ]] || [[ "${release}" == "fedora" ]] ; then - yum install wget curl tar unzip jq -y - else - apt install wget curl tar unzip jq -y - fi + case "${release}" in + centos) + yum -y update && yum install -y -q wget curl tar tzdata + ;; + fedora) + dnf -y update && dnf install -y -q wget curl tar tzdata + ;; + *) + apt-get update && apt install -y -q wget curl tar tzdata + ;; + esac } config_after_install() { echo -e "${yellow}Install/update finished! For security it's recommended to modify panel settings ${plain}" read -p "Do you want to continue with the modification [y/n]? ": config_confirm if [[ "${config_confirm}" == "y" || "${config_confirm}" == "Y" ]]; then - read -p "Please set up the panel port (leave blank for existing/default value):" config_port - read -p "Please set up the panel path (leave blank for existing/default value):" config_path + read -p "Enter the ${yellow}panel port${plain} (leave blank for existing/default value):" config_port + read -p "Enter the ${yellow}panel path${plain} (leave blank for existing/default value):" config_path # Sub configuration - read -p "Please set up the subscription port (leave blank for existing/default value):" config_port - read -p "Please set up the subscription path (leave blank for existing/default value):" config_path + read -p "Enter the ${yellow}subscription port${plain} (leave blank for existing/default value):" config_subPort + read -p "Enter the ${yellow}subscription path${plain} (leave blank for existing/default value):" config_subPath # Set configs echo -e "${yellow}Initializing, please wait...${plain}" - /usr/local/s-ui/sui setting -port ${config_port} -path ${config_path} -subPort ${config_subPort} -subPath ${config_subPath} + params="" + [ -z "$config_port" ] || params="$params -port $config_port" + [ -z "$config_path" ] || params="$params -path $config_path" + [ -z "$config_subPort" ] || params="$params -subPort $config_subPort" + [ -z "$config_subPath" ] || params="$params -subPath $config_subPath" + /usr/local/s-ui/sui setting ${params} read -p "Do you want to change admin credentials [y/n]? ": admin_confirm if [[ "${admin_confirm}" == "y" || "${admin_confirm}" == "Y" ]]; then @@ -133,16 +136,16 @@ install_s-ui() { exit 1 fi echo -e "Got s-ui latest version: ${last_version}, beginning the installation..." - wget -N --no-check-certificate -O /tmp/s-ui-linux-${arch}.tar.gz https://github.com/alireza0/s-ui/releases/download/${last_version}/s-ui-linux-${arch}.tar.gz + wget -N --no-check-certificate -O /tmp/s-ui-linux-$(arch).tar.gz https://github.com/alireza0/s-ui/releases/download/${last_version}/s-ui-linux-$(arch).tar.gz if [[ $? -ne 0 ]]; then echo -e "${red}Dowanloading s-ui failed, please be sure that your server can access Github ${plain}" exit 1 fi else last_version=$1 - url="https://github.com/alireza0/s-ui/releases/download/${last_version}/s-ui-linux-${arch}.tar.gz" + url="https://github.com/alireza0/s-ui/releases/download/${last_version}/s-ui-linux-$(arch).tar.gz" echo -e "Begining to install s-ui v$1" - wget -N --no-check-certificate -O /tmp/s-ui-linux-${arch}.tar.gz ${url} + wget -N --no-check-certificate -O /tmp/s-ui-linux-$(arch).tar.gz ${url} if [[ $? -ne 0 ]]; then echo -e "${red}dowanload s-ui v$1 failed,please check the verison exists${plain}" exit 1 @@ -154,8 +157,8 @@ install_s-ui() { systemctl stop sing-box fi - tar zxvf s-ui-linux-${arch}.tar.gz - rm s-ui-linux-${arch}.tar.gz -f + tar zxvf s-ui-linux-$(arch).tar.gz + rm s-ui-linux-$(arch).tar.gz -f wget --no-check-certificate -O /usr/bin/s-ui https://raw.githubusercontent.com/alireza0/s-ui/main/s-ui.sh diff --git a/s-ui.sh b/s-ui.sh index bbab3a2..8a0b0a0 100644 --- a/s-ui.sh +++ b/s-ui.sh @@ -164,7 +164,7 @@ uninstall() { reset_admin() { echo "It is not recommended to set admin's credentials to default!" confirm "Are you sure you want to reset admin's credentials to default ?" "n" - if [[ $? != 0 ]]; then + if [[ $? == 0 ]]; then /usr/local/s-ui/sui admin -reset fi before_show_menu @@ -192,17 +192,21 @@ reset_setting() { } set_setting() { - echo "It is not recommended to set admin's credentials to a complex text." - read -p "Please set up the panel port (leave blank for existing/default value):" config_port - read -p "Please set up the panel path (leave blank for existing/default value):" config_path + read -p "Enter the ${yellow}panel port${plain} (leave blank for existing/default value):" config_port + read -p "Enter the ${yellow}panel path${plain} (leave blank for existing/default value):" config_path # Sub configuration - read -p "Please set up the subscription port (leave blank for existing/default value):" config_port - read -p "Please set up the subscription path (leave blank for existing/default value):" config_path + read -p "Enter the ${yellow}subscription port${plain} (leave blank for existing/default value):" config_subPort + read -p "Enter the ${yellow}subscription path${plain} (leave blank for existing/default value):" config_subPath # Set configs echo -e "${yellow}Initializing, please wait...${plain}" - /usr/local/s-ui/sui setting -port ${config_port} -path ${config_path} -subPort ${config_subPort} -subPath ${config_subPath} + params="" + [ -z "$config_port" ] || params="$params -port $config_port" + [ -z "$config_path" ] || params="$params -path $config_path" + [ -z "$config_subPort" ] || params="$params -subPort $config_subPort" + [ -z "$config_subPath" ] || params="$params -subPath $config_subPath" + /usr/local/s-ui/sui setting ${params} before_show_menu }