Files
docker-easyconnect/Dockerfile.cli
Hagb f533949090 Support non-amd64 deb package of EasyConnect
Since non-amd64 deb packages of EasyConnect are proved to exist
(https://github.com/Hagb/docker-easyconnect/issues/25#issuecomment-1233369467),
the deb package should not be assume to be amd64 and architecture
specific code should be rewritten:

- Add EC_HOST build argument to tell Dockerfile the architecture of
  EasyConnect package
- Whether to install cross toolchain and qemu-user and which package
  should be install, is determined by EC_HOST and the local architecture
  now, more specifically by build-scripts/get-echost-names.sh (no longer
  hard-code amd64 cross toolchain)
- fake-hwaddr.so should follow the architecture of the EC deb, so
  fake-hwaddr/Makefile uses CC envirnoment variable instead of
  hard-coded x86_64-linux-gnu-gcc as c compiler now
- qemu_args is removed now. It was used to pass LD_PRELOAD to foreign
  binaries under qemu-user, but now we pass LD_PRELOAD to the qemu
  wrapper and wrapper will pass the LD_PRELOAD to the simulated
  binaries
2022-09-24 08:52:32 +08:00

63 lines
2.8 KiB
Docker

FROM debian:bookworm-slim
ARG ANDROID_PATCH BUILD_ENV=local MIRROR_URL=http://ftp.cn.debian.org/debian/ EC_HOST
COPY ["./build-scripts/config-apt.sh", "./build-scripts/get-echost-names.sh", "./build-scripts/add-qemu.sh", \
"/tmp/build-scripts/"]
RUN . /tmp/build-scripts/config-apt.sh && \
. /tmp/build-scripts/get-echost-names.sh && \
. /tmp/build-scripts/add-qemu.sh && \
apt-get update && \
apt-get install -y --no-install-recommends --no-install-suggests iptables \
dante-server busybox iproute2 tinyproxy-bin ca-certificates ${qemu_pkgs} && \
for command in ps kill killall; do ln -s "$(which busybox)" /usr/local/bin/"${command}" || exit 1 ; done && \
rm -rf /var/lib/apt/lists/*
RUN groupadd -r socks && useradd -r -g socks socks
ARG EC_CLI_URL="https://github.com/shmilee/scripts/releases/download/v0.0.1/easyconn_7.6.8.2-ubuntu_amd64.deb"
COPY ./build-scripts/mk-qemu-wrapper.sh /tmp/build-scripts/
RUN EC_DIR=/usr/share/sangfor/EasyConnect/resources && cd /tmp && \
busybox wget "${EC_CLI_URL}" -O easyconn.deb && \
dpkg -x easyconn.deb easyconn && \
bash -c "mkdir -p ${EC_DIR}/{bin,lib64,shell,logs}/" && \
bash -c "cp easyconn/${EC_DIR}/bin/{CSClient,easyconn,ECAgent,svpnservice,ca.crt,cert.crt} \
/${EC_DIR}/bin/" && \
bash -c "chmod +xs ${EC_DIR}/bin/{CSClient,ECAgent,svpnservice}" && \
extra_bins=easyconn . /tmp/build-scripts/mk-qemu-wrapper.sh && \
bash -c "cp easyconn/${EC_DIR}/lib64/lib{nspr4,nss3,nssutil3,plc4,plds4,smime3}.so \
/${EC_DIR}/lib64/" && \
cp easyconn/${EC_DIR}/shell/* \
/${EC_DIR}/shell/ && \
chmod +x ${EC_DIR}/shell/* && \
ln -s ${EC_DIR}/bin/easyconn /usr/local/bin/ && \
cp -r easyconn/${EC_DIR}/conf ${EC_DIR}/conf_7.6.8 && rm -r *
ARG EC_763_URL="http://download.sangfor.com.cn/download/product/sslvpn/pkg/linux_01/EasyConnect_x64.deb"
ARG EC_767_URL="http://download.sangfor.com.cn/download/product/sslvpn/pkg/linux_767/EasyConnect_x64_7_6_7_3.deb"
RUN cd /tmp && \
for ver in 7.6.3 7.6.7 ; do { \
vername=EC_$( echo "$ver" | sed 's/\.//g' )_URL && \
url="$(eval printf %s \"\$$vername\")" && \
if [ -n "${url}" ]; then busybox wget "${url}" -O EasyConnect.deb && dpkg -x EasyConnect.deb ec && \
cp -r ec/usr/share/sangfor/EasyConnect/resources/conf \
/usr/share/sangfor/EasyConnect/resources/conf_$ver && \
rm -r *; fi ;} || exit 1 ; done
RUN for i in /usr/share/sangfor/EasyConnect/resources/conf_*/; do \
ln -s /root/.easyconn $i/.easyconn ; \
done && touch /root/.easyconn
COPY ./docker-root /
COPY --from=hagb/docker-easyconnect:build /results/fake-hwaddr/ /results/tinyproxy-ws/ /
ENV QEMU_ECAGENT_MEM_LIMIT=256
VOLUME /root/ /usr/share/sangfor/EasyConnect/resources/logs/
CMD _EC_CLI=1 start.sh