Skip to content

Commit

Permalink
Added build_xray-plugin.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
teddysun committed Feb 22, 2021
1 parent 874256e commit 39d2208
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docker/shadowsocks-rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ If you want to enable **xray-plugin**, a sample in JSON like below:
}
```

For more `v2ray-plugin` configrations please visit [v2ray-plugin usage][6].
For more `v2ray-plugin` configrations please visit v2ray-plugin [usage][6].

For more `xray-plugin` configrations please visit [xray-plugin usage][7].
For more `xray-plugin` configrations please visit xray-plugin [usage][7].

This container with sample configuration `/etc/shadowsocks-rust/config.json`

Expand Down
43 changes: 43 additions & 0 deletions docker/shadowsocks-rust/build_xray-plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
#
# This is a Shell script for build multi-architectures xray-plugin binary file
#
# Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x
#
# Copyright (C) 2021 Teddysun <[email protected]>
#
# Reference URL:
# https://github.com/teddysun/xray-plugin

cur_dir="$(pwd)"

COMMANDS=( git go )
for CMD in "${COMMANDS[@]}"; do
if [ ! "$(command -v "${CMD}")" ]; then
echo "${CMD} is not installed, please install it and try again" && exit 1
fi
done

cd ${cur_dir}
git clone https://github.com/teddysun/xray-plugin.git
cd xray-plugin || exit 2

VERSION="$(git describe --tags)"
LDFLAGS="-X main.VERSION=$VERSION -s -w"
ARCHS=( 386 amd64 arm arm64 ppc64le s390x )
ARMS=( 6 7 )

for ARCH in ${ARCHS[@]}; do
if [ "${ARCH}" = "arm" ]; then
for V in ${ARMS[@]}; do
echo "Building xray-plugin_linux_${ARCH}${V}"
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${V} go build -v -trimpath -ldflags "${LDFLAGS}" -o ${cur_dir}/xray-plugin_linux_${ARCH}${V}
done
else
echo "Building xray-plugin_linux_${ARCH}"
env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -trimpath -ldflags "${LDFLAGS}" -o ${cur_dir}/xray-plugin_linux_${ARCH}
fi
done

# clean up
cd ${cur_dir} && rm -fr xray-plugin
2 changes: 1 addition & 1 deletion docker/shadowsocks-rust/xray-plugin.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# This is a Shell script for shadowsocks-libev supported SIP003 plugins based alpine with Docker image
# This is a Shell script for shadowsocks-rust supported SIP003 plugins based alpine with Docker image
#
# Copyright (C) 2019 - 2021 Teddysun <[email protected]>
#
Expand Down

0 comments on commit 39d2208

Please sign in to comment.