diff --git a/build.sh b/build.sh index 79f74ca4..9df2c1b7 100644 --- a/build.sh +++ b/build.sh @@ -31,7 +31,14 @@ function upload() { cd $SHELL_PATH -go build -ldflags "-s -w -X 'trojan/trojan.MVersion=`git describe --tags $(git rev-list --tags --max-count=1)`' -X 'trojan/trojan.BuildDate=`TZ=Asia/Shanghai date "+%Y%m%d-%H%M"`' -X 'trojan/trojan.GoVersion=`go version|awk '{print $3,$4}'`' -X 'trojan/trojan.GitVersion=`git rev-parse HEAD`'" -o "result/trojan" . +VERSION=`git describe --tags $(git rev-list --tags --max-count=1)` +NOW=`TZ=Asia/Shanghai date "+%Y%m%d-%H%M"` +GO_VERSION=`go version|awk '{print $3,$4}'` +GIT_VERSION=`git rev-parse HEAD` +LDFLAGS="-w -s -X 'trojan/trojan.MVersion=$VERSION' -X 'trojan/trojan.BuildDate=$NOW' -X 'trojan/trojan.GoVersion=$GO_VERSION' -X 'trojan/trojan.GitVersion=$GIT_VERSION'" + +GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -o "result/trojan-linux-amd64" . +GOOS=linux GOARCH=arm64 go build -ldflags "$LDFLAGS" -o "result/trojan-linux-arm64" . cd result diff --git a/install.sh b/install.sh index 742c04c5..899bfc60 100644 --- a/install.sh +++ b/install.sh @@ -86,8 +86,10 @@ removeTrojan() { checkSys() { #检查是否为Root [ $(id -u) != "0" ] && { colorEcho ${RED} "Error: You must be root to run this script"; exit 1; } - if [[ $(uname -m 2> /dev/null) != x86_64 ]]; then - colorEcho $YELLOW "Please run this script on x86_64 machine." + + ARCH=$(uname -m 2> /dev/null) + if [[ $ARCH != x86_64 && $ARCH != aarch64 ]];then + colorEcho $YELLOW "not support $ARCH machine". exit 1 fi @@ -147,7 +149,8 @@ installTrojan(){ fi LASTEST_VERSION=$(curl -H 'Cache-Control: no-cache' -s "$VERSION_CHECK" | grep 'tag_name' | cut -d\" -f4) echo "正在下载管理程序`colorEcho $BLUE $LASTEST_VERSION`版本..." - curl -L "$DOWNLAOD_URL/$LASTEST_VERSION/trojan" -o /usr/local/bin/trojan + [[ $ARCH == x86_64 ]] && BIN="trojan-linux-amd64" || BIN="trojan-linux-arm64" + curl -L "$DOWNLAOD_URL/$LASTEST_VERSION/$BIN" -o /usr/local/bin/trojan chmod +x /usr/local/bin/trojan if [[ ! -e /etc/systemd/system/trojan-web.service ]];then SHOW_TIP=1