Skip to content

Commit

Permalink
添加arm64架构支持
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed May 26, 2021
1 parent 93a8fec commit baf57ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 8 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit baf57ef

Please sign in to comment.