[
  {
    "path": "Readme.md",
    "content": "![Shadowsocks](https://github.com/teddysun/shadowsocks_install/raw/master/shadowsocks.png)\n# Auto install Shadowsocks Server\n\nshadowsocks.sh\n===============\n- Auto Install Shadowsocks(Python) Server for CentOS/Debian/Ubuntu\n- https://teddysun.com/342.html\n\nshadowsocks-libev.sh\n===============\n- Auto Install Shadowsocks(libev) Server for CentOS\n- https://teddysun.com/357.html\n\nshadowsocks-libev-debian.sh\n===============\n- Auto Install Shadowsocks(libev) Server for Debian/Ubuntu\n- https://teddysun.com/358.html\n\nshadowsocks-go.sh\n===============\n- Auto Install Shadowsocks(Go) Server for CentOS/Debian/Ubuntu\n- https://teddysun.com/392.html\n\nshadowsocks-crond.sh\n===============\n- Check Shadowsocks(All version) Server is running or not, and start it if not running\n- https://teddysun.com/525.html\n\nshadowsocksR.sh\n===============\n- Auto Install ShadowsocksR Server for CentOS/Debian/Ubuntu\n- https://shadowsocks.be/9.html\n\nshadowsocks-all.sh\n==================\n- Auto Install Shadowsocks Server (all version) for CentOS/Debian/Ubuntu\n- https://teddysun.com/486.html\n\nhaproxy.sh\n===============\n- Auto Install haproxy for Shadowsocks Server\n- https://shadowsocks.be/10.html\n\nCopyright (C) 2014-2019 Teddysun\n"
  },
  {
    "path": "docker/go-shadowsocks2/Dockerfile.architecture",
    "content": "# Dockerfile for go-shadowsocks2 based alpine\n# Copyright (C) 2019 - 2024 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/go-shadowsocks2\n# https://github.com/teddysun/v2ray-plugin\n# https://github.com/teddysun/xray-plugin\n\nFROM alpine:latest\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nARG TARGETPLATFORM\nWORKDIR /root\nCOPY go-shadowsocks2.sh /root/go-shadowsocks2.sh\nCOPY v2ray-plugin.sh /root/v2ray-plugin.sh\nCOPY xray-plugin.sh /root/xray-plugin.sh\nRUN set -ex \\\n\t&& apk add --no-cache tzdata \\\n\t&& chmod +x /root/go-shadowsocks2.sh /root/v2ray-plugin.sh /root/xray-plugin.sh \\\n\t&& /root/go-shadowsocks2.sh \"${TARGETPLATFORM}\" \\\n\t&& /root/v2ray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& /root/xray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& rm -fv /root/go-shadowsocks2.sh /root/v2ray-plugin.sh /root/xray-plugin.sh\n\nENV TZ=Asia/Shanghai\nENV SERVER_PORT=9000\nENV METHOD=AEAD_CHACHA20_POLY1305\nENV PASSWORD=teddysun.com\nENV ARGS=\nCMD exec go-shadowsocks2 \\\n\t-s \"ss://${METHOD}:${PASSWORD}@:${SERVER_PORT}\" \\\n\t-verbose \\\n\t${ARGS}"
  },
  {
    "path": "docker/go-shadowsocks2/README.md",
    "content": "## Go-shadowsocks2 Docker Image by Teddysun\n\n[go-shadowsocks2][1] is a fresh implementation of Shadowsocks in Go which can help you get through firewalls.\n\nBased on alpine with latest version [go-shadowsocks2][1] and [v2ray-plugin][6] + [xray-plugin][7].\n\nDocker images are built for quick deployment in various computing cloud providers.\n\nFor more information on docker and containerization technologies, refer to [official document][3].\n\n## Prepare the host\n\nIf you need to install docker by yourself, follow the [official installation guide][4].\n\n## Pull the image\n\n```bash\n$ docker pull teddysun/go-shadowsocks2\n```\n\nThis pulls the latest release of go-shadowsocks2.\n\nIt can be found at [Docker Hub][5].\n\n## Start a container\n\nYou **must set environment variable** at first.\n\n- `SERVER_PORT`: Server listening on port, default  `9000`;\n- `METHOD`: Encryption method to use, available ciphers: `AEAD_AES_128_GCM`, `AEAD_AES_256_GCM`, `AEAD_CHACHA20_POLY1305`, default `AEAD_CHACHA20_POLY1305`;\n- `PASSWORD`: Your own password, default `teddysun.com`;\n- `ARGS`: Additional arguments, for example: `-plugin v2ray-plugin -plugin-opts \"server\"` or `-plugin xray-plugin -plugin-opts \"server\"`. \n\nFor more `v2ray-plugin` configrations please visit v2ray-plugin [usage][8].\n\nFor more `xray-plugin` configrations please visit xray-plugin [usage][9].\n\n**1.** There is an example to start a container with default environment variables:\n\n```bash\n$ docker run -d -p 9000:9000 -p 9000:9000/udp --name go-ss --restart=always teddysun/go-shadowsocks2\n```\n\n**2.** There is an example to start a container that listen on port `8989`, using `AEAD_AES_256_GCM` AEAD cipher with password `password00`:\n\n```bash\n$ docker run -d -p 8989:8989 -p 8989:8989/udp --name go-ss --restart=always -e SERVER_PORT=8989 -e METHOD=AEAD_AES_256_GCM -e PASSWORD=password00 teddysun/go-shadowsocks2\n```\n\n**3.** There is an example to start a container that listen on port `8989`, using `AEAD_AES_256_GCM` AEAD cipher with password `password00` and supported SIP003 plugins `v2ray-plugin` over websocket (HTTP):\n\n```bash\n$ docker run -d -p 8989:8989 -p 8989:8989/udp --name go-ss --restart=always -e SERVER_PORT=8989 -e METHOD=AEAD_AES_256_GCM -e PASSWORD=password00 -e ARGS=\"-plugin v2ray-plugin -plugin-opts \"server\"\" teddysun/go-shadowsocks2\n```\n\n**4.** There is an example to start a container that listen on port `8989`, using `AEAD_AES_256_GCM` AEAD cipher with password `password00` and supported SIP003 plugins `xray-plugin` over websocket (HTTP):\n\n```bash\n$ docker run -d -p 8989:8989 -p 8989:8989/udp --name go-ss --restart=always -e SERVER_PORT=8989 -e METHOD=AEAD_AES_256_GCM -e PASSWORD=password00 -e ARGS=\"-plugin xray-plugin -plugin-opts \"server\"\" teddysun/go-shadowsocks2\n```\n\n**Warning**: The port number must be opened in firewall.\n\n[1]: https://github.com/shadowsocks/go-shadowsocks2\n[2]: https://shadowsocks.org/en/index.html\n[3]: https://docs.docker.com/\n[4]: https://docs.docker.com/install/\n[5]: https://hub.docker.com/r/teddysun/go-shadowsocks2/\n[6]: https://github.com/teddysun/v2ray-plugin\n[7]: https://github.com/teddysun/xray-plugin\n[8]: https://github.com/teddysun/v2ray-plugin#usage\n[9]: https://github.com/teddysun/xray-plugin#usage"
  },
  {
    "path": "docker/go-shadowsocks2/build_go-shadowsocks2.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for build multi-architectures go-shadowsocks2 binary file\n# \n# Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x\n# \n# Copyright (C) 2020 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/shadowsocks/go-shadowsocks2\n\ncur_dir=\"$(pwd)\"\n\nCOMMANDS=( git go )\nfor CMD in \"${COMMANDS[@]}\"; do\n    if [ ! \"$(command -v \"${CMD}\")\" ]; then\n        echo \"${CMD} is not installed, please install it and try again\" && exit 1\n    fi\ndone\n\ncd ${cur_dir}\ngit clone https://github.com/shadowsocks/go-shadowsocks2.git\ncd go-shadowsocks2 || exit 2\ngo get -d -v\n\nLDFLAGS=\"-s -w\"\nARCHS=( 386 amd64 arm arm64 ppc64le s390x )\nARMS=( 6 7 )\n\nfor ARCH in ${ARCHS[@]}; do\n    if [ \"${ARCH}\" = \"arm\" ]; then\n        for V in ${ARMS[@]}; do\n            echo \"Building go-shadowsocks2_linux_${ARCH}${V}\"\n            env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${V} go build -v -ldflags \"${LDFLAGS}\" -o ${cur_dir}/go-shadowsocks2_linux_${ARCH}${V}\n        done\n    else\n        echo \"Building go-shadowsocks2_linux_${ARCH}\"\n        env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -ldflags \"${LDFLAGS}\" -o ${cur_dir}/go-shadowsocks2_linux_${ARCH}\n    fi\ndone\n\nchmod +x ${cur_dir}/go-shadowsocks2_linux_*\n# clean up\ncd ${cur_dir} && rm -fr go-shadowsocks2\n"
  },
  {
    "path": "docker/go-shadowsocks2/go-shadowsocks2.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for go-shadowsocks2 based alpine with Docker image\n# \n# Copyright (C) 2019 - 2020 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/shadowsocks/go-shadowsocks2\n\nPLATFORM=$1\nif [ -z \"$PLATFORM\" ]; then\n    ARCH=\"amd64\"\nelse\n    case \"$PLATFORM\" in\n        linux/386)\n            ARCH=\"386\"\n            ;;\n        linux/amd64)\n            ARCH=\"amd64\"\n            ;;\n        linux/arm/v6)\n            ARCH=\"arm6\"\n            ;;\n        linux/arm/v7)\n            ARCH=\"arm7\"\n            ;;\n        linux/arm64|linux/arm64/v8)\n            ARCH=\"arm64\"\n            ;;\n        linux/ppc64le)\n            ARCH=\"ppc64le\"\n            ;;\n        linux/s390x)\n            ARCH=\"s390x\"\n            ;;\n        *)\n            ARCH=\"\"\n            ;;\n    esac\nfi\n[ -z \"${ARCH}\" ] && echo \"Error: Not supported OS Architecture\" && exit 1\n# Download binary file\nGO_SHADOWSOCKS2_FILE=\"go-shadowsocks2_linux_${ARCH}\"\necho \"Downloading go-shadowsocks2 binary file: ${GO_SHADOWSOCKS2_FILE}\"\nwget -O /usr/bin/go-shadowsocks2 https://dl.lamp.sh/files/${GO_SHADOWSOCKS2_FILE} > /dev/null 2>&1\nif [ $? -ne 0 ]; then\n    echo \"Error: Failed to download go-shadowsocks2 binary file: ${GO_SHADOWSOCKS2_FILE}\" && exit 1\nfi\nchmod +x /usr/bin/go-shadowsocks2\necho \"Download go-shadowsocks2 binary file: ${GO_SHADOWSOCKS2_FILE} completed\"\n"
  },
  {
    "path": "docker/go-shadowsocks2/v2ray-plugin.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for go-shadowsocks2 supported SIP003 plugins based alpine with Docker image\n# \n# Copyright (C) 2019 - 2021 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n\nPLATFORM=$1\nif [ -z \"$PLATFORM\" ]; then\n    ARCH=\"amd64\"\nelse\n    case \"$PLATFORM\" in\n        linux/386)\n            ARCH=\"386\"\n            ;;\n        linux/amd64)\n            ARCH=\"amd64\"\n            ;;\n        linux/arm/v6)\n            ARCH=\"arm6\"\n            ;;\n        linux/arm/v7)\n            ARCH=\"arm7\"\n            ;;\n        linux/arm64|linux/arm64/v8)\n            ARCH=\"arm64\"\n            ;;\n        linux/ppc64le)\n            ARCH=\"ppc64le\"\n            ;;\n        linux/s390x)\n            ARCH=\"s390x\"\n            ;;\n        *)\n            ARCH=\"\"\n            ;;\n    esac\nfi\n[ -z \"${ARCH}\" ] && echo \"Error: Not supported OS Architecture\" && exit 1\n# Download v2ray-plugin binary file\nV2RAY_PLUGIN_FILE=\"v2ray-plugin_linux_${ARCH}\"\necho \"Downloading v2ray-plugin binary file: ${V2RAY_PLUGIN_FILE}\"\nwget -O /usr/bin/v2ray-plugin https://dl.lamp.sh/files/${V2RAY_PLUGIN_FILE} > /dev/null 2>&1\nif [ $? -ne 0 ]; then\n    echo \"Error: Failed to download v2ray-plugin binary file: ${V2RAY_PLUGIN_FILE}\" && exit 1\nfi\nchmod +x /usr/bin/v2ray-plugin\necho \"Download v2ray-plugin binary file: ${V2RAY_PLUGIN_FILE} completed\"\n"
  },
  {
    "path": "docker/go-shadowsocks2/xray-plugin.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for go-shadowsocks2 supported SIP003 plugins based alpine with Docker image\n# \n# Copyright (C) 2019 - 2021 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/teddysun/xray-plugin\n\nPLATFORM=$1\nif [ -z \"$PLATFORM\" ]; then\n    ARCH=\"amd64\"\nelse\n    case \"$PLATFORM\" in\n        linux/386)\n            ARCH=\"386\"\n            ;;\n        linux/amd64)\n            ARCH=\"amd64\"\n            ;;\n        linux/arm/v6)\n            ARCH=\"arm6\"\n            ;;\n        linux/arm/v7)\n            ARCH=\"arm7\"\n            ;;\n        linux/arm64|linux/arm64/v8)\n            ARCH=\"arm64\"\n            ;;\n        linux/ppc64le)\n            ARCH=\"ppc64le\"\n            ;;\n        linux/s390x)\n            ARCH=\"s390x\"\n            ;;\n        *)\n            ARCH=\"\"\n            ;;\n    esac\nfi\n[ -z \"${ARCH}\" ] && echo \"Error: Not supported OS Architecture\" && exit 1\n# Download xray-plugin binary file\nXRAY_PLUGIN_FILE=\"xray-plugin_linux_${ARCH}\"\necho \"Downloading xray-plugin binary file: ${XRAY_PLUGIN_FILE}\"\nwget -O /usr/bin/xray-plugin https://dl.lamp.sh/files/${XRAY_PLUGIN_FILE} > /dev/null 2>&1\nif [ $? -ne 0 ]; then\n    echo \"Error: Failed to download xray-plugin binary file: ${XRAY_PLUGIN_FILE}\" && exit 1\nfi\nchmod +x /usr/bin/xray-plugin\necho \"Download xray-plugin binary file: ${XRAY_PLUGIN_FILE} completed\"\n"
  },
  {
    "path": "docker/shadowsocks-go/.dockerignore",
    "content": ".dockerignore\nREADME.md"
  },
  {
    "path": "docker/shadowsocks-go/Dockerfile",
    "content": "# Dockerfile for Shadowsocks-go based alpine\n# Copyright (C) 2018 - 2024 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-go\n\nFROM alpine:latest\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nWORKDIR /root\nCOPY shadowsocks-go.sh /root/shadowsocks-go.sh\nCOPY config_sample.json /etc/shadowsocks-go/config.json\nRUN set -ex \\\n\t&& apk add --no-cache tzdata \\\n\t&& chmod +x /root/shadowsocks-go.sh \\\n\t&& /root/shadowsocks-go.sh \\\n\t&& rm -fv /root/shadowsocks-go.sh\n\nENV TZ=Asia/Shanghai\nVOLUME /etc/shadowsocks-go\n\nCMD [ \"shadowsocks-server\", \"-c\", \"/etc/shadowsocks-go/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-go/Dockerfile.architecture",
    "content": "# Dockerfile for Shadowsocks-go based alpine\n# Copyright (C) 2018 - 2024 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-go\n\nFROM alpine:latest\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nARG TARGETPLATFORM\nWORKDIR /root\nCOPY shadowsocks-go.sh /root/shadowsocks-go.sh\nCOPY config_sample.json /etc/shadowsocks-go/config.json\nRUN set -ex \\\n\t&& apk add --no-cache tzdata \\\n\t&& chmod +x /root/shadowsocks-go.sh \\\n\t&& /root/shadowsocks-go.sh \"${TARGETPLATFORM}\" \\\n\t&& rm -fv /root/shadowsocks-go.sh\n\nENV TZ=Asia/Shanghai\nVOLUME /etc/shadowsocks-go\n\nCMD [ \"shadowsocks-server\", \"-c\", \"/etc/shadowsocks-go/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-go/README.md",
    "content": "## Shadowsocks-go Docker Image by Teddysun\n\n[Shadowsocks-go][1] is a lightweight tunnel proxy which can help you get through firewalls.\n\nIt is a port of [Shadowsocks][2] created by @cyfdecyf.\n\nDocker images are built for quick deployment in various computing cloud providers.\n\nFor more information on docker and containerization technologies, refer to [official document][3].\n\n## Prepare the host\n\nIf you need to install docker by yourself, follow the [official installation guide][4].\n\n## Pull the image\n\n```bash\n$ docker pull teddysun/shadowsocks-go\n```\n\nThis pulls the latest release of shadowsocks-go.\n\nIt can be found at [Docker Hub][5].\n\n## Start a container\n\nYou **must create a configuration file**  `/etc/shadowsocks-go/config.json` in host at first:\n\n```\n$ mkdir -p /etc/shadowsocks-go\n```\n\nA sample in JSON like below:\n\n```\n{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"local_port\":1080,\n    \"password\":\"password0\",\n    \"method\":\"aes-256-cfb\",\n    \"timeout\":120\n}\n```\n\nThis container with sample configuration `/etc/shadowsocks-go/config.json`\n\nThere is an example to start a container that listens on `9000` (both TCP and UDP):\n\n```bash\n$ docker run -d -p 9000:9000 -p 9000:9000/udp --name ss-go --restart=always -v /etc/shadowsocks-go:/etc/shadowsocks-go teddysun/shadowsocks-go\n```\n\n**Warning**: The port number must be same as configuration and opened in firewall.\n\n[1]: https://github.com/shadowsocks/shadowsocks-go\n[2]: https://shadowsocks.org/en/index.html\n[3]: https://docs.docker.com/\n[4]: https://docs.docker.com/install/\n[5]: https://hub.docker.com/r/teddysun/shadowsocks-go/"
  },
  {
    "path": "docker/shadowsocks-go/config_sample.json",
    "content": "{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"local_port\":1080,\n    \"password\":\"password0\",\n    \"method\":\"aes-256-cfb\",\n    \"timeout\":120\n}"
  },
  {
    "path": "docker/shadowsocks-go/shadowsocks-go.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for shadowsocks-go based alpine with Docker image\n# \n# Copyright (C) 2019 - 2020 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-go\n\nPLATFORM=$1\nif [ -z \"$PLATFORM\" ]; then\n    ARCH=\"amd64\"\nelse\n    case \"$PLATFORM\" in\n        linux/386)\n            ARCH=\"386\"\n            ;;\n        linux/amd64)\n            ARCH=\"amd64\"\n            ;;\n        linux/arm/v6)\n            ARCH=\"arm6\"\n            ;;\n        linux/arm/v7)\n            ARCH=\"arm7\"\n            ;;\n        linux/arm64|linux/arm64/v8)\n            ARCH=\"arm64\"\n            ;;\n        linux/ppc64le)\n            ARCH=\"ppc64le\"\n            ;;\n        linux/s390x)\n            ARCH=\"s390x\"\n            ;;\n        *)\n            ARCH=\"\"\n            ;;\n    esac\nfi\n[ -z \"${ARCH}\" ] && echo \"Error: Not supported OS Architecture\" && exit 1\n# Download binary file\nSHADOWSOCKS_GO_FILE=\"shadowsocks-go_linux_${ARCH}\"\necho \"Downloading shadowsocks-go binary file: ${SHADOWSOCKS_GO_FILE}\"\nwget -O /usr/bin/shadowsocks-server https://dl.lamp.sh/files/${SHADOWSOCKS_GO_FILE} > /dev/null 2>&1\nif [ $? -ne 0 ]; then\n    echo \"Error: Failed to download shadowsocks-go binary file: ${SHADOWSOCKS_GO_FILE}\" && exit 1\nfi\nchmod +x /usr/bin/shadowsocks-server\necho \"Download shadowsocks-go binary file: ${SHADOWSOCKS_GO_FILE} completed\"\n"
  },
  {
    "path": "docker/shadowsocks-libev/Dockerfile",
    "content": "# Dockerfile for shadowsocks-libev based alpine\n# Copyright (C) 2018 - 2026 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-libev\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n# https://github.com/teddysun/xray-plugin\n\nFROM alpine:3.23\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nWORKDIR /root\nCOPY v2ray-plugin.sh /root/v2ray-plugin.sh\nCOPY xray-plugin.sh /root/xray-plugin.sh\nCOPY config_sample.json /etc/shadowsocks-libev/config.json\nRUN set -ex \\\n\t&& runDeps=\"git build-base c-ares-dev cmake libcap libev-dev libtool libsodium-dev linux-headers mbedtls-dev pcre2-dev\" \\\n\t&& apk add --no-cache --virtual .build-deps ${runDeps} \\\n\t&& mkdir -p /root/libev \\\n\t&& cd /root/libev \\\n\t&& git clone --depth=1 https://github.com/shadowsocks/shadowsocks-libev.git . \\\n\t&& git submodule update --init --recursive \\\n\t&& mkdir -p build \\\n\t&& cd build \\\n\t&& cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTING=OFF -DWITH_STATIC=OFF -DCMAKE_BUILD_TYPE=Release \\\n\t&& make -j$(getconf _NPROCESSORS_ONLN) \\\n\t&& make install \\\n\t&& ls /usr/bin/ss-* | xargs -n1 setcap cap_net_bind_service+ep \\\n\t&& apk add --no-cache \\\n\t\ttzdata \\\n\t\trng-tools \\\n\t\tca-certificates \\\n\t\t$(scanelf --needed --nobanner /usr/bin/ss-* \\\n\t\t| awk '{ gsub(/,/, \"\\nso:\", $2); print \"so:\" $2 }' \\\n\t\t| xargs -r apk info --installed \\\n\t\t| sort -u) \\\n\t&& apk del .build-deps \\\n\t&& cd /root \\\n\t&& rm -rf /root/libev \\\n\t&& chmod +x /root/v2ray-plugin.sh /root/xray-plugin.sh \\\n\t&& /root/v2ray-plugin.sh \\\n\t&& /root/xray-plugin.sh \\\n\t&& rm -f /root/v2ray-plugin.sh /root/xray-plugin.sh\n\nVOLUME /etc/shadowsocks-libev\nENV TZ=Asia/Shanghai\nCMD [ \"ss-server\", \"-c\", \"/etc/shadowsocks-libev/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-libev/Dockerfile.architecture",
    "content": "# Dockerfile for shadowsocks-libev based alpine\n# Copyright (C) 2018 - 2026 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-libev\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n# https://github.com/teddysun/xray-plugin\n\nFROM alpine:3.23\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nARG TARGETPLATFORM\nWORKDIR /root\nCOPY v2ray-plugin.sh /root/v2ray-plugin.sh\nCOPY xray-plugin.sh /root/xray-plugin.sh\nCOPY config_sample.json /etc/shadowsocks-libev/config.json\nRUN set -ex \\\n\t&& runDeps=\"git build-base c-ares-dev cmake libcap libev-dev libtool libsodium-dev linux-headers mbedtls-dev pcre2-dev\" \\\n\t&& apk add --no-cache --virtual .build-deps ${runDeps} \\\n\t&& mkdir -p /root/libev \\\n\t&& cd /root/libev \\\n\t&& git clone --depth=1 https://github.com/shadowsocks/shadowsocks-libev.git . \\\n\t&& git submodule update --init --recursive \\\n\t&& mkdir -p build \\\n\t&& cd build \\\n\t&& cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTING=OFF -DWITH_STATIC=OFF -DCMAKE_BUILD_TYPE=Release \\\n\t&& make -j$(getconf _NPROCESSORS_ONLN) \\\n\t&& make install \\\n\t&& ls /usr/bin/ss-* | xargs -n1 setcap cap_net_bind_service+ep \\\n\t&& apk add --no-cache \\\n\t\ttzdata \\\n\t\trng-tools \\\n\t\tca-certificates \\\n\t\t$(scanelf --needed --nobanner /usr/bin/ss-* \\\n\t\t| awk '{ gsub(/,/, \"\\nso:\", $2); print \"so:\" $2 }' \\\n\t\t| xargs -r apk info --installed \\\n\t\t| sort -u) \\\n\t&& apk del .build-deps \\\n\t&& cd /root \\\n\t&& rm -rf /root/libev \\\n\t&& chmod +x /root/v2ray-plugin.sh /root/xray-plugin.sh \\\n\t&& /root/v2ray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& /root/xray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& rm -f /root/v2ray-plugin.sh /root/xray-plugin.sh\n\nVOLUME /etc/shadowsocks-libev\nENV TZ=Asia/Shanghai\nCMD [ \"ss-server\", \"-c\", \"/etc/shadowsocks-libev/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-libev/Dockerfile_edge.architecture",
    "content": "# Dockerfile for shadowsocks-libev based alpine\n# Copyright (C) 2018 - 2024 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-libev\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n# https://github.com/teddysun/xray-plugin\n\nFROM alpine:edge\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nARG TARGETPLATFORM\nWORKDIR /root\nCOPY v2ray-plugin.sh /root/v2ray-plugin.sh\nCOPY xray-plugin.sh /root/xray-plugin.sh\nCOPY config_sample.json /etc/shadowsocks-libev/config.json\nRUN set -ex \\\n\t&& echo \"https://dl-cdn.alpinelinux.org/alpine/edge/testing/\" >> /etc/apk/repositories \\\n\t&& apk add --no-cache tzdata rng-tools ca-certificates shadowsocks-libev \\\n\t&& chmod +x /root/v2ray-plugin.sh /root/xray-plugin.sh \\\n\t&& /root/v2ray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& /root/xray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& rm -f /root/v2ray-plugin.sh /root/xray-plugin.sh\n\nVOLUME /etc/shadowsocks-libev\nENV TZ=Asia/Shanghai\nCMD [ \"/usr/bin/ss-server\", \"-c\", \"/etc/shadowsocks-libev/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-libev/README.md",
    "content": "## Shadowsocks-libev Docker Image by Teddysun\n\n[shadowsocks-libev][1] is a lightweight secured socks5 proxy for embedded devices and low end boxes.\n\nIt is a port of [shadowsocks][2] created by @clowwindy maintained by @madeye and @linusyang.\n\nBased on alpine with latest version [shadowsocks-libev](https://github.com/shadowsocks/shadowsocks-libev) and [v2ray-plugin](https://github.com/teddysun/v2ray-plugin), [xray-plugin](https://github.com/teddysun/xray-plugin).\n\nDocker images are built for quick deployment in various computing cloud providers.\n\nFor more information on docker and containerization technologies, refer to [official document][3].\n\n## Prepare the host\n\nIf you need to install docker by yourself, follow the [official installation guide][4].\n\n## Pull the image\n\n```bash\n$ docker pull teddysun/shadowsocks-libev\n```\n\nThis pulls the latest release of shadowsocks-libev.\n\nIt can be found at [Docker Hub][5].\n\n## Start a container\n\nYou **must create a configuration file**  `/etc/shadowsocks-libev/config.json` in host at first:\n\n```\n$ mkdir -p /etc/shadowsocks-libev\n```\n\nA sample in JSON like below:\n\n```\n{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"password\":\"password0\",\n    \"timeout\":300,\n    \"method\":\"aes-256-gcm\",\n    \"fast_open\":true,\n    \"nameserver\":\"8.8.8.8\",\n    \"mode\":\"tcp_and_udp\"\n}\n```\n\nIf you want to enable **v2ray-plugin**, a sample in JSON like below:\n\n```\n{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"password\":\"password0\",\n    \"timeout\":300,\n    \"method\":\"aes-256-gcm\",\n    \"fast_open\":true,\n    \"nameserver\":\"8.8.8.8\",\n    \"mode\":\"tcp_and_udp\",\n    \"plugin\":\"v2ray-plugin\",\n    \"plugin_opts\":\"server\"\n}\n```\n\nIf you want to enable **xray-plugin**, a sample in JSON like below:\n\n```\n{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"password\":\"password0\",\n    \"timeout\":300,\n    \"method\":\"aes-256-gcm\",\n    \"fast_open\":true,\n    \"nameserver\":\"8.8.8.8\",\n    \"mode\":\"tcp_and_udp\",\n    \"plugin\":\"xray-plugin\",\n    \"plugin_opts\":\"server\"\n}\n```\n\nFor more `v2ray-plugin` configrations please visit v2ray-plugin [usage][6].\n\nFor more `xray-plugin` configrations please visit xray-plugin [usage][7].\n\nThis container with sample configuration `/etc/shadowsocks-libev/config.json`\n\nThere is an example to start a container that listens on `9000` (both TCP and UDP):\n\n```bash\n$ docker run -d -p 9000:9000 -p 9000:9000/udp --name ss-libev --restart=always -v /etc/shadowsocks-libev:/etc/shadowsocks-libev teddysun/shadowsocks-libev\n```\n\n**Warning**: The port number must be same as configuration and opened in firewall.\n\n[1]: https://github.com/shadowsocks/shadowsocks-libev\n[2]: https://shadowsocks.org/en/index.html\n[3]: https://docs.docker.com/\n[4]: https://docs.docker.com/install/\n[5]: https://hub.docker.com/r/teddysun/shadowsocks-libev/\n[6]: https://github.com/shadowsocks/v2ray-plugin#usage\n[7]: https://github.com/teddysun/xray-plugin#usage"
  },
  {
    "path": "docker/shadowsocks-libev/build_v2ray-plugin.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for build multi-architectures v2ray-plugin binary file\n# \n# Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x\n# \n# Copyright (C) 2020 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/shadowsocks/v2ray-plugin\n\ncur_dir=\"$(pwd)\"\n\nCOMMANDS=( git go )\nfor CMD in \"${COMMANDS[@]}\"; do\n    if [ ! \"$(command -v \"${CMD}\")\" ]; then\n        echo \"${CMD} is not installed, please install it and try again\" && exit 1\n    fi\ndone\n\ncd ${cur_dir}\ngit clone https://github.com/shadowsocks/v2ray-plugin.git\ncd v2ray-plugin || exit 2\n\nVERSION=\"$(git describe --tags)\"\nLDFLAGS=\"-X main.VERSION=$VERSION -s -w\"\nGCFLAGS=\"\"\nARCHS=( 386 amd64 arm arm64 ppc64le s390x )\nARMS=( 6 7 )\n\nfor ARCH in ${ARCHS[@]}; do\n    if [ \"${ARCH}\" = \"arm\" ]; then\n        for V in ${ARMS[@]}; do\n            echo \"Building v2ray-plugin_linux_${ARCH}${V}\"\n            env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${V} go build -v -ldflags \"${LDFLAGS}\" -gcflags \"${GCFLAGS}\" -o ${cur_dir}/v2ray-plugin_linux_${ARCH}${V}\n        done\n    else\n        echo \"Building v2ray-plugin_linux_${ARCH}\"\n        env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -ldflags \"${LDFLAGS}\" -gcflags \"${GCFLAGS}\" -o ${cur_dir}/v2ray-plugin_linux_${ARCH}\n    fi\ndone\n\n# clean up\ncd ${cur_dir} && rm -fr v2ray-plugin\n"
  },
  {
    "path": "docker/shadowsocks-libev/build_xray-plugin.sh",
    "content": "#!/bin/bash\n#\n# This is a Shell script for build multi-architectures xray-plugin binary file\n# \n# Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x\n# \n# Copyright (C) 2021 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/teddysun/xray-plugin\n\ncur_dir=\"$(pwd)\"\n\nCOMMANDS=( git go )\nfor CMD in \"${COMMANDS[@]}\"; do\n    if [ ! \"$(command -v \"${CMD}\")\" ]; then\n        echo \"${CMD} is not installed, please install it and try again\" && exit 1\n    fi\ndone\n\ncd ${cur_dir}\ngit clone https://github.com/teddysun/xray-plugin.git\ncd xray-plugin || exit 2\n\nVERSION=\"$(git describe --tags)\"\nLDFLAGS=\"-X main.VERSION=$VERSION -s -w\"\nARCHS=( 386 amd64 arm arm64 ppc64le s390x )\nARMS=( 6 7 )\n\nfor ARCH in ${ARCHS[@]}; do\n    if [ \"${ARCH}\" = \"arm\" ]; then\n        for V in ${ARMS[@]}; do\n            echo \"Building xray-plugin_linux_${ARCH}${V}\"\n            env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${V} go build -v -trimpath -ldflags \"${LDFLAGS}\" -o ${cur_dir}/xray-plugin_linux_${ARCH}${V}\n        done\n    else\n        echo \"Building xray-plugin_linux_${ARCH}\"\n        env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -trimpath -ldflags \"${LDFLAGS}\" -o ${cur_dir}/xray-plugin_linux_${ARCH}\n    fi\ndone\n\n# clean up\ncd ${cur_dir} && rm -fr xray-plugin\n"
  },
  {
    "path": "docker/shadowsocks-libev/config_sample.json",
    "content": "{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"password\":\"password0\",\n    \"timeout\":300,\n    \"method\":\"aes-256-gcm\",\n    \"fast_open\":true,\n    \"nameserver\":\"8.8.8.8\",\n    \"mode\":\"tcp_and_udp\"\n}"
  },
  {
    "path": "docker/shadowsocks-libev/v2ray-plugin.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for shadowsocks-libev based alpine with Docker image\n# \n# Copyright (C) 2019 - 2021 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-libev\n# https://github.com/shadowsocks/simple-obfs\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n\nPLATFORM=$1\nif [ -z \"$PLATFORM\" ]; then\n    ARCH=\"amd64\"\nelse\n    case \"$PLATFORM\" in\n        linux/386)\n            ARCH=\"386\"\n            ;;\n        linux/amd64)\n            ARCH=\"amd64\"\n            ;;\n        linux/arm/v6)\n            ARCH=\"arm6\"\n            ;;\n        linux/arm/v7)\n            ARCH=\"arm7\"\n            ;;\n        linux/arm64|linux/arm64/v8)\n            ARCH=\"arm64\"\n            ;;\n        linux/ppc64le)\n            ARCH=\"ppc64le\"\n            ;;\n        linux/s390x)\n            ARCH=\"s390x\"\n            ;;\n        *)\n            ARCH=\"\"\n            ;;\n    esac\nfi\n[ -z \"${ARCH}\" ] && echo \"Error: Not supported OS Architecture\" && exit 1\n# Download v2ray-plugin binary file\nV2RAY_PLUGIN_FILE=\"v2ray-plugin_linux_${ARCH}\"\necho \"Downloading v2ray-plugin binary file: ${V2RAY_PLUGIN_FILE}\"\nwget -O /usr/bin/v2ray-plugin https://dl.lamp.sh/files/${V2RAY_PLUGIN_FILE} > /dev/null 2>&1\nif [ $? -ne 0 ]; then\n    echo \"Error: Failed to download v2ray-plugin binary file: ${V2RAY_PLUGIN_FILE}\" && exit 1\nfi\nchmod +x /usr/bin/v2ray-plugin\necho \"Download v2ray-plugin binary file: ${V2RAY_PLUGIN_FILE} completed\"\n"
  },
  {
    "path": "docker/shadowsocks-libev/xray-plugin.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for shadowsocks-libev supported SIP003 plugins based alpine with Docker image\n# \n# Copyright (C) 2019 - 2021 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/teddysun/xray-plugin\n\nPLATFORM=$1\nif [ -z \"$PLATFORM\" ]; then\n    ARCH=\"amd64\"\nelse\n    case \"$PLATFORM\" in\n        linux/386)\n            ARCH=\"386\"\n            ;;\n        linux/amd64)\n            ARCH=\"amd64\"\n            ;;\n        linux/arm/v6)\n            ARCH=\"arm6\"\n            ;;\n        linux/arm/v7)\n            ARCH=\"arm7\"\n            ;;\n        linux/arm64|linux/arm64/v8)\n            ARCH=\"arm64\"\n            ;;\n        linux/ppc64le)\n            ARCH=\"ppc64le\"\n            ;;\n        linux/s390x)\n            ARCH=\"s390x\"\n            ;;\n        *)\n            ARCH=\"\"\n            ;;\n    esac\nfi\n[ -z \"${ARCH}\" ] && echo \"Error: Not supported OS Architecture\" && exit 1\n# Download xray-plugin binary file\nXRAY_PLUGIN_FILE=\"xray-plugin_linux_${ARCH}\"\necho \"Downloading xray-plugin binary file: ${XRAY_PLUGIN_FILE}\"\nwget -O /usr/bin/xray-plugin https://dl.lamp.sh/files/${XRAY_PLUGIN_FILE} > /dev/null 2>&1\nif [ $? -ne 0 ]; then\n    echo \"Error: Failed to download xray-plugin binary file: ${XRAY_PLUGIN_FILE}\" && exit 1\nfi\nchmod +x /usr/bin/xray-plugin\necho \"Download xray-plugin binary file: ${XRAY_PLUGIN_FILE} completed\"\n"
  },
  {
    "path": "docker/shadowsocks-python/.dockerignore",
    "content": ".dockerignore\nREADME.md"
  },
  {
    "path": "docker/shadowsocks-python/Dockerfile",
    "content": "# Dockerfile for Shadowsocks-Python based alpine\n# Copyright (C) 2018 - 2024 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks/tree/master\n\nFROM python:3.9-alpine\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nRUN set -ex \\\n\t&& apk add --no-cache unzip libsodium-dev openssl mbedtls \\\n\t&& cd /tmp \\\n\t&& wget -O shadowsocks.zip https://github.com/shadowsocks/shadowsocks/archive/master.zip \\\n\t&& unzip shadowsocks.zip \\\n\t&& cd shadowsocks-master \\\n\t&& python setup.py install \\\n\t&& cd /tmp \\\n\t&& rm -fr shadowsocks.zip shadowsocks-master \n\nCOPY config_sample.json /etc/shadowsocks-python/config.json\nVOLUME /etc/shadowsocks-python\n\nCMD [ \"ssserver\", \"-c\", \"/etc/shadowsocks-python/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-python/Dockerfile.architecture",
    "content": "# Dockerfile for Shadowsocks-Python based alpine\n# Copyright (C) 2018 - 2024 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks/tree/master\n\nFROM python:3.9-alpine\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nRUN set -ex \\\n\t&& apk add --no-cache unzip libsodium-dev openssl mbedtls \\\n\t&& cd /tmp \\\n\t&& wget -O shadowsocks.zip https://github.com/shadowsocks/shadowsocks/archive/master.zip \\\n\t&& unzip shadowsocks.zip \\\n\t&& cd shadowsocks-master \\\n\t&& python setup.py install \\\n\t&& cd /tmp \\\n\t&& rm -fr shadowsocks.zip shadowsocks-master \n\nCOPY config_sample.json /etc/shadowsocks-python/config.json\nVOLUME /etc/shadowsocks-python\n\nCMD [ \"ssserver\", \"-c\", \"/etc/shadowsocks-python/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-python/README.md",
    "content": "## Shadowsocks-Python Docker Image by Teddysun\n\n[Shadowsocks][1] is a lightweight secured socks5 proxy for embedded devices and low end boxes.\n\nIt is a port of [Shadowsocks][2] created by @clowwindy .\n\nDocker images are built for quick deployment in various computing cloud providers.\n\nFor more information on docker and containerization technologies, refer to [official document][3].\n\n## Prepare the host\n\nIf you need to install docker by yourself, follow the [official installation guide][4].\n\n## Pull the image\n\n```bash\n$ docker pull teddysun/shadowsocks-python\n```\n\nThis pulls the latest release of shadowsocks-python.\n\nIt can be found at [Docker Hub][5].\n\n## Start a container\n\nYou **must create a configuration file**  `/etc/shadowsocks-python/config.json` in host at first:\n\n```\n$ mkdir -p /etc/shadowsocks-python\n```\n\nA sample in JSON like below:\n\n```\n{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"local_address\":\"127.0.0.1\",\n    \"local_port\":1080,\n    \"password\":\"password0\",\n    \"timeout\":120,\n    \"method\":\"aes-256-cfb\",\n    \"fast_open\":true\n}\n```\n\nThis container with sample configuration `/etc/shadowsocks-python/config.json`\n\nThere is an example to start a container that listens on `9000` (both TCP and UDP):\n\n```bash\n$ docker run -d -p 9000:9000 -p 9000:9000/udp --name ss --restart=always -v /etc/shadowsocks-python:/etc/shadowsocks-python teddysun/shadowsocks-python\n```\n\n**Warning**: The port number must be same as configuration and opened in firewall.\n\n[1]: https://github.com/shadowsocks/shadowsocks/tree/master\n[2]: https://shadowsocks.org/en/index.html\n[3]: https://docs.docker.com/\n[4]: https://docs.docker.com/install/\n[5]: https://hub.docker.com/r/teddysun/shadowsocks-python/"
  },
  {
    "path": "docker/shadowsocks-python/config_sample.json",
    "content": "{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"local_address\":\"127.0.0.1\",\n    \"local_port\":1080,\n    \"password\":\"password0\",\n    \"timeout\":120,\n    \"method\":\"aes-256-cfb\",\n    \"fast_open\":true\n}"
  },
  {
    "path": "docker/shadowsocks-r/.dockerignore",
    "content": ".dockerignore\nREADME.md"
  },
  {
    "path": "docker/shadowsocks-r/Dockerfile",
    "content": "# Dockerfile for ShadowsocksR based alpine\n# Copyright (C) 2018 - 2024 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocksrr/shadowsocksr\n\nFROM python:3.9-alpine\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nRUN set -ex \\\n\t&& apk add --no-cache tar libsodium-dev openssl \\\n\t&& wget -O /tmp/shadowsocksr-3.2.2.tar.gz https://github.com/shadowsocksrr/shadowsocksr/archive/3.2.2.tar.gz \\\n\t&& tar zxf /tmp/shadowsocksr-3.2.2.tar.gz -C /tmp \\\n\t&& mv /tmp/shadowsocksr-3.2.2/shadowsocks /usr/local/ \\\n\t&& rm -fr /tmp/shadowsocksr-3.2.2 \\\n\t&& rm -f /tmp/shadowsocksr-3.2.2.tar.gz\n\nCOPY ./config_sample.json /etc/shadowsocks-r/config.json\nVOLUME /etc/shadowsocks-r\n\nCMD [ \"/usr/local/shadowsocks/server.py\", \"-c\", \"/etc/shadowsocks-r/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-r/Dockerfile.architecture",
    "content": "# Dockerfile for ShadowsocksR based alpine\n# Copyright (C) 2018 - 2024 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocksrr/shadowsocksr\n\nFROM python:3.9-alpine\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nRUN set -ex \\\n\t&& apk add --no-cache tar libsodium-dev openssl \\\n\t&& wget -O /tmp/shadowsocksr-3.2.2.tar.gz https://github.com/shadowsocksrr/shadowsocksr/archive/3.2.2.tar.gz \\\n\t&& tar zxf /tmp/shadowsocksr-3.2.2.tar.gz -C /tmp \\\n\t&& mv /tmp/shadowsocksr-3.2.2/shadowsocks /usr/local/ \\\n\t&& rm -fr /tmp/shadowsocksr-3.2.2 \\\n\t&& rm -f /tmp/shadowsocksr-3.2.2.tar.gz\n\nCOPY ./config_sample.json /etc/shadowsocks-r/config.json\nVOLUME /etc/shadowsocks-r\n\nCMD [ \"/usr/local/shadowsocks/server.py\", \"-c\", \"/etc/shadowsocks-r/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-r/README.md",
    "content": "## ShadowsocksR Docker Image by Teddysun\n\n[shadowsocksr][1] is a lightweight secured socks5 proxy for embedded devices and low end boxes.\n\nIt is a port of [shadowsocks][2] created by @clowwindy maintained by @breakwa11 and @Akkariiin.\n\nDocker images are built for quick deployment in various computing cloud providers.\n\nFor more information on docker and containerization technologies, refer to [official document][3].\n\n## Prepare the host\n\nIf you need to install docker by yourself, follow the [official installation guide][4].\n\n## Pull the image\n\n```bash\n$ docker pull teddysun/shadowsocks-r\n```\n\nThis pulls the latest release of shadowsocks-r.\n\nIt can be found at [Docker Hub][5].\n\n## Start a container\n\nYou **must create a configuration file**  `/etc/shadowsocks-r/config.json` in host at first:\n\n```\n$ mkdir -p /etc/shadowsocks-r\n```\n\nA sample in JSON like below:\n\n```\n{\n    \"server\":\"0.0.0.0\",\n    \"server_ipv6\":\"::\",\n    \"server_port\":9000,\n    \"local_address\":\"127.0.0.1\",\n    \"local_port\":1080,\n    \"password\":\"password0\",\n    \"timeout\":120,\n    \"method\":\"aes-256-cfb\",\n    \"protocol\":\"origin\",\n    \"protocol_param\":\"\",\n    \"obfs\":\"plain\",\n    \"obfs_param\":\"\",\n    \"redirect\":\"\",\n    \"dns_ipv6\":false,\n    \"fast_open\":true,\n    \"workers\":1\n}\n```\n\nThis container with sample configuration `/etc/shadowsocks-r/config.json`\n\nThere is an example to start a container that listens on `9000` (both TCP and UDP):\n\n```bash\n$ docker run -d -p 9000:9000 -p 9000:9000/udp --name ssr --restart=always -v /etc/shadowsocks-r:/etc/shadowsocks-r teddysun/shadowsocks-r\n```\n\n**Warning**: The port number must be same as configuration and opened in firewall.\n\n[1]: https://github.com/shadowsocksrr/shadowsocksr\n[2]: https://shadowsocks.org/en/index.html\n[3]: https://docs.docker.com/\n[4]: https://docs.docker.com/install/\n[5]: https://hub.docker.com/r/teddysun/shadowsocks-r/"
  },
  {
    "path": "docker/shadowsocks-r/config_sample.json",
    "content": "{\n    \"server\":\"0.0.0.0\",\n    \"server_ipv6\":\"::\",\n    \"server_port\":9000,\n    \"local_address\":\"127.0.0.1\",\n    \"local_port\":1080,\n    \"password\":\"password0\",\n    \"timeout\":120,\n    \"method\":\"aes-256-cfb\",\n    \"protocol\":\"origin\",\n    \"protocol_param\":\"\",\n    \"obfs\":\"plain\",\n    \"obfs_param\":\"\",\n    \"redirect\":\"\",\n    \"dns_ipv6\":false,\n    \"fast_open\":true,\n    \"workers\":1\n}"
  },
  {
    "path": "docker/shadowsocks-rust/Dockerfile",
    "content": "# Dockerfile for shadowsocks-rust based alpine\n# Copyright (C) 2020 - 2024 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-rust\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n# https://github.com/teddysun/xray-plugin\n\nFROM alpine:latest\n\nWORKDIR /root\nCOPY v2ray-plugin.sh /root/v2ray-plugin.sh\nCOPY xray-plugin.sh /root/xray-plugin.sh\nCOPY config_sample.json /etc/shadowsocks-rust/config.json\nRUN set -ex \\\n\t&& runDeps=\"git build-base c-ares-dev autoconf automake libev-dev libtool libsodium-dev linux-headers mbedtls-dev pcre-dev openssl-dev cargo\" \\\n\t&& apk add --no-cache --virtual .build-deps ${runDeps} \\\n\t&& mkdir -p /root/rust \\\n\t&& cd /root/rust \\\n\t&& VERSION=$(wget --no-check-certificate -qO- https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases/latest | grep 'tag_name' | cut -d\\\" -f4) \\\n\t&& git clone -b ${VERSION} --depth=1 https://github.com/shadowsocks/shadowsocks-rust.git . \\\n\t&& cargo build --release --features \"local-tun local-redir stream-cipher aead-cipher-2022\" --verbose \\\n\t&& cp -pv target/release/sslocal /usr/bin \\\n\t&& cp -pv target/release/ssmanager /usr/bin \\\n\t&& cp -pv target/release/ssserver /usr/bin \\\n\t&& cp -pv target/release/ssservice /usr/bin \\\n\t&& cp -pv target/release/ssurl /usr/bin \\\n\t&& apk add --no-cache \\\n\t\ttzdata \\\n\t\trng-tools \\\n\t\tca-certificates \\\n\t\tlibgcc \\\n\t\t$(scanelf --needed --nobanner /usr/bin/ss* \\\n\t\t| awk '{ gsub(/,/, \"\\nso:\", $2); print \"so:\" $2 }' \\\n\t\t| xargs -r apk info --installed \\\n\t\t| sort -u) \\\n\t&& apk del .build-deps \\\n\t&& cd /root \\\n\t&& rm -rf /root/rust \\\n\t&& chmod +x /root/v2ray-plugin.sh /root/xray-plugin.sh \\\n\t&& /root/v2ray-plugin.sh \\\n\t&& /root/xray-plugin.sh \\\n\t&& rm -f /root/v2ray-plugin.sh /root/xray-plugin.sh\n\nVOLUME /etc/shadowsocks-rust\nENV TZ=Asia/Shanghai\nCMD [ \"/usr/bin/ssservice\", \"server\", \"--log-without-time\", \"-c\", \"/etc/shadowsocks-rust/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-rust/Dockerfile.alpine",
    "content": "# Dockerfile for shadowsocks-rust based alpine\n# Copyright (C) 2020 - 2024 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-rust\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n# https://github.com/teddysun/xray-plugin\n\nFROM alpine:latest\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nARG TARGETPLATFORM\nWORKDIR /root\nCOPY v2ray-plugin.sh /root/v2ray-plugin.sh\nCOPY xray-plugin.sh /root/xray-plugin.sh\nCOPY shadowsocks-rust-alpine.sh /root/shadowsocks-rust-alpine.sh\nCOPY config_sample.json /etc/shadowsocks-rust/config.json\nRUN set -ex \\\n\t&& chmod +x /root/shadowsocks-rust-alpine.sh /root/v2ray-plugin.sh /root/xray-plugin.sh \\\n\t&& /root/shadowsocks-rust-alpine.sh \"${TARGETPLATFORM}\" \\\n\t&& rm -f /root/shadowsocks-rust-alpine.sh \\\n\t&& apk add --no-cache \\\n\t\ttzdata \\\n\t\trng-tools \\\n\t\tca-certificates \\\n\t\tlibgcc \\\n\t\t$(scanelf --needed --nobanner /usr/bin/ss* \\\n\t\t| awk '{ gsub(/,/, \"\\nso:\", $2); print \"so:\" $2 }' \\\n\t\t| xargs -r apk info --installed \\\n\t\t| sort -u) \\\n\t&& /root/v2ray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& /root/xray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& rm -f /root/v2ray-plugin.sh /root/xray-plugin.sh\n\nVOLUME /etc/shadowsocks-rust\nENV TZ=Asia/Shanghai\nCMD [ \"/usr/bin/ssservice\", \"server\", \"--log-without-time\", \"-c\", \"/etc/shadowsocks-rust/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-rust/Dockerfile.architecture",
    "content": "# Dockerfile for shadowsocks-rust based alpine\n# Copyright (C) 2020 - 2024 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-rust\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n# https://github.com/teddysun/xray-plugin\n\nFROM alpine:latest\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nARG TARGETPLATFORM\nWORKDIR /root\nCOPY v2ray-plugin.sh /root/v2ray-plugin.sh\nCOPY xray-plugin.sh /root/xray-plugin.sh\nCOPY config_sample.json /etc/shadowsocks-rust/config.json\nRUN set -ex \\\n\t&& runDeps=\"git build-base c-ares-dev autoconf automake libev-dev libtool libsodium-dev linux-headers mbedtls-dev pcre-dev openssl-dev cargo\" \\\n\t&& apk add --no-cache --virtual .build-deps ${runDeps} \\\n\t&& mkdir -p /root/rust \\\n\t&& cd /root/rust \\\n\t&& VERSION=$(wget --no-check-certificate -qO- https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases/latest | grep 'tag_name' | cut -d\\\" -f4) \\\n\t&& git clone -b ${VERSION} --depth=1 https://github.com/shadowsocks/shadowsocks-rust.git . \\\n\t&& cargo build --release --features \"local-tun local-redir stream-cipher aead-cipher-2022\" --verbose \\\n\t&& cp -pv target/release/sslocal /usr/bin \\\n\t&& cp -pv target/release/ssmanager /usr/bin \\\n\t&& cp -pv target/release/ssserver /usr/bin \\\n\t&& cp -pv target/release/ssservice /usr/bin \\\n\t&& cp -pv target/release/ssurl /usr/bin \\\n\t&& apk add --no-cache \\\n\t\ttzdata \\\n\t\trng-tools \\\n\t\tca-certificates \\\n\t\tlibgcc \\\n\t\t$(scanelf --needed --nobanner /usr/bin/ss* \\\n\t\t| awk '{ gsub(/,/, \"\\nso:\", $2); print \"so:\" $2 }' \\\n\t\t| xargs -r apk info --installed \\\n\t\t| sort -u) \\\n\t&& apk del .build-deps \\\n\t&& cd /root \\\n\t&& rm -rf /root/rust \\\n\t&& chmod +x /root/v2ray-plugin.sh /root/xray-plugin.sh \\\n\t&& /root/v2ray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& /root/xray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& rm -f /root/v2ray-plugin.sh /root/xray-plugin.sh\n\nVOLUME /etc/shadowsocks-rust\nENV TZ=Asia/Shanghai\nCMD [ \"/usr/bin/ssservice\", \"server\", \"--log-without-time\", \"-c\", \"/etc/shadowsocks-rust/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-rust/Dockerfile.debian",
    "content": "# Dockerfile for shadowsocks-rust based debian\n# Copyright (C) 2020 - 2025 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-rust\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n# https://github.com/teddysun/xray-plugin\n\nFROM debian:trixie-slim\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nARG TARGETPLATFORM\nWORKDIR /root\nCOPY v2ray-plugin.sh /root/v2ray-plugin.sh\nCOPY xray-plugin.sh /root/xray-plugin.sh\nCOPY shadowsocks-rust-debian.sh /root/shadowsocks-rust-debian.sh\nCOPY config_sample.json /etc/shadowsocks-rust/config.json\nRUN set -ex \\\n\t&& apt-get update \\\n\t&& apt-get install -y --no-install-recommends wget ca-certificates xz-utils \\\n\t&& chmod +x /root/shadowsocks-rust-debian.sh \\\n\t&& /root/shadowsocks-rust-debian.sh \"${TARGETPLATFORM}\" \\\n\t&& rm -f /root/shadowsocks-rust-debian.sh \\\n\t&& chmod +x /root/v2ray-plugin.sh /root/xray-plugin.sh \\\n\t&& /root/v2ray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& /root/xray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& rm -f /root/v2ray-plugin.sh /root/xray-plugin.sh \\\n\t&& apt-get -y autoremove \\\n\t&& apt-get -y clean \\\n\t&& rm -rf /var/lib/apt/lists/*\n\nVOLUME /etc/shadowsocks-rust\nENV TZ=Asia/Shanghai\nCMD [ \"/usr/bin/ssservice\", \"server\", \"--log-without-time\", \"-c\", \"/etc/shadowsocks-rust/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-rust/Dockerfile_edge.alpine",
    "content": "# Dockerfile for shadowsocks-rust based alpine\n# Copyright (C) 2020 - 2024 Teddysun <i@teddysun.com>\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-rust\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n# https://github.com/teddysun/xray-plugin\n\nFROM alpine:edge\nLABEL maintainer=\"Teddysun <i@teddysun.com>\"\n\nARG TARGETPLATFORM\nWORKDIR /root\nCOPY v2ray-plugin.sh /root/v2ray-plugin.sh\nCOPY xray-plugin.sh /root/xray-plugin.sh\nCOPY config_sample.json /etc/shadowsocks-rust/config.json\nRUN set -ex \\\n\t&& chmod +x /root/v2ray-plugin.sh /root/xray-plugin.sh \\\n\t&& apk add --no-cache tzdata rng-tools ca-certificates shadowsocks-rust \\\n\t&& /root/v2ray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& /root/xray-plugin.sh \"${TARGETPLATFORM}\" \\\n\t&& rm -f /root/v2ray-plugin.sh /root/xray-plugin.sh\n\nVOLUME /etc/shadowsocks-rust\nENV TZ=Asia/Shanghai\nCMD [ \"/usr/bin/ssservice\", \"server\", \"--log-without-time\", \"-c\", \"/etc/shadowsocks-rust/config.json\" ]\n"
  },
  {
    "path": "docker/shadowsocks-rust/README.md",
    "content": "## Shadowsocks-rust Docker Image by Teddysun\n\n![Shadowsocks](https://github.com/teddysun/shadowsocks_install/raw/master/shadowsocks.png)\n\n[shadowsocks-rust][1] is a fast tunnel proxy that helps you bypass firewalls.\n\nIt is a port of [shadowsocks][2] created by [@zonyitoo](https://github.com/zonyitoo).\n\nBased on alpine with latest version [shadowsocks-rust](https://github.com/shadowsocks/shadowsocks-rust) and [v2ray-plugin](https://github.com/teddysun/v2ray-plugin), [xray-plugin](https://github.com/teddysun/xray-plugin).\n\nDocker images are built for quick deployment in various computing cloud providers.\n\nFor more information on docker and containerization technologies, refer to [official document][3].\n\n## Prepare the host\n\nIf you need to install docker by yourself, follow the [official installation guide][4].\n\n## Pull the image\n\n```bash\n$ docker pull teddysun/shadowsocks-rust\n```\n\nThis pulls the latest release of shadowsocks-rust.\n\nIt can be found at [Docker Hub][5].\n\n## Start a container\n\nYou **must create a configuration file**  `/etc/shadowsocks-rust/config.json` in host at first:\n\n```\n$ mkdir -p /etc/shadowsocks-rust\n```\n\nA sample in JSON like below:\n\n```\n{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"password\":\"password0\",\n    \"timeout\":300,\n    \"method\":\"aes-256-gcm\",\n    \"nameserver\":\"8.8.8.8\",\n    \"mode\":\"tcp_and_udp\"\n}\n```\n\nIf you want to enable **v2ray-plugin**, a sample in JSON like below:\n\n```\n{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"password\":\"password0\",\n    \"timeout\":300,\n    \"method\":\"aes-256-gcm\",\n    \"nameserver\":\"8.8.8.8\",\n    \"mode\":\"tcp_and_udp\",\n    \"plugin\":\"v2ray-plugin\",\n    \"plugin_opts\":\"server\"\n}\n```\n\nIf you want to enable **xray-plugin**, a sample in JSON like below:\n\n```\n{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"password\":\"password0\",\n    \"timeout\":300,\n    \"method\":\"aes-256-gcm\",\n    \"nameserver\":\"8.8.8.8\",\n    \"mode\":\"tcp_and_udp\",\n    \"plugin\":\"xray-plugin\",\n    \"plugin_opts\":\"server\"\n}\n```\n\nFor more `v2ray-plugin` configrations please visit v2ray-plugin [usage][6].\n\nFor more `xray-plugin` configrations please visit xray-plugin [usage][7].\n\nThis container with sample configuration `/etc/shadowsocks-rust/config.json`\n\nThere is an example to start a container that listens on `9000` (both TCP and UDP):\n\n```bash\n$ docker run -d -p 9000:9000 -p 9000:9000/udp --name ss-rust --restart=always -v /etc/shadowsocks-rust:/etc/shadowsocks-rust teddysun/shadowsocks-rust\n```\n\n**Warning**: The port number must be same as configuration and opened in firewall.\n\n[1]: https://github.com/shadowsocks/shadowsocks-rust\n[2]: https://shadowsocks.org/en/index.html\n[3]: https://docs.docker.com/\n[4]: https://docs.docker.com/install/\n[5]: https://hub.docker.com/r/teddysun/shadowsocks-rust/\n[6]: https://github.com/shadowsocks/v2ray-plugin#usage\n[7]: https://github.com/teddysun/xray-plugin#usage"
  },
  {
    "path": "docker/shadowsocks-rust/build_v2ray-plugin.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for build multi-architectures v2ray-plugin binary file\n# \n# Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x\n# \n# Copyright (C) 2020 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/shadowsocks/v2ray-plugin\n\ncur_dir=\"$(pwd)\"\n\nCOMMANDS=( git go )\nfor CMD in \"${COMMANDS[@]}\"; do\n    if [ ! \"$(command -v \"${CMD}\")\" ]; then\n        echo \"${CMD} is not installed, please install it and try again\" && exit 1\n    fi\ndone\n\ncd ${cur_dir}\ngit clone https://github.com/shadowsocks/v2ray-plugin.git\ncd v2ray-plugin || exit 2\n\nVERSION=\"$(git describe --tags)\"\nLDFLAGS=\"-X main.VERSION=$VERSION -s -w\"\nGCFLAGS=\"\"\nARCHS=( 386 amd64 arm arm64 ppc64le s390x )\nARMS=( 6 7 )\n\nfor ARCH in ${ARCHS[@]}; do\n    if [ \"${ARCH}\" = \"arm\" ]; then\n        for V in ${ARMS[@]}; do\n            echo \"Building v2ray-plugin_linux_${ARCH}${V}\"\n            env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${V} go build -v -ldflags \"${LDFLAGS}\" -gcflags \"${GCFLAGS}\" -o ${cur_dir}/v2ray-plugin_linux_${ARCH}${V}\n        done\n    else\n        echo \"Building v2ray-plugin_linux_${ARCH}\"\n        env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -ldflags \"${LDFLAGS}\" -gcflags \"${GCFLAGS}\" -o ${cur_dir}/v2ray-plugin_linux_${ARCH}\n    fi\ndone\n\n# clean up\ncd ${cur_dir} && rm -fr v2ray-plugin\n"
  },
  {
    "path": "docker/shadowsocks-rust/build_xray-plugin.sh",
    "content": "#!/bin/bash\n#\n# This is a Shell script for build multi-architectures xray-plugin binary file\n# \n# Supported architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x\n# \n# Copyright (C) 2021 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/teddysun/xray-plugin\n\ncur_dir=\"$(pwd)\"\n\nCOMMANDS=( git go )\nfor CMD in \"${COMMANDS[@]}\"; do\n    if [ ! \"$(command -v \"${CMD}\")\" ]; then\n        echo \"${CMD} is not installed, please install it and try again\" && exit 1\n    fi\ndone\n\ncd ${cur_dir}\ngit clone https://github.com/teddysun/xray-plugin.git\ncd xray-plugin || exit 2\n\nVERSION=\"$(git describe --tags)\"\nLDFLAGS=\"-X main.VERSION=$VERSION -s -w\"\nARCHS=( 386 amd64 arm arm64 ppc64le s390x )\nARMS=( 6 7 )\n\nfor ARCH in ${ARCHS[@]}; do\n    if [ \"${ARCH}\" = \"arm\" ]; then\n        for V in ${ARMS[@]}; do\n            echo \"Building xray-plugin_linux_${ARCH}${V}\"\n            env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GOARM=${V} go build -v -trimpath -ldflags \"${LDFLAGS}\" -o ${cur_dir}/xray-plugin_linux_${ARCH}${V}\n        done\n    else\n        echo \"Building xray-plugin_linux_${ARCH}\"\n        env CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -trimpath -ldflags \"${LDFLAGS}\" -o ${cur_dir}/xray-plugin_linux_${ARCH}\n    fi\ndone\n\n# clean up\ncd ${cur_dir} && rm -fr xray-plugin\n"
  },
  {
    "path": "docker/shadowsocks-rust/config_sample.json",
    "content": "{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"password\":\"password0\",\n    \"timeout\":300,\n    \"method\":\"aes-256-gcm\",\n    \"fast_open\":true,\n    \"nameserver\":\"8.8.8.8\",\n    \"mode\":\"tcp_and_udp\"\n}"
  },
  {
    "path": "docker/shadowsocks-rust/shadowsocks-rust-alpine.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for shadowsocks-rust based alpine with Docker image\n# \n# Copyright (C) 2019 - 2024 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-rust\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n# https://github.com/teddysun/xray-plugin\n\nPLATFORM=$1\nif [ -z \"$PLATFORM\" ]; then\n    ARCH=\"x86_64-unknown-linux-musl\"\nelse\n    case \"$PLATFORM\" in\n        linux/386)\n            ARCH=\"\"\n            ;;\n        linux/amd64)\n            ARCH=\"x86_64-unknown-linux-musl\"\n            ;;\n        linux/arm/v6)\n            ARCH=\"arm-unknown-linux-musleabi\"\n            ;;\n        linux/arm/v7)\n            ARCH=\"arm-unknown-linux-musleabihf\"\n            ;;\n        linux/arm64|linux/arm64/v8)\n            ARCH=\"aarch64-unknown-linux-musl\"\n            ;;\n        linux/ppc64le)\n            ARCH=\"\"\n            ;;\n        linux/s390x)\n            ARCH=\"\"\n            ;;\n        *)\n            ARCH=\"\"\n            ;;\n    esac\nfi\n[ -z \"${ARCH}\" ] && echo \"Error: Not supported OS Architecture\" && exit 1\nVERSION=$(wget --no-check-certificate -qO- https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases/latest | grep 'tag_name' | cut -d\\\" -f4)\n[ -z \"${VERSION}\" ] && echo \"Error: Get shadowsocks-rust latest version failed\" && exit 1\n# Download shadowsocks-rust binary file\nSHADOWSOCKS_RUST_FILE=\"shadowsocks-${VERSION}.${ARCH}.tar.xz\"\nSHADOWSOCKS_RUST_URL=\"https://github.com/shadowsocks/shadowsocks-rust/releases/download/${VERSION}/${SHADOWSOCKS_RUST_FILE}\"\necho \"Downloading shadowsocks-rust binary file: ${SHADOWSOCKS_RUST_FILE}\"\nwget -O ${SHADOWSOCKS_RUST_FILE} ${SHADOWSOCKS_RUST_URL} > /dev/null 2>&1\nif [ $? -ne 0 ]; then\n    echo \"Error: Failed to download shadowsocks-rust binary file: ${SHADOWSOCKS_RUST_FILE}\" && exit 1\nfi\necho \"Download shadowsocks-rust binary file: ${SHADOWSOCKS_RUST_FILE} completed\"\necho \"Extracting ${SHADOWSOCKS_RUST_FILE}...\"\ntar Jxf ${SHADOWSOCKS_RUST_FILE} -C /usr/bin\nchmod +x /usr/bin/ss*\nrm -f ${SHADOWSOCKS_RUST_FILE}\necho \"Install shadowsocks-rust binary file: ${SHADOWSOCKS_RUST_FILE} completed\"\n"
  },
  {
    "path": "docker/shadowsocks-rust/shadowsocks-rust-debian.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for shadowsocks-rust based debian with Docker image\n# \n# Copyright (C) 2019 - 2024 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-rust\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n# https://github.com/teddysun/xray-plugin\n\nPLATFORM=$1\nif [ -z \"$PLATFORM\" ]; then\n    ARCH=\"x86_64-unknown-linux-gnu\"\nelse\n    case \"$PLATFORM\" in\n        linux/386)\n            ARCH=\"\"\n            ;;\n        linux/amd64)\n            ARCH=\"x86_64-unknown-linux-gnu\"\n            ;;\n        linux/arm/v6)\n            ARCH=\"\"\n            ;;\n        linux/arm/v7)\n            ARCH=\"arm-unknown-linux-gnueabihf\"\n            ;;\n        linux/arm64|linux/arm64/v8)\n            ARCH=\"aarch64-unknown-linux-gnu\"\n            ;;\n        linux/ppc64le)\n            ARCH=\"\"\n            ;;\n        linux/s390x)\n            ARCH=\"\"\n            ;;\n        *)\n            ARCH=\"\"\n            ;;\n    esac\nfi\n[ -z \"${ARCH}\" ] && echo \"Error: Not supported OS Architecture\" && exit 1\nVERSION=$(wget --no-check-certificate -qO- https://api.github.com/repos/shadowsocks/shadowsocks-rust/releases/latest | grep 'tag_name' | cut -d\\\" -f4)\n[ -z \"${VERSION}\" ] && echo \"Error: Get shadowsocks-rust latest version failed\" && exit 1\n# Download shadowsocks-rust binary file\nSHADOWSOCKS_RUST_FILE=\"shadowsocks-${VERSION}.${ARCH}.tar.xz\"\nSHADOWSOCKS_RUST_URL=\"https://github.com/shadowsocks/shadowsocks-rust/releases/download/${VERSION}/${SHADOWSOCKS_RUST_FILE}\"\necho \"Downloading shadowsocks-rust binary file: ${SHADOWSOCKS_RUST_FILE}\"\nwget -O ${SHADOWSOCKS_RUST_FILE} ${SHADOWSOCKS_RUST_URL} > /dev/null 2>&1\nif [ $? -ne 0 ]; then\n    echo \"Error: Failed to download shadowsocks-rust binary file: ${SHADOWSOCKS_RUST_FILE}\" && exit 1\nfi\necho \"Download shadowsocks-rust binary file: ${SHADOWSOCKS_RUST_FILE} completed\"\necho \"Extracting ${SHADOWSOCKS_RUST_FILE}...\"\ntar Jxf ${SHADOWSOCKS_RUST_FILE} -C /usr/bin\nchmod +x /usr/bin/ss*\nrm -f ${SHADOWSOCKS_RUST_FILE}\necho \"Install shadowsocks-rust binary file: ${SHADOWSOCKS_RUST_FILE} completed\"\n"
  },
  {
    "path": "docker/shadowsocks-rust/v2ray-plugin.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for shadowsocks-libev supported SIP003 plugins based alpine with Docker image\n# \n# Copyright (C) 2019 - 2021 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/shadowsocks/v2ray-plugin\n# https://github.com/teddysun/v2ray-plugin\n\nPLATFORM=$1\nif [ -z \"$PLATFORM\" ]; then\n    ARCH=\"amd64\"\nelse\n    case \"$PLATFORM\" in\n        linux/386)\n            ARCH=\"386\"\n            ;;\n        linux/amd64)\n            ARCH=\"amd64\"\n            ;;\n        linux/arm/v6)\n            ARCH=\"arm6\"\n            ;;\n        linux/arm/v7)\n            ARCH=\"arm7\"\n            ;;\n        linux/arm64|linux/arm64/v8)\n            ARCH=\"arm64\"\n            ;;\n        linux/ppc64le)\n            ARCH=\"ppc64le\"\n            ;;\n        linux/s390x)\n            ARCH=\"s390x\"\n            ;;\n        *)\n            ARCH=\"\"\n            ;;\n    esac\nfi\n[ -z \"${ARCH}\" ] && echo \"Error: Not supported OS Architecture\" && exit 1\n# Download v2ray-plugin binary file\nV2RAY_PLUGIN_FILE=\"v2ray-plugin_linux_${ARCH}\"\necho \"Downloading v2ray-plugin binary file: ${V2RAY_PLUGIN_FILE}\"\nwget -O /usr/bin/v2ray-plugin https://dl.lamp.sh/files/${V2RAY_PLUGIN_FILE} > /dev/null 2>&1\nif [ $? -ne 0 ]; then\n    echo \"Error: Failed to download v2ray-plugin binary file: ${V2RAY_PLUGIN_FILE}\" && exit 1\nfi\nchmod +x /usr/bin/v2ray-plugin\necho \"Download v2ray-plugin binary file: ${V2RAY_PLUGIN_FILE} completed\"\n"
  },
  {
    "path": "docker/shadowsocks-rust/xray-plugin.sh",
    "content": "#!/bin/sh\n#\n# This is a Shell script for shadowsocks-rust supported SIP003 plugins based alpine with Docker image\n# \n# Copyright (C) 2019 - 2021 Teddysun <i@teddysun.com>\n#\n# Reference URL:\n# https://github.com/teddysun/xray-plugin\n\nPLATFORM=$1\nif [ -z \"$PLATFORM\" ]; then\n    ARCH=\"amd64\"\nelse\n    case \"$PLATFORM\" in\n        linux/386)\n            ARCH=\"386\"\n            ;;\n        linux/amd64)\n            ARCH=\"amd64\"\n            ;;\n        linux/arm/v6)\n            ARCH=\"arm6\"\n            ;;\n        linux/arm/v7)\n            ARCH=\"arm7\"\n            ;;\n        linux/arm64|linux/arm64/v8)\n            ARCH=\"arm64\"\n            ;;\n        linux/ppc64le)\n            ARCH=\"ppc64le\"\n            ;;\n        linux/s390x)\n            ARCH=\"s390x\"\n            ;;\n        *)\n            ARCH=\"\"\n            ;;\n    esac\nfi\n[ -z \"${ARCH}\" ] && echo \"Error: Not supported OS Architecture\" && exit 1\n# Download xray-plugin binary file\nXRAY_PLUGIN_FILE=\"xray-plugin_linux_${ARCH}\"\necho \"Downloading xray-plugin binary file: ${XRAY_PLUGIN_FILE}\"\nwget -O /usr/bin/xray-plugin https://dl.lamp.sh/files/${XRAY_PLUGIN_FILE} > /dev/null 2>&1\nif [ $? -ne 0 ]; then\n    echo \"Error: Failed to download xray-plugin binary file: ${XRAY_PLUGIN_FILE}\" && exit 1\nfi\nchmod +x /usr/bin/xray-plugin\necho \"Download xray-plugin binary file: ${XRAY_PLUGIN_FILE} completed\"\n"
  },
  {
    "path": "haproxy.sh",
    "content": "#!/usr/bin/env bash\n#\n# System Required:  CentOS, Debian, Ubuntu\n#\n# Description: Install haproxy for Shadowsocks server\n#\n# Author: Teddysun <i@teddysun.com>\n#\n# Intro:  https://shadowsocks.be/10.html\n#\n\ncur_dir=`pwd`\n\n[[ $EUID -ne 0 ]] && echo \"Error: This script must be run as root!\" && exit 1\n\nclear\necho\necho \"#############################################################\"\necho \"# Install haproxy for Shadowsocks server                    #\"\necho \"# Intro: https://shadowsocks.be/10.html                     #\"\necho \"# Author: Teddysun <i@teddysun.com>                         #\"\necho \"#############################################################\"\necho\n\ncheck_sys() {\n    local checkType=$1\n    local value=$2\n\n    local release=''\n    local systemPackage=''\n\n    if [ -f /etc/redhat-release ]; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    elif cat /etc/issue | grep -Eqi \"debian\"; then\n        release=\"debian\"\n        systemPackage=\"apt\"\n    elif cat /etc/issue | grep -Eqi \"ubuntu\"; then\n        release=\"ubuntu\"\n        systemPackage=\"apt\"\n    elif cat /etc/issue | grep -Eqi \"centos|red hat|redhat\"; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    elif cat /proc/version | grep -Eqi \"debian\"; then\n        release=\"debian\"\n        systemPackage=\"apt\"\n    elif cat /proc/version | grep -Eqi \"ubuntu\"; then\n        release=\"ubuntu\"\n        systemPackage=\"apt\"\n    elif cat /proc/version | grep -Eqi \"centos|red hat|redhat\"; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    fi\n\n    if [ ${checkType} == \"sysRelease\" ]; then\n        if [ \"$value\" == \"$release\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    elif [ ${checkType} == \"packageManager\" ]; then\n        if [ \"$value\" == \"$systemPackage\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    fi\n}\n\ninstall_check() {\n    if check_sys packageManager yum || check_sys packageManager apt; then\n        return 0\n    else\n        return 1\n    fi\n}\n\ndisable_selinux(){\n    if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then\n        sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config\n        setenforce 0\n    fi\n}\n\nvalid_ip(){\n    local ip=$1\n    local stat=1\n    if [[ $ip =~ ^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$ ]]; then\n        OIFS=$IFS\n        IFS='.'\n        ip=($ip)\n        IFS=$OIFS\n        [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]\n        stat=$?\n    fi\n    return ${stat}\n}\n\nget_ip(){\n    local IP=$( ip addr | egrep -o '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}' | egrep -v \"^192\\.168|^172\\.1[6-9]\\.|^172\\.2[0-9]\\.|^172\\.3[0-2]\\.|^10\\.|^127\\.|^255\\.|^0\\.\" | head -n 1 )\n    [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )\n    [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip )\n    [ ! -z ${IP} ] && echo ${IP} || echo\n}\n\nget_char(){\n    SAVEDSTTY=`stty -g`\n    stty -echo\n    stty cbreak\n    dd if=/dev/tty bs=1 count=1 2> /dev/null\n    stty -raw\n    stty echo\n    stty $SAVEDSTTY\n}\n\n# Pre-installation settings\npre_install(){\n    if ! install_check; then\n        echo \"Your OS is not supported to run it.\"\n        echo \"Please change to CentOS 6+/Debian 7+/Ubuntu 12+ and try again.\"\n        exit 1\n    fi\n\n    # Set haproxy config port\n    while true\n    do\n    echo -e \"Please enter a port for haproxy and Shadowsocks server [1-65535]\"\n    read -p \"(Default port: 8989):\" haproxyport\n    [ -z \"${haproxyport}\" ] && haproxyport=\"8989\"\n    expr ${haproxyport} + 0 &>/dev/null\n    if [ $? -eq 0 ]; then\n        if [ ${haproxyport} -ge 1 ] && [ ${haproxyport} -le 65535 ]; then\n            echo\n            echo \"---------------------------\"\n            echo \"port = ${haproxyport}\"\n            echo \"---------------------------\"\n            echo\n            break\n        else\n            echo \"Enter error! Please enter a correct number.\"\n        fi\n    else\n        echo \"Enter error! Please enter a correct number.\"\n    fi\n    done\n\n    # Set haproxy config IPv4 address\n    while :\n    do\n    echo -e \"Please enter your Shadowsocks server's IPv4 address for haproxy\"\n    read -p \"(IPv4 is):\" haproxyip\n    valid_ip ${haproxyip}\n    if [ $? -eq 0 ]; then\n        echo\n        echo \"---------------------------\"\n        echo \"IP = ${haproxyip}\"\n        echo \"---------------------------\"\n        echo\n        break\n    else\n        echo \"Enter error! Please enter correct IPv4 address.\"\n    fi\n    done\n\n    echo\n    echo \"Press any key to start...or Press Ctrl+C to cancel\"\n    char=`get_char`\n\n}\n\n# Config haproxy\nconfig_haproxy(){\n    # Config DNS nameserver\n    if ! grep -q \"8.8.8.8\" /etc/resolv.conf; then\n        cp -p /etc/resolv.conf /etc/resolv.conf.bak\n        echo \"nameserver 8.8.8.8\" > /etc/resolv.conf\n        echo \"nameserver 8.8.4.4\" >> /etc/resolv.conf\n    fi\n\n    if [ -f /etc/haproxy/haproxy.cfg ]; then\n        cp -p /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bak\n    fi\n\n    cat > /etc/haproxy/haproxy.cfg<<-EOF\nglobal\n    ulimit-n    51200\n    log         127.0.0.1 local2\n    chroot      /var/lib/haproxy\n    pidfile     /var/run/haproxy.pid\n    user        haproxy\n    group       haproxy\n    daemon\n\ndefaults\n    mode                    tcp\n    log                     global\n    option                  dontlognull\n    timeout connect         5s\n    timeout client          1m\n    timeout server          1m\n\nfrontend ss-${haproxyport}\n        bind *:${haproxyport}\n        default_backend ss-${haproxyport}\nbackend ss-${haproxyport}\n        server server1 ${haproxyip}:${haproxyport} maxconn 20480\nEOF\n}\n\ninstall(){\n    # Install haproxy\n    if check_sys packageManager yum; then\n        yum install -y haproxy\n    elif check_sys packageManager apt; then\n        apt-get -y update\n        apt-get install -y haproxy\n    fi\n\n    if [ -d /etc/haproxy ]; then\n        echo \"haproxy install success.\"\n\n        echo \"Config haproxy start...\"\n        config_haproxy\n        echo \"Config haproxy completed...\"\n\n        if check_sys packageManager yum; then\n            chkconfig --add haproxy\n            chkconfig haproxy on\n        elif check_sys packageManager apt; then\n            update-rc.d haproxy defaults\n        fi\n\n        # Start haproxy\n        service haproxy start\n        if [ $? -eq 0 ]; then\n            echo \"haproxy start success...\"\n        else\n            echo \"haproxy start failure...\"\n        fi\n    else\n        echo\n        echo \"haproxy install failed.\"\n        exit 1\n    fi\n\n    sleep 3\n    # restart haproxy\n    service haproxy restart\n    # Active Internet connections confirm\n    netstat -nxtlp\n    echo\n    echo \"Congratulations, haproxy install completed.\"\n    echo -e \"Your haproxy Server IP: \\033[41;37m $(get_ip) \\033[0m\"\n    echo -e \"Your haproxy Server port: \\033[41;37m ${haproxyport} \\033[0m\"\n    echo -e \"Your Input Shadowsocks IP: \\033[41;37m ${haproxyip} \\033[0m\"\n    echo\n    echo \"Welcome to visit: https://shadowsocks.be/10.html\"\n    echo \"Enjoy it.\"\n    echo\n}\n\n\n# Install haproxy\ninstall_haproxy(){\n    disable_selinux\n    pre_install\n    install\n}\n\n# Initialization step\ninstall_haproxy 2>&1 | tee ${cur_dir}/haproxy_for_shadowsocks.log\n"
  },
  {
    "path": "sample_config/shadowsocks-go/config.json",
    "content": "{\n    \"port_password\":{\n         \"9000\":\"password0\",\n         \"9001\":\"password1\",\n         \"9002\":\"password2\",\n         \"9003\":\"password3\",\n         \"9004\":\"password4\"\n    },\n    \"method\":\"aes-256-cfb\",\n    \"timeout\":300\n}"
  },
  {
    "path": "sample_config/shadowsocks-libev/config.json",
    "content": "{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":9000,\n    \"password\":\"password0\",\n    \"timeout\":300,\n    \"user\":\"nobody\",\n    \"method\":\"aes-256-gcm\",\n    \"fast_open\":false,\n    \"nameserver\":\"8.8.8.8\",\n    \"mode\":\"tcp_and_udp\"\n}"
  },
  {
    "path": "sample_config/shadowsocks-manager/config.json",
    "content": "{\n    \"server\":\"0.0.0.0\",\n    \"port_password\":{\n         \"9000\":\"password0\",\n         \"9001\":\"password1\",\n         \"9002\":\"password2\",\n         \"9003\":\"password3\",\n         \"9004\":\"password4\"\n    },\n    \"timeout\":300,\n    \"user\":\"nobody\",\n    \"method\":\"aes-256-gcm\",\n    \"nameserver\":\"8.8.8.8\",\n    \"mode\":\"tcp_and_udp\"\n}"
  },
  {
    "path": "sample_config/shadowsocks-python/config.json",
    "content": "{\n    \"server\":\"0.0.0.0\",\n    \"local_address\":\"127.0.0.1\",\n    \"local_port\":1080,\n    \"port_password\":{\n         \"9000\":\"password0\",\n         \"9001\":\"password1\",\n         \"9002\":\"password2\",\n         \"9003\":\"password3\",\n         \"9004\":\"password4\"\n    },\n    \"timeout\":300,\n    \"method\":\"aes-256-gcm\",\n    \"fast_open\": false\n}"
  },
  {
    "path": "sample_config/shadowsocks-r/config.json",
    "content": "{\n    \"server\":\"0.0.0.0\",\n    \"server_ipv6\": \"[::]\",\n    \"local_address\":\"127.0.0.1\",\n    \"local_port\":1080,\n    \"port_password\":{\n        \"9000\":\"password0\",\n        \"9001\":\"password1\",\n        \"9002\":\"password2\",\n        \"9003\":\"password3\",\n        \"9004\":\"password4\"\n    },\n    \"timeout\":300,\n    \"method\":\"aes-256-cfb\",\n    \"protocol\": \"auth_chain_a\",\n    \"protocol_param\": \"\",\n    \"obfs\": \"http_simple_compatible\",\n    \"obfs_param\": \"\",\n    \"redirect\": \"\",\n    \"dns_ipv6\": false,\n    \"fast_open\": false,\n    \"workers\": 1\n}"
  },
  {
    "path": "shadowsocks",
    "content": "#!/bin/bash\n# chkconfig: 2345 90 10\n# description: A secure socks5 proxy, designed to protect your Internet traffic.\n\n### BEGIN INIT INFO\n# Provides:          Shadowsocks\n# Required-Start:    $network $syslog\n# Required-Stop:     $network\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: Fast tunnel proxy that helps you bypass firewalls\n# Description:       Start or stop the Shadowsocks server\n### END INIT INFO\n\n# Author: Teddysun <i@teddysun.com>\n\nNAME=Shadowsocks\nif [ -f /usr/bin/ssserver ]; then\n    DAEMON=/usr/bin/ssserver\nelif [ -f /usr/local/bin/ssserver ]; then\n    DAEMON=/usr/local/bin/ssserver\nfi\nif [ -f /etc/shadowsocks-python/config.json ]; then\n    CONF=/etc/shadowsocks-python/config.json\nelif [ -f /etc/shadowsocks.json ]; then\n    CONF=/etc/shadowsocks.json\nfi\nRETVAL=0\n\ncheck_running(){\n    PID=$(ps -ef | grep -v grep | grep -i \"${DAEMON}\" | awk '{print $2}')\n    if [ -n \"$PID\" ]; then\n        return 0\n    else\n        return 1\n    fi\n}\n\ndo_start(){\n    check_running\n    if [ $? -eq 0 ]; then\n        echo \"$NAME (pid $PID) is already running...\"\n        exit 0\n    else\n        $DAEMON -c $CONF -d start\n        RETVAL=$?\n        if [ $RETVAL -eq 0 ]; then\n            echo \"Starting $NAME success\"\n        else\n            echo \"Starting $NAME failed\"\n        fi\n    fi\n}\n\ndo_stop(){\n    check_running\n    if [ $? -eq 0 ]; then\n        $DAEMON -c $CONF -d stop\n        RETVAL=$?\n        if [ $RETVAL -eq 0 ]; then\n            echo \"Stopping $NAME success\"\n        else\n            echo \"Stopping $NAME failed\"\n        fi\n    else\n        echo \"$NAME is stopped\"\n        RETVAL=1\n    fi\n}\n\ndo_status(){\n    check_running\n    if [ $? -eq 0 ]; then\n        echo \"$NAME (pid $PID) is running...\"\n    else\n        echo \"$NAME is stopped\"\n        RETVAL=1\n    fi\n}\n\ndo_restart(){\n    do_stop\n    sleep 0.5\n    do_start\n}\n\ncase \"$1\" in\n    start|stop|restart|status)\n    do_$1\n    ;;\n    *)\n    echo \"Usage: $0 { start | stop | restart | status }\"\n    RETVAL=1\n    ;;\nesac\n\nexit $RETVAL\n"
  },
  {
    "path": "shadowsocks-all.sh",
    "content": "#!/usr/bin/env bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\nexport PATH\n#\n# Auto install Shadowsocks Server (libev and rust) with v2ray-plugin and xray-plugin\n#\n# Copyright (C) 2016-2026 Teddysun <i@teddysun.com>\n#\n# System Required:  CentOS/RHEL 8+, Debian 11+, Ubuntu 20.04+\n#\n# Reference URL:\n# https://github.com/shadowsocks/shadowsocks-libev\n# https://github.com/shadowsocks/shadowsocks-rust\n# https://github.com/teddysun/v2ray-plugin\n# https://github.com/teddysun/xray-plugin\n#\n# Thanks:\n# @madeye     <https://github.com/madeey>\n# @zonyitoo   <https://github.com/zonyitoo>\n#\n# Intro:  https://teddysun.com/486.html\n\nred='\\e[0;31m'\ngreen='\\e[0;32m'\nyellow='\\e[0;33m'\nplain='\\e[0m'\n\n[[ $EUID -ne 0 ]] && echo -e \"[${red}Error${plain}] This script must be run as root!\" && exit 1\n\ncur_dir=$( pwd )\nsoftware=(Shadowsocks-libev Shadowsocks-rust)\nplugins=(None v2ray-plugin xray-plugin)\n\nshadowsocks_libev_config='/etc/shadowsocks/shadowsocks-libev-config.json'\nshadowsocks_rust_config='/etc/shadowsocks/shadowsocks-rust-config.json'\n\n# Stream Ciphers\ncommon_ciphers=(\naes-256-gcm\naes-192-gcm\naes-128-gcm\nchacha20-ietf-poly1305\nxchacha20-ietf-poly1305\n)\n\nrust_ciphers=(\naes-256-gcm\naes-192-gcm\naes-128-gcm\nchacha20-ietf-poly1305\nxchacha20-ietf-poly1305\n2022-blake3-aes-256-gcm\n2022-blake3-aes-128-gcm\n2022-blake3-chacha20-poly1305\n)\n\n# RHEL repo URL\nrhel_repo_url='https://dl.lamp.sh/shadowsocks/rhel/teddysun.repo'\nrhel_repo_url_2='https://dl.lamp.sh/linux/rhel/teddysun_linux.repo'\n\n# Debian/Ubuntu GPG key URL\ndebian_gpg_url='https://dl.lamp.sh/shadowsocks/DEB-GPG-KEY-Teddysun'\n\ndisable_selinux(){\n    if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then\n        sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config\n        setenforce 0\n    fi\n}\n\ncheck_sys(){\n    local checkType=$1\n    local value=$2\n\n    local release=''\n    local systemPackage=''\n\n    if [[ -f /etc/redhat-release ]]; then\n        release='centos'\n        systemPackage='dnf'\n    elif grep -Eqi 'debian|raspbian' /etc/issue; then\n        release='debian'\n        systemPackage='apt'\n    elif grep -Eqi 'ubuntu' /etc/issue; then\n        release='ubuntu'\n        systemPackage='apt'\n    elif grep -Eqi 'centos|red hat|redhat' /etc/issue; then\n        release='centos'\n        systemPackage='dnf'\n    elif grep -Eqi 'debian|raspbian' /proc/version; then\n        release='debian'\n        systemPackage='apt'\n    elif grep -Eqi 'ubuntu' /proc/version; then\n        release='ubuntu'\n        systemPackage='apt'\n    elif grep -Eqi 'centos|red hat|redhat' /proc/version; then\n        release='centos'\n        systemPackage='dnf'\n    fi\n\n    if [[ \"${checkType}\" == 'sysRelease' ]]; then\n        if [ \"${value}\" == \"${release}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    elif [[ \"${checkType}\" == 'packageManager' ]]; then\n        if [ \"${value}\" == \"${systemPackage}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    fi\n}\n\nget_ip(){\n    local IP\n    IP=$(ip addr | grep -E -o '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}' | grep -E -v '^192\\.168|^172\\.1[6-9]\\.|^172\\.2[0-9]\\.|^172\\.3[0-2]\\.|^10\\.|^127\\.|^255\\.|^0\\.' | head -n 1)\n    [ -z \"${IP}\" ] && IP=$(wget -qO- -t1 -T2 http://ipv4.icanhazip.com)\n    [ -z \"${IP}\" ] && IP=$(wget -qO- -t1 -T2 http://ipinfo.io/ip)\n    echo \"${IP}\"\n}\n\nget_ipv6(){\n    local ipv6\n    ipv6=$(wget -qO- -t1 -T2 http://ipv6.icanhazip.com)\n    [ -z \"${ipv6}\" ] && return 1\n    return 0\n}\n\nget_opsy(){\n    [ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return\n    [ -f /etc/os-release ] && awk -F'[= \"]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return\n    [ -f /etc/lsb-release ] && awk -F'[=\"]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return\n}\n\nget_char(){\n    SAVEDSTTY=$(stty -g)\n    stty -echo\n    stty cbreak\n    dd if=/dev/tty bs=1 count=1 2> /dev/null\n    stty -raw\n    stty echo\n    stty \"$SAVEDSTTY\"\n}\n\nis_valid_port() {\n    local port=\"$1\"\n    [[ \"$port\" =~ ^[0-9]+$ ]] || return 1\n    (( port >= 1 && port <= 65535 )) || return 1\n    return 0\n}\n\ninstall_check(){\n    if check_sys packageManager dnf || check_sys packageManager apt; then\n        return 0\n    else\n        return 1\n    fi\n}\n\ninstall_select(){\n    if ! install_check; then\n        echo -e \"[${red}Error${plain}] Your OS is not supported to run it!\"\n        echo 'Please change to CentOS/RHEL 8+, Debian 11+, or Ubuntu 20.04+ and try again.'\n        exit 1\n    fi\n\n    clear\n    while true\n    do\n    echo  \"Which Shadowsocks server you'd select:\"\n    for ((i=1;i<=${#software[@]};i++ )); do\n        hint=\"${software[$i-1]}\"\n        echo -e \"${green}${i}${plain}) ${hint}\"\n    done\n    read -r -p \"Please enter a number (Default ${software[0]}):\" selected\n    [ -z \"${selected}\" ] && selected='1'\n    case \"${selected}\" in\n        1|2)\n        echo\n        echo \"You choose = ${software[${selected}-1]}\"\n        echo\n        break\n        ;;\n        *)\n        echo -e \"[${red}Error${plain}] Please only enter a number [1-2]\"\n        ;;\n    esac\n    done\n}\n\ninstall_prepare_password(){\n    echo \"Please enter password for ${software[${selected}-1]}\"\n    read -r -p '(Default password: teddysun.com):' shadowsockspwd\n    [ -z \"${shadowsockspwd}\" ] && shadowsockspwd='teddysun.com'\n    echo\n    echo \"password = ${shadowsockspwd}\"\n    echo\n}\n\ninstall_prepare_port() {\n    while true\n    do\n    dport=$(shuf -i 9000-19999 -n 1)\n    echo -e \"Please enter a port for ${software[${selected}-1]} [1-65535]\"\n    read -r -p \"(Default port: ${dport}):\" shadowsocksport\n    [ -z \"${shadowsocksport}\" ] && shadowsocksport=${dport}\n    if is_valid_port \"${shadowsocksport}\"; then\n        echo\n        echo \"port = ${shadowsocksport}\"\n        echo\n        break\n    fi\n    echo -e \"[${red}Error${plain}] Please enter a correct number [1-65535]\"\n    done\n}\n\ninstall_prepare_cipher(){\n    while true\n    do\n    echo -e \"Please select stream cipher for ${software[${selected}-1]}:\"\n\n    if [ \"${selected}\" == '1' ]; then\n        for ((i=1;i<=${#common_ciphers[@]};i++ )); do\n            hint=\"${common_ciphers[$i-1]}\"\n            echo -e \"${green}${i}${plain}) ${hint}\"\n        done\n        read -r -p \"Which cipher you'd select(Default: ${common_ciphers[0]}):\" pick\n        [ -z \"${pick}\" ] && pick=1\n        if [[ \"${pick}\" =~ [^0-9] ]]; then\n            echo -e \"[${red}Error${plain}] Please enter a number\"\n            continue\n        fi\n        if [[ \"${pick}\" -lt 1 || \"${pick}\" -gt ${#common_ciphers[@]} ]]; then\n            echo -e \"[${red}Error${plain}] Please enter a number between 1 and ${#common_ciphers[@]}\"\n            continue\n        fi\n        shadowsockscipher=${common_ciphers[${pick}-1]}\n    elif [ \"${selected}\" == '2' ]; then\n        for ((i=1;i<=${#rust_ciphers[@]};i++ )); do\n            hint=\"${rust_ciphers[$i-1]}\"\n            echo -e \"${green}${i}${plain}) ${hint}\"\n        done\n        read -r -p \"Which cipher you'd select(Default: ${rust_ciphers[0]}):\" pick\n        [ -z \"${pick}\" ] && pick=1\n        if [[ \"${pick}\" =~ [^0-9] ]]; then\n            echo -e \"[${red}Error${plain}] Please enter a number\"\n            continue\n        fi\n        if [[ \"${pick}\" -lt 1 || \"${pick}\" -gt ${#rust_ciphers[@]} ]]; then\n            echo -e \"[${red}Error${plain}] Please enter a number between 1 and ${#rust_ciphers[@]}\"\n            continue\n        fi\n        shadowsockscipher=${rust_ciphers[${pick}-1]}\n    fi\n\n    echo\n    echo \"cipher = ${shadowsockscipher}\"\n    echo\n    break\n    done\n}\n\ninstall_prepare_plugin(){\n    while true\n    do\n    echo -e \"Please select SIP003 plugin for ${software[${selected}-1]}:\"\n    for ((i=1;i<=${#plugins[@]};i++ )); do\n        hint=\"${plugins[$i-1]}\"\n        echo -e \"${green}${i}${plain}) ${hint}\"\n    done\n    read -r -p \"Which plugin you'd select (Default: ${plugins[0]}):\" pick\n    [ -z \"${pick}\" ] && pick=1\n    if [[ \"${pick}\" =~ [^0-9] ]]; then\n        echo -e \"[${red}Error${plain}] Please enter a number\"\n        continue\n    fi\n    if [[ \"${pick}\" -lt 1 || \"${pick}\" -gt ${#plugins[@]} ]]; then\n        echo -e \"[${red}Error${plain}] Please enter a number between 1 and ${#plugins[@]}\"\n        continue\n    fi\n    plugin_name=${plugins[${pick}-1]}\n    echo\n    echo \"plugin = ${plugin_name}\"\n    echo\n    break\n    done\n\n    if [ \"${plugin_name}\" != \"None\" ]; then\n        install_prepare_plugin_options\n    fi\n}\n\ninstall_prepare_plugin_options(){\n    echo \"Please enter plugin options (e.g., for v2ray-plugin/xray-plugin):\"\n    echo \"Examples:\"\n    echo \"  - No TLS: server\"\n    echo \"  - With TLS: server;tls;host=yourdomain.com\"\n    echo \"  - With TLS and path: server;tls;host=yourdomain.com;path=/ws\"\n    read -r -p '(Default: server):' plugin_opts\n    [ -z \"${plugin_opts}\" ] && plugin_opts='server'\n    echo\n    echo \"plugin_opts = ${plugin_opts}\"\n    echo\n}\n\ninstall_prepare(){\n    install_prepare_password\n    install_prepare_port\n    install_prepare_cipher\n    install_prepare_plugin\n\n    echo\n    echo 'Press any key to start...or Press Ctrl+C to cancel'\n    get_char > /dev/null\n}\n\nadd_rhel_repo(){\n    echo -e \"[${green}Info${plain}] Adding Teddysun Shadowsocks Repository for RHEL...\"\n    dnf install -y yum-utils epel-release > /dev/null 2>&1\n    dnf config-manager --set-enabled epel > /dev/null 2>&1\n    dnf config-manager --add-repo ${rhel_repo_url} > /dev/null 2>&1\n    dnf config-manager --add-repo ${rhel_repo_url_2} > /dev/null 2>&1\n    if [ -f \"/etc/yum.repos.d/teddysun.repo\" ] && [ -f \"/etc/yum.repos.d/teddysun_linux.repo\" ]; then\n        echo -e \"[${green}Info${plain}] Repository added successfully.\"\n        dnf makecache > /dev/null 2>&1\n    else\n        echo -e \"[${red}Error${plain}] Failed to add repository.\"\n        exit 1\n    fi\n}\n\nadd_debian_repo(){\n    local distro codename\n    echo -e \"[${green}Info${plain}] Adding Teddysun Shadowsocks Repository for Debian/Ubuntu...\"\n    apt-get update > /dev/null 2>&1\n    apt-get -y install lsb-release ca-certificates curl gnupg > /dev/null 2>&1\n    curl -fsSL ${debian_gpg_url} | gpg --dearmor --yes -o /usr/share/keyrings/deb-gpg-key-teddysun.gpg > /dev/null 2>&1\n    chmod a+r /usr/share/keyrings/deb-gpg-key-teddysun.gpg\n    \n    distro=$(lsb_release -si | tr '[:upper:]' '[:lower:]')\n    codename=$(lsb_release -sc)\n    \n    echo \"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/deb-gpg-key-teddysun.gpg] https://dl.lamp.sh/shadowsocks/${distro}/ ${codename} main\" > /etc/apt/sources.list.d/teddysun.list\n    \n    if [ -f \"/etc/apt/sources.list.d/teddysun.list\" ]; then\n        echo -e \"[${green}Info${plain}] Repository added successfully.\"\n        apt-get update > /dev/null 2>&1\n    else\n        echo -e \"[${red}Error${plain}] Failed to add repository.\"\n        exit 1\n    fi\n}\n\ninstall_dependencies(){\n    echo -e \"[${green}Info${plain}] Checking and installing dependencies...\"\n    if check_sys packageManager dnf; then\n        dnf install -y qrencode > /dev/null 2>&1\n    elif check_sys packageManager apt; then\n        apt-get install -y qrencode > /dev/null 2>&1\n    fi\n}\n\ninstall_shadowsocks_libev(){\n    local distro codename\n    echo -e \"[${green}Info${plain}] Installing ${software[0]}...\"\n    if check_sys packageManager dnf; then\n        dnf install -y shadowsocks-libev > /dev/null 2>&1\n    elif check_sys packageManager apt; then\n        distro=$(lsb_release -si | tr '[:upper:]' '[:lower:]')\n        codename=$(lsb_release -sc)\n        if [ \"${distro}\" == \"debian\" ]; then\n            apt-get install -y \"shadowsocks-libev=3.3.6-2~debian.$(lsb_release -sr | cut -d. -f1)~${codename}\" > /dev/null 2>&1\n        else\n            apt-get install -y \"shadowsocks-libev=3.3.6-2~ubuntu.$(lsb_release -sr | cut -d. -f1)~${codename}\" > /dev/null 2>&1\n        fi\n    fi\n    \n    if [ ! -f \"/usr/bin/ss-server\" ]; then\n        echo -e \"[${red}Error${plain}] ${software[0]} installation failed.\"\n        exit 1\n    fi\n}\n\ninstall_shadowsocks_rust(){\n    echo -e \"[${green}Info${plain}] Installing ${software[1]}...\"\n    if check_sys packageManager dnf; then\n        dnf install -y shadowsocks-rust > /dev/null 2>&1\n    elif check_sys packageManager apt; then\n        apt-get install -y shadowsocks-rust > /dev/null 2>&1\n    fi\n    \n    if [ ! -f \"/usr/bin/ssservice\" ]; then\n        echo -e \"[${red}Error${plain}] ${software[1]} installation failed.\"\n        exit 1\n    fi\n}\n\ninstall_plugin(){\n    if [ \"${plugin_name}\" == \"None\" ]; then\n        return 0\n    fi\n    \n    echo -e \"[${green}Info${plain}] Installing ${plugin_name}...\"\n    if check_sys packageManager dnf; then\n        dnf install -y \"${plugin_name}\" > /dev/null 2>&1\n    elif check_sys packageManager apt; then\n        apt-get install -y \"${plugin_name}\" > /dev/null 2>&1\n    fi\n    RT=$?\n    if [ ${RT} -ne 0 ]; then\n        echo -e \"[${red}Error${plain}] ${plugin_name} installation failed.\"\n        exit 1\n    fi\n}\n\nconfig_shadowsocks_libev(){\n    local server_value=\"\\\"0.0.0.0\\\"\"\n    if get_ipv6; then\n        server_value=\"[\\\"[::0]\\\",\\\"0.0.0.0\\\"]\"\n    fi\n\n    mkdir -p \"$(dirname ${shadowsocks_libev_config})\"\n    \n    if [ \"${plugin_name}\" != \"None\" ]; then\n        cat > ${shadowsocks_libev_config}<<-EOF\n{\n    \"server\":${server_value},\n    \"server_port\":${shadowsocksport},\n    \"password\":\"${shadowsockspwd}\",\n    \"timeout\":300,\n    \"method\":\"${shadowsockscipher}\",\n    \"fast_open\":false,\n    \"nameserver\":\"8.8.8.8\",\n    \"mode\":\"tcp_and_udp\",\n    \"plugin\":\"${plugin_name}\",\n    \"plugin_opts\":\"${plugin_opts}\"\n}\nEOF\n    else\n        cat > ${shadowsocks_libev_config}<<-EOF\n{\n    \"server\":${server_value},\n    \"server_port\":${shadowsocksport},\n    \"password\":\"${shadowsockspwd}\",\n    \"timeout\":300,\n    \"method\":\"${shadowsockscipher}\",\n    \"fast_open\":false,\n    \"nameserver\":\"8.8.8.8\",\n    \"mode\":\"tcp_and_udp\"\n}\nEOF\n    fi\n}\n\nconfig_shadowsocks_rust(){\n    local server_value=\"\\\"0.0.0.0\\\"\"\n    if get_ipv6; then\n        server_value=\"[\\\"[::0]\\\",\\\"0.0.0.0\\\"]\"\n    fi\n\n    mkdir -p \"$(dirname ${shadowsocks_rust_config})\"\n    \n    if [ \"${plugin_name}\" != \"None\" ]; then\n        cat > ${shadowsocks_rust_config}<<-EOF\n{\n    \"server\":${server_value},\n    \"server_port\":${shadowsocksport},\n    \"password\":\"${shadowsockspwd}\",\n    \"timeout\":300,\n    \"method\":\"${shadowsockscipher}\",\n    \"fast_open\":false,\n    \"mode\":\"tcp_and_udp\",\n    \"plugin\":\"${plugin_name}\",\n    \"plugin_opts\":\"${plugin_opts}\"\n}\nEOF\n    else\n        cat > ${shadowsocks_rust_config}<<-EOF\n{\n    \"server\":${server_value},\n    \"server_port\":${shadowsocksport},\n    \"password\":\"${shadowsockspwd}\",\n    \"timeout\":300,\n    \"method\":\"${shadowsockscipher}\",\n    \"fast_open\":false,\n    \"mode\":\"tcp_and_udp\"\n}\nEOF\n    fi\n}\n\nconfig_firewall(){\n    if check_sys packageManager dnf; then\n        if systemctl status firewalld > /dev/null 2>&1; then\n            default_zone=$(firewall-cmd --get-default-zone)\n            firewall-cmd --permanent --zone=\"${default_zone}\" --add-port=\"${shadowsocksport}\"/tcp > /dev/null 2>&1\n            firewall-cmd --permanent --zone=\"${default_zone}\" --add-port=\"${shadowsocksport}\"/udp > /dev/null 2>&1\n            firewall-cmd --reload > /dev/null 2>&1\n            echo -e \"[${green}Info${plain}] Firewall port ${shadowsocksport} opened.\"\n        else\n            echo -e \"[${yellow}Warning${plain}] firewalld is not running, please open port ${shadowsocksport} manually if necessary.\"\n        fi\n    fi\n    if check_sys packageManager apt; then\n        if ufw status &>/dev/null; then\n            ufw allow \"${shadowsocksport}\"/tcp\n            ufw allow \"${shadowsocksport}\"/udp\n        else\n            echo -e \"[${yellow}Warning${plain}] ufw is not running, please open port ${shadowsocksport} manually if necessary.\"\n        fi\n    fi\n}\n\nstart_shadowsocks_libev(){\n    systemctl daemon-reload\n    systemctl start shadowsocks-libev-server\n    systemctl enable shadowsocks-libev-server > /dev/null 2>&1\n}\n\nstart_shadowsocks_rust(){\n    systemctl daemon-reload\n    systemctl start shadowsocks-rust-server\n    systemctl enable shadowsocks-rust-server > /dev/null 2>&1\n}\n\ninstall_completed_libev(){\n    clear\n    echo\n    echo -e \"Congratulations, ${green}${software[0]}${plain} server install completed!\"\n    echo -e \"Your Server IP        : ${red} $(get_ip) ${plain}\"\n    echo -e \"Your Server Port      : ${red} ${shadowsocksport} ${plain}\"\n    echo -e \"Your Password         : ${red} ${shadowsockspwd} ${plain}\"\n    echo -e \"Your Encryption Method: ${red} ${shadowsockscipher} ${plain}\"\n    if [ \"${plugin_name}\" != \"None\" ]; then\n        echo -e \"Your Plugin           : ${red} ${plugin_name} ${plain}\"\n        echo -e \"Your Plugin Options   : ${red} ${plugin_opts} ${plain}\"\n    fi\n}\n\ninstall_completed_rust(){\n    clear\n    echo\n    echo -e \"Congratulations, ${green}${software[1]}${plain} server install completed!\"\n    echo -e \"Your Server IP        : ${red} $(get_ip) ${plain}\"\n    echo -e \"Your Server Port      : ${red} ${shadowsocksport} ${plain}\"\n    echo -e \"Your Password         : ${red} ${shadowsockspwd} ${plain}\"\n    echo -e \"Your Encryption Method: ${red} ${shadowsockscipher} ${plain}\"\n    if [ \"${plugin_name}\" != \"None\" ]; then\n        echo -e \"Your Plugin           : ${red} ${plugin_name} ${plain}\"\n        echo -e \"Your Plugin Options   : ${red} ${plugin_opts} ${plain}\"\n    fi\n}\n\nqr_generate_libev(){\n    if [ \"$(command -v qrencode)\" ]; then\n        local tmp qr_code plugin_encoded\n        if [ \"${plugin_name}\" != \"None\" ]; then\n            # SIP003 URL format with plugin\n            tmp=$(echo -n \"${shadowsockscipher}:${shadowsockspwd}\" | base64 -w0 | sed 's/=//g')\n            plugin_encoded=$(echo -n \"${plugin_name};${plugin_opts}\" | base64 -w0 | sed 's/=//g')\n            qr_code=\"ss://${tmp}@$(get_ip):${shadowsocksport}/?plugin=${plugin_encoded}\"\n        else\n            tmp=$(echo -n \"${shadowsockscipher}:${shadowsockspwd}@$(get_ip):${shadowsocksport}\" | base64 -w0)\n            qr_code=\"ss://${tmp}\"\n        fi\n        echo\n        echo 'Your QR Code: (For Shadowsocks Windows, OSX, Android and iOS clients)'\n        echo -e \"${green} ${qr_code} ${plain}\"\n        echo -n \"${qr_code}\" | qrencode -s8 -o \"${cur_dir}\"/shadowsocks_libev_qr.png\n        echo 'Your QR Code has been saved as a PNG file path:'\n        echo -e \"${green} ${cur_dir}/shadowsocks_libev_qr.png ${plain}\"\n    fi\n}\n\nqr_generate_rust(){\n    if [ \"$(command -v qrencode)\" ]; then\n        local tmp qr_code plugin_encoded\n        if [ \"${plugin_name}\" != \"None\" ]; then\n            # SIP003 URL format with plugin\n            tmp=$(echo -n \"${shadowsockscipher}:${shadowsockspwd}\" | base64 -w0 | sed 's/=//g')\n            plugin_encoded=$(echo -n \"${plugin_name};${plugin_opts}\" | base64 -w0 | sed 's/=//g')\n            qr_code=\"ss://${tmp}@$(get_ip):${shadowsocksport}/?plugin=${plugin_encoded}\"\n        else\n            tmp=$(echo -n \"${shadowsockscipher}:${shadowsockspwd}@$(get_ip):${shadowsocksport}\" | base64 -w0)\n            qr_code=\"ss://${tmp}\"\n        fi\n        echo\n        echo 'Your QR Code: (For Shadowsocks Windows, OSX, Android and iOS clients)'\n        echo -e \"${green} ${qr_code} ${plain}\"\n        echo -n \"${qr_code}\" | qrencode -s8 -o \"${cur_dir}\"/shadowsocks_rust_qr.png\n        echo 'Your QR Code has been saved as a PNG file path:'\n        echo -e \"${green} ${cur_dir}/shadowsocks_rust_qr.png ${plain}\"\n    fi\n}\n\ninstall_main(){\n    if   [ \"${selected}\" == '1' ]; then\n        install_shadowsocks_libev\n        install_plugin\n        config_shadowsocks_libev\n        start_shadowsocks_libev\n        install_completed_libev\n        qr_generate_libev\n    elif [ \"${selected}\" == '2' ]; then\n        install_shadowsocks_rust\n        install_plugin\n        config_shadowsocks_rust\n        start_shadowsocks_rust\n        install_completed_rust\n        qr_generate_rust\n    fi\n\n    echo\n    echo 'Welcome to visit: https://teddysun.com/486.html'\n    echo 'Enjoy it!'\n    echo\n}\n\ninstall_shadowsocks(){\n    disable_selinux\n    install_select\n    install_prepare\n    \n    if check_sys packageManager dnf; then\n        add_rhel_repo\n    elif check_sys packageManager apt; then\n        add_debian_repo\n    fi\n    \n    install_dependencies\n    config_firewall\n    install_main\n}\n\nuninstall_shadowsocks_libev(){\n    echo -e \"Are you sure uninstall ${red}${software[0]}${plain}? [y/n]\"\n    read -r -p '(default: n):' answer\n    [ -z \"${answer}\" ] && answer='n'\n    if [ \"${answer}\" == 'y' ] || [ \"${answer}\" == 'Y' ]; then\n        systemctl stop shadowsocks-libev-server > /dev/null 2>&1\n        systemctl disable shadowsocks-libev-server > /dev/null 2>&1\n        if check_sys packageManager dnf; then\n            dnf remove -y shadowsocks-libev v2ray-plugin xray-plugin > /dev/null 2>&1\n        elif check_sys packageManager apt; then\n            apt-get remove -y shadowsocks-libev v2ray-plugin xray-plugin > /dev/null 2>&1\n        fi\n        rm -f ${shadowsocks_libev_config}\n        echo -e \"[${green}Info${plain}] ${software[0]} uninstall success\"\n    else\n        echo\n        echo -e \"[${green}Info${plain}] ${software[0]} uninstall cancelled, nothing to do...\"\n        echo\n    fi\n}\n\nuninstall_shadowsocks_rust(){\n    echo -e \"Are you sure uninstall ${red}${software[1]}${plain}? [y/n]\"\n    read -r -p '(default: n):' answer\n    [ -z \"${answer}\" ] && answer='n'\n    if [ \"${answer}\" == 'y' ] || [ \"${answer}\" == 'Y' ]; then\n        systemctl stop shadowsocks-rust-server > /dev/null 2>&1\n        systemctl disable shadowsocks-rust-server > /dev/null 2>&1\n        if check_sys packageManager dnf; then\n            dnf remove -y shadowsocks-rust v2ray-plugin xray-plugin > /dev/null 2>&1\n        elif check_sys packageManager apt; then\n            apt-get remove -y shadowsocks-rust v2ray-plugin xray-plugin > /dev/null 2>&1\n        fi\n        rm -f ${shadowsocks_rust_config}\n        echo -e \"[${green}Info${plain}] ${software[1]} uninstall success\"\n    else\n        echo\n        echo -e \"[${green}Info${plain}] ${software[1]} uninstall cancelled, nothing to do...\"\n        echo\n    fi\n}\n\nuninstall_shadowsocks(){\n    while true\n    do\n    echo 'Which Shadowsocks server you want to uninstall?'\n    for ((i=1;i<=${#software[@]};i++ )); do\n        hint=\"${software[$i-1]}\"\n        echo -e \"${green}${i}${plain}) ${hint}\"\n    done\n    read -r -p 'Please enter a number [1-2]:' un_select\n    case \"${un_select}\" in\n        1|2)\n        echo\n        echo \"You choose = ${software[${un_select}-1]}\"\n        echo\n        break\n        ;;\n        *)\n        echo -e \"[${red}Error${plain}] Please only enter a number [1-2]\"\n        ;;\n    esac\n    done\n\n    if   [ \"${un_select}\" == '1' ]; then\n        uninstall_shadowsocks_libev\n    elif [ \"${un_select}\" == '2' ]; then\n        uninstall_shadowsocks_rust\n    fi\n}\n\n# Initialization step\naction=$1\n[ -z \"$1\" ] && action=install\ncase \"${action}\" in\n    install)\n        install_shadowsocks\n        ;;\n    uninstall)\n        uninstall_shadowsocks\n        ;;\n    *)\n        echo \"Arguments error! [${action}]\"\n        echo \"Usage: $(basename \"$0\") [install|uninstall]\"\n        ;;\nesac\n"
  },
  {
    "path": "shadowsocks-crond.sh",
    "content": "#!/usr/bin/env bash\n#=================================================================#\n#   System Required:  CentOS, Debian, Ubuntu                      #\n#   Description: Check Shadowsocks Server is running or not       #\n#   Author: Teddysun <i@teddysun.com>                             #\n#   Visit: https://shadowsocks.be/6.html                          #\n#=================================================================#\n\nname=(Shadowsocks Shadowsocks-Python ShadowsocksR Shadowsocks-Go Shadowsocks-libev)\npath=/var/log\n[[ ! -d ${path} ]] && mkdir -p ${path}\nlog=${path}/shadowsocks-crond.log\n\nshadowsocks_init[0]=/etc/init.d/shadowsocks\nshadowsocks_init[1]=/etc/init.d/shadowsocks-python\nshadowsocks_init[2]=/etc/init.d/shadowsocks-r\nshadowsocks_init[3]=/etc/init.d/shadowsocks-go\nshadowsocks_init[4]=/etc/init.d/shadowsocks-libev\n\ni=0\nfor init in \"${shadowsocks_init[@]}\"; do\n    pid=\"\"\n    if [ -f ${init} ]; then\n        ss_status=$(${init} status)\n        if [ $? -eq 0 ]; then\n            pid=$(echo \"$ss_status\" | sed -e 's/[^0-9]*//g')\n        fi\n\n        if [ -z \"${pid}\" ]; then\n            echo \"$(date +'%Y-%m-%d %H:%M:%S') ${name[$i]} is not running\" >> ${log}\n            echo \"$(date +'%Y-%m-%d %H:%M:%S') Starting ${name[$i]}\" >> ${log}\n            ${init} start &>/dev/null\n            if [ $? -eq 0 ]; then\n                echo \"$(date +'%Y-%m-%d %H:%M:%S') ${name[$i]} start success\" >> ${log}\n            else\n                echo \"$(date +'%Y-%m-%d %H:%M:%S') ${name[$i]} start failed\" >> ${log}\n            fi\n        else\n            echo \"$(date +'%Y-%m-%d %H:%M:%S') ${name[$i]} is running with pid $pid\" >> ${log}\n        fi\n    \n    fi\n    ((i++))\ndone\n"
  },
  {
    "path": "shadowsocks-debian",
    "content": "#!/bin/bash\n\n### BEGIN INIT INFO\n# Provides:          Shadowsocks\n# Required-Start:    $network $local_fs $remote_fs\n# Required-Stop:     $network $local_fs $remote_fs\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: Fast tunnel proxy that helps you bypass firewalls\n# Description:       Start or stop the Shadowsocks server\n### END INIT INFO\n\n# Author: Teddysun <i@teddysun.com>\n\nNAME=Shadowsocks\nif [ -f /usr/bin/ssserver ]; then\n    DAEMON=/usr/bin/ssserver\nelif [ -f /usr/local/bin/ssserver ]; then\n    DAEMON=/usr/local/bin/ssserver\nfi\nif [ -f /etc/shadowsocks-python/config.json ]; then\n    CONF=/etc/shadowsocks-python/config.json\nelif [ -f /etc/shadowsocks.json ]; then\n    CONF=/etc/shadowsocks.json\nfi\nRETVAL=0\n\ncheck_running(){\n    PID=$(ps -ef | grep -v grep | grep -i \"${DAEMON}\" | awk '{print $2}')\n    if [ -n \"$PID\" ]; then\n        return 0\n    else\n        return 1\n    fi\n}\n\ndo_start(){\n    check_running\n    if [ $? -eq 0 ]; then\n        echo \"$NAME (pid $PID) is already running...\"\n        exit 0\n    else\n        $DAEMON -c $CONF -d start\n        RETVAL=$?\n        if [ $RETVAL -eq 0 ]; then\n            echo \"Starting $NAME success\"\n        else\n            echo \"Starting $NAME failed\"\n        fi\n    fi\n}\n\ndo_stop(){\n    check_running\n    if [ $? -eq 0 ]; then\n        $DAEMON -c $CONF -d stop\n        RETVAL=$?\n        if [ $RETVAL -eq 0 ]; then\n            echo \"Stopping $NAME success\"\n        else\n            echo \"Stopping $NAME failed\"\n        fi\n    else\n        echo \"$NAME is stopped\"\n        RETVAL=1\n    fi\n}\n\ndo_status(){\n    check_running\n    if [ $? -eq 0 ]; then\n        echo \"$NAME (pid $PID) is running...\"\n    else\n        echo \"$NAME is stopped\"\n        RETVAL=1\n    fi\n}\n\ndo_restart(){\n    do_stop\n    sleep 0.5\n    do_start\n}\n\ncase \"$1\" in\n    start|stop|restart|status)\n    do_$1\n    ;;\n    *)\n    echo \"Usage: $0 { start | stop | restart | status }\"\n    RETVAL=1\n    ;;\nesac\n\nexit $RETVAL\n"
  },
  {
    "path": "shadowsocks-go",
    "content": "#!/bin/bash\n# chkconfig: 2345 90 10\n# description: A secure socks5 proxy, designed to protect your Internet traffic.\n\n### BEGIN INIT INFO\n# Provides:          Shadowsocks-go\n# Required-Start:    $network $syslog\n# Required-Stop:     $network\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: Fast tunnel proxy that helps you bypass firewalls\n# Description:       Start or stop the Shadowsocks-go server\n### END INIT INFO\n\n# Author: Teddysun <i@teddysun.com>\n\n# Source function library\n. /etc/rc.d/init.d/functions\n\n# Check that networking is up.\n[ ${NETWORKING} =\"yes\" ] || exit 0\n\nNAME=Shadowsocks-go\nDAEMON=/usr/bin/shadowsocks-server\nif [ -f /etc/shadowsocks-go/config.json ]; then\n    CONF=/etc/shadowsocks-go/config.json\nelif [ -f /etc/shadowsocks/config.json ]; then\n    CONF=/etc/shadowsocks/config.json\nfi\nPID_DIR=/var/run\nPID_FILE=$PID_DIR/shadowsocks-go.pid\nRET_VAL=0\n\n[ -x $DAEMON ] || exit 0\n\nif [ ! -d $PID_DIR ]; then\n    mkdir -p $PID_DIR\n    if [ $? -ne 0 ]; then\n        echo \"Creating PID directory $PID_DIR failed\"\n        exit 1\n    fi\nfi\n\nif [ ! -f $CONF ]; then\n    echo \"$NAME config file $CONF not found\"\n    exit 1\nfi\n\ncheck_running() {\n    if [ -r $PID_FILE ]; then\n        read PID < $PID_FILE\n        if [ -d \"/proc/$PID\" ]; then\n            return 0\n        else\n            rm -f $PID_FILE\n            return 1\n        fi\n    else\n        return 2\n    fi\n}\n\ndo_status() {\n    check_running\n    case $? in\n        0)\n        echo \"$NAME (pid $PID) is running...\"\n        ;;\n        1|2)\n        echo \"$NAME is stopped\"\n        RET_VAL=1\n        ;;\n    esac\n}\n\ndo_start() {\n    if check_running; then\n        echo \"$NAME (pid $PID) is already running...\"\n        return 0\n    fi\n    $DAEMON -u -c $CONF 2>&1 > /dev/null &\n    PID=$!\n    echo $PID > $PID_FILE\n    sleep 0.3\n    if check_running; then\n        echo \"Starting $NAME success\"\n    else\n        echo \"Starting $NAME failed\"\n        RET_VAL=1\n    fi\n}\n\ndo_stop() {\n    if check_running; then\n        kill -9 $PID\n        rm -f $PID_FILE\n        echo \"Stopping $NAME success\"\n    else\n        echo \"$NAME is stopped\"\n        RET_VAL=1\n    fi\n}\n\ndo_restart() {\n    do_stop\n    sleep 0.5\n    do_start\n}\n\ncase \"$1\" in\n    start|stop|restart|status)\n    do_$1\n    ;;\n    *)\n    echo \"Usage: $0 { start | stop | restart | status }\"\n    RET_VAL=1\n    ;;\nesac\n\nexit $RET_VAL\n"
  },
  {
    "path": "shadowsocks-go-debian",
    "content": "#!/bin/bash\n\n### BEGIN INIT INFO\n# Provides:          Shadowsocks-go\n# Required-Start:    $network $local_fs $remote_fs\n# Required-Stop:     $network $local_fs $remote_fs\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: Fast tunnel proxy that helps you bypass firewalls\n# Description:       Start or stop the Shadowsocks-go server\n### END INIT INFO\n\n# Author: Teddysun <i@teddysun.com>\n\nNAME=Shadowsocks-go\nDAEMON=/usr/bin/shadowsocks-server\nif [ -f /etc/shadowsocks-go/config.json ]; then\n    CONF=/etc/shadowsocks-go/config.json\nelif [ -f /etc/shadowsocks/config.json ]; then\n    CONF=/etc/shadowsocks/config.json\nfi\nPID_DIR=/var/run\nPID_FILE=$PID_DIR/shadowsocks-go.pid\nRET_VAL=0\n\n[ -x $DAEMON ] || exit 0\n\nif [ ! -d $PID_DIR ]; then\n    mkdir -p $PID_DIR\n    if [ $? -ne 0 ]; then\n        echo \"Creating PID directory $PID_DIR failed\"\n        exit 1\n    fi\nfi\n\nif [ ! -f $CONF ]; then\n    echo \"$NAME config file $CONF not found\"\n    exit 1\nfi\n\ncheck_running() {\n    if [ -r $PID_FILE ]; then\n        read PID < $PID_FILE\n        if [ -d \"/proc/$PID\" ]; then\n            return 0\n        else\n            rm -f $PID_FILE\n            return 1\n        fi\n    else\n        return 2\n    fi\n}\n\ndo_status() {\n    check_running\n    case $? in\n        0)\n        echo \"$NAME (pid $PID) is running...\"\n        ;;\n        1|2)\n        echo \"$NAME is stopped\"\n        RET_VAL=1\n        ;;\n    esac\n}\n\ndo_start() {\n    if check_running; then\n        echo \"$NAME (pid $PID) is already running...\"\n        return 0\n    fi\n    $DAEMON -u -c $CONF 2>&1 > /dev/null &\n    PID=$!\n    echo $PID > $PID_FILE\n    sleep 0.3\n    if check_running; then\n        echo \"Starting $NAME success\"\n    else\n        echo \"Starting $NAME failed\"\n        RET_VAL=1\n    fi\n}\n\ndo_stop() {\n    if check_running; then\n        kill -9 $PID\n        rm -f $PID_FILE\n        echo \"Stopping $NAME success\"\n    else\n        echo \"$NAME is stopped\"\n        RET_VAL=1\n    fi\n}\n\ndo_restart() {\n    do_stop\n    sleep 0.5\n    do_start\n}\n\ncase \"$1\" in\n    start|stop|restart|status)\n    do_$1\n    ;;\n    *)\n    echo \"Usage: $0 { start | stop | restart | status }\"\n    RET_VAL=1\n    ;;\nesac\n\nexit $RET_VAL\n"
  },
  {
    "path": "shadowsocks-go.sh",
    "content": "#!/usr/bin/env bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\nexport PATH\n#=================================================================#\n#   System Required:  CentOS, Debian, Ubuntu                      #\n#   Description: One click Install Shadowsocks-go server          #\n#   Author: Teddysun <i@teddysun.com>                             #\n#   Thanks: @cyfdecyf <https://twitter.com/cyfdecyf>              #\n#   Intro:  https://teddysun.com/392.html                         #\n#==================================================================\n\nclear\necho\necho \"#############################################################\"\necho \"# One click Install Shadowsocks-go server                   #\"\necho \"# Intro: https://teddysun.com/392.html                      #\"\necho \"# Author: Teddysun <i@teddysun.com>                         #\"\necho \"# Github: https://github.com/shadowsocks/shadowsocks-go     #\"\necho \"#############################################################\"\necho\n\n# Current folder\ncur_dir=`pwd`\n# Stream Ciphers\nciphers=(\naes-256-cfb\naes-192-cfb\naes-128-cfb\naes-256-ctr\naes-192-ctr\naes-128-ctr\nchacha20-ietf\nchacha20\nsalsa20\nrc4-md5\n)\n# Color\nred='\\033[0;31m'\ngreen='\\033[0;32m'\nyellow='\\033[0;33m'\nplain='\\033[0m'\n\n# Make sure only root can run our script\n[[ $EUID -ne 0 ]] && echo -e \"[${red}Error${plain}] This script must be run as root!\" && exit 1\n\n#Check system\ncheck_sys(){\n    local checkType=$1\n    local value=$2\n\n    local release=''\n    local systemPackage=''\n\n    if [[ -f /etc/redhat-release ]]; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    elif grep -Eqi \"debian\" /etc/issue; then\n        release=\"debian\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"ubuntu\" /etc/issue; then\n        release=\"ubuntu\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"centos|red hat|redhat\" /etc/issue; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    elif grep -Eqi \"debian|raspbian\" /proc/version; then\n        release=\"debian\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"ubuntu\" /proc/version; then\n        release=\"ubuntu\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"centos|red hat|redhat\" /proc/version; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    fi\n\n    if [[ \"${checkType}\" == \"sysRelease\" ]]; then\n        if [ \"${value}\" == \"${release}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    elif [[ \"${checkType}\" == \"packageManager\" ]]; then\n        if [ \"${value}\" == \"${systemPackage}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    fi\n}\n\n# Get version\ngetversion(){\n    if [[ -s /etc/redhat-release ]]; then\n        grep -oE  \"[0-9.]+\" /etc/redhat-release\n    else\n        grep -oE  \"[0-9.]+\" /etc/issue\n    fi\n}\n\n# CentOS version\ncentosversion(){\n    if check_sys sysRelease centos; then\n        local code=$1\n        local version=\"$(getversion)\"\n        local main_ver=${version%%.*}\n        if [ \"$main_ver\" == \"$code\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    else\n        return 1\n    fi\n}\n\n# is 64bit or not\nis_64bit(){\n    if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then\n        return 0\n    else\n        return 1\n    fi\n}\n\n# Disable selinux\ndisable_selinux(){\n    if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then\n        sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config\n        setenforce 0\n    fi\n}\n\nget_ip(){\n    local IP=$( ip addr | egrep -o '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}' | egrep -v \"^192\\.168|^172\\.1[6-9]\\.|^172\\.2[0-9]\\.|^172\\.3[0-2]\\.|^10\\.|^127\\.|^255\\.|^0\\.\" | head -n 1 )\n    [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )\n    [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip )\n    [ ! -z ${IP} ] && echo ${IP} || echo\n}\n\nget_char(){\n    SAVEDSTTY=`stty -g`\n    stty -echo\n    stty cbreak\n    dd if=/dev/tty bs=1 count=1 2> /dev/null\n    stty -raw\n    stty echo\n    stty $SAVEDSTTY\n}\n\n# Pre-installation settings\npre_install(){\n    if ! check_sys packageManager yum && ! check_sys packageManager apt; then\n        echo -e \"$[{red}Error${plain}] Your OS is not supported. please change OS to CentOS/Debian/Ubuntu and try again.\"\n        exit 1\n    fi\n    # Set shadowsocks-go config password\n    echo \"Please enter password for shadowsocks-go:\"\n    read -p \"(Default password: teddysun.com):\" shadowsockspwd\n    [ -z \"${shadowsockspwd}\" ] && shadowsockspwd=\"teddysun.com\"\n    echo\n    echo \"---------------------------\"\n    echo \"password = ${shadowsockspwd}\"\n    echo \"---------------------------\"\n    echo\n    # Set shadowsocks-go config port\n    while true\n    do\n    dport=$(shuf -i 9000-19999 -n 1)\n    echo -e \"Please enter a port for shadowsocks-go [1-65535]\"\n    read -p \"(Default port: ${dport}):\" shadowsocksport\n    [ -z \"${shadowsocksport}\" ] && shadowsocksport=${dport}\n    expr ${shadowsocksport} + 1 &>/dev/null\n    if [ $? -eq 0 ]; then\n        if [ ${shadowsocksport} -ge 1 ] && [ ${shadowsocksport} -le 65535 ] && [ ${shadowsocksport:0:1} != 0 ]; then\n            echo\n            echo \"---------------------------\"\n            echo \"port = ${shadowsocksport}\"\n            echo \"---------------------------\"\n            echo\n            break\n        fi\n    fi\n    echo -e \"[${red}Error${plain}] Please enter a correct number [1-65535]\"\n    done\n\n    # Set shadowsocks config stream ciphers\n    while true\n    do\n    echo -e \"Please select stream cipher for shadowsocks-go:\"\n    for ((i=1;i<=${#ciphers[@]};i++ )); do\n        hint=\"${ciphers[$i-1]}\"\n        echo -e \"${green}${i}${plain}) ${hint}\"\n    done\n    read -p \"Which cipher you'd select(Default: ${ciphers[0]}):\" pick\n    [ -z \"$pick\" ] && pick=1\n    expr ${pick} + 1 &>/dev/null\n    if [ $? -ne 0 ]; then\n        echo -e \"[${red}Error${plain}] Please enter a number\"\n        continue\n    fi\n    if [[ \"$pick\" -lt 1 || \"$pick\" -gt ${#ciphers[@]} ]]; then\n        echo -e \"[${red}Error${plain}] Please enter a number between 1 and ${#ciphers[@]}\"\n        continue\n    fi\n    shadowsockscipher=${ciphers[$pick-1]}\n    echo\n    echo \"---------------------------\"\n    echo \"cipher = ${shadowsockscipher}\"\n    echo \"---------------------------\"\n    echo\n    break\n    done\n\n    echo\n    echo \"Press any key to start...or Press Ctrl+C to cancel\"\n    char=`get_char`\n    #Install necessary dependencies\n    if check_sys packageManager yum; then\n        yum install -y wget unzip gzip curl nss\n    elif check_sys packageManager apt; then\n        apt-get -y update\n        apt-get install -y wget unzip gzip curl libnss3\n    fi\n    echo\n\n}\n\n# Download shadowsocks-go\ndownload_files(){\n    cd ${cur_dir}\n    if is_64bit; then\n        if ! wget --no-check-certificate -c https://dl.lamp.sh/shadowsocks/shadowsocks-server-linux64-1.2.2.gz; then\n            echo -e \"[${red}Error${plain}] Failed to download shadowsocks-server-linux64-1.2.2.gz\"\n            exit 1\n        fi\n        gzip -d shadowsocks-server-linux64-1.2.2.gz\n        if [ $? -ne 0 ]; then\n            echo -e \"[${red}Error${plain}] Decompress shadowsocks-server-linux64-1.2.2.gz failed\"\n            exit 1\n        fi\n        mv -f shadowsocks-server-linux64-1.2.2 /usr/bin/shadowsocks-server\n    else\n        if ! wget --no-check-certificate -c https://dl.lamp.sh/shadowsocks/shadowsocks-server-linux32-1.2.2.gz; then\n            echo -e \"[${red}Error${plain}] Failed to download shadowsocks-server-linux32-1.2.2.gz\"\n            exit 1\n        fi\n        gzip -d shadowsocks-server-linux32-1.2.2.gz\n        if [ $? -ne 0 ]; then\n            echo -e \"[${red}Error${plain}] Decompress shadowsocks-server-linux32-1.2.2.gz failed\"\n            exit 1\n        fi\n        mv -f shadowsocks-server-linux32-1.2.2 /usr/bin/shadowsocks-server\n    fi\n\n    # Download start script\n    if check_sys packageManager yum; then\n        if ! wget --no-check-certificate -O /etc/init.d/shadowsocks https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-go; then\n            echo -e \"[${red}Error${plain}] Failed to download shadowsocks-go auto start script!\"\n            exit 1\n        fi\n    elif check_sys packageManager apt; then\n        if ! wget --no-check-certificate -O /etc/init.d/shadowsocks https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-go-debian; then\n            echo -e \"[${red}Error${plain}] Failed to download shadowsocks-go auto start script!\"\n            exit 1\n        fi\n    fi\n}\n\n# Config shadowsocks\nconfig_shadowsocks(){\n    if [ ! -d /etc/shadowsocks ]; then\n        mkdir -p /etc/shadowsocks\n    fi\n    cat > /etc/shadowsocks/config.json<<-EOF\n{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":${shadowsocksport},\n    \"local_port\":1080,\n    \"password\":\"${shadowsockspwd}\",\n    \"method\":\"${shadowsockscipher}\",\n    \"timeout\":300\n}\nEOF\n}\n\n# Firewall set\nfirewall_set(){\n    echo -e \"[${green}Info${plain}] firewall set start...\"\n    if centosversion 6; then\n        /etc/init.d/iptables status > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            iptables -L -n | grep -i ${shadowsocksport} > /dev/null 2>&1\n            if [ $? -ne 0 ]; then\n                iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${shadowsocksport} -j ACCEPT\n                iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${shadowsocksport} -j ACCEPT\n                /etc/init.d/iptables save\n                /etc/init.d/iptables restart\n            else\n                echo -e \"[${green}Info${plain}] port ${shadowsocksport} has been set up.\"\n            fi\n        else\n            echo -e \"[${yellow}Warning${plain}] iptables looks like shutdown or not installed, please manually set it if necessary.\"\n        fi\n    elif centosversion 7; then\n        systemctl status firewalld > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            default_zone=$(firewall-cmd --get-default-zone)\n            firewall-cmd --permanent --zone=${default_zone} --add-port=${shadowsocksport}/tcp\n            firewall-cmd --permanent --zone=${default_zone} --add-port=${shadowsocksport}/udp\n            firewall-cmd --reload\n        else\n            echo -e \"[${yellow}Warning${plain}] firewalld looks like not running or not installed, please enable port ${shadowsocksport} manually if necessary.\"\n        fi\n    fi\n    echo -e \"[${green}Info${plain}] firewall set completed...\"\n}\n\n# Install Shadowsocks-go\ninstall(){\n\n    if [ -f /usr/bin/shadowsocks-server ]; then\n        echo \"Shadowsocks-go server install success!\"\n        chmod +x /usr/bin/shadowsocks-server\n        chmod +x /etc/init.d/shadowsocks\n\n        if check_sys packageManager yum; then\n            chkconfig --add shadowsocks\n            chkconfig shadowsocks on\n        elif check_sys packageManager apt; then\n            update-rc.d -f shadowsocks defaults\n        fi\n\n        /etc/init.d/shadowsocks start\n        if [ $? -ne 0 ]; then\n            echo -e \"[${red}Error${plain}] Shadowsocks-go server start failed!\"\n        fi\n    else\n        echo\n        echo -e \"[${red}Error${plain}] Shadowsocks-go server install failed!\"\n        exit 1\n    fi\n\n    clear\n    echo\n    echo -e \"Congratulations, Shadowsocks-go server install completed!\"\n    echo -e \"Your Server IP        : \\033[41;37m $(get_ip) \\033[0m\"\n    echo -e \"Your Server Port      : \\033[41;37m ${shadowsocksport} \\033[0m\"\n    echo -e \"Your Password         : \\033[41;37m ${shadowsockspwd} \\033[0m\"\n    echo -e \"Your Encryption Method: \\033[41;37m ${shadowsockscipher} \\033[0m\"\n    echo\n    echo \"Welcome to visit:https://teddysun.com/392.html\"\n    echo \"Enjoy it!\"\n    echo\n}\n\n# Uninstall Shadowsocks-go\nuninstall_shadowsocks_go(){\n    printf \"Are you sure uninstall shadowsocks-go? (y/n) \"\n    printf \"\\n\"\n    read -p \"(Default: n):\" answer\n    [ -z ${answer} ] && answer=\"n\"\n    if [ \"${answer}\" == \"y\" ] || [ \"${answer}\" == \"Y\" ]; then\n        ps -ef | grep -v grep | grep -i \"shadowsocks-server\" > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            /etc/init.d/shadowsocks stop\n        fi\n        if check_sys packageManager yum; then\n            chkconfig --del shadowsocks\n        elif check_sys packageManager apt; then\n            update-rc.d -f shadowsocks remove\n        fi\n        # delete config file\n        rm -rf /etc/shadowsocks\n        # delete shadowsocks\n        rm -f /etc/init.d/shadowsocks\n        rm -f /usr/bin/shadowsocks-server\n        echo \"Shadowsocks-go uninstall success!\"\n    else\n        echo\n        echo \"Uninstall cancelled, nothing to do...\"\n        echo\n    fi\n}\n\n# Install Shadowsocks-go\ninstall_shadowsocks_go(){\n    disable_selinux\n    pre_install\n    download_files\n    config_shadowsocks\n    if check_sys packageManager yum; then\n        firewall_set\n    fi\n    install\n}\n\n# Initialization step\naction=$1\n[ -z $1 ] && action=install\ncase \"$action\" in\n    install|uninstall)\n        ${action}_shadowsocks_go\n        ;;\n    *)\n        echo \"Arguments error! [${action}]\"\n        echo \"Usage: `basename $0` [install|uninstall]\"\n        ;;\nesac\n"
  },
  {
    "path": "shadowsocks-libev",
    "content": "#!/usr/bin/env bash\n# chkconfig: 2345 90 10\n# description: A secure socks5 proxy, designed to protect your Internet traffic.\n\n### BEGIN INIT INFO\n# Provides:          Shadowsocks-libev\n# Required-Start:    $network $syslog\n# Required-Stop:     $network\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: Fast tunnel proxy that helps you bypass firewalls\n# Description:       Start or stop the Shadowsocks-libev server\n### END INIT INFO\n\n# Author: Teddysun <i@teddysun.com>\nif [ -f /usr/local/bin/ss-server ]; then\n    DAEMON=/usr/local/bin/ss-server\nelif [ -f /usr/bin/ss-server ]; then\n    DAEMON=/usr/bin/ss-server\nfi\nNAME=Shadowsocks-libev\nCONF=/etc/shadowsocks-libev/config.json\nPID_DIR=/var/run\nPID_FILE=$PID_DIR/shadowsocks-libev.pid\nRET_VAL=0\n\n[ -x $DAEMON ] || exit 0\n\nif [ ! -d $PID_DIR ]; then\n    mkdir -p $PID_DIR\n    if [ $? -ne 0 ]; then\n        echo \"Creating PID directory $PID_DIR failed\"\n        exit 1\n    fi\nfi\n\nif [ ! -f $CONF ]; then\n    echo \"$NAME config file $CONF not found\"\n     exit 1\nfi\n\ncheck_running() {\n    if [ -r $PID_FILE ]; then\n        read PID < $PID_FILE\n        if [ -d \"/proc/$PID\" ]; then\n            return 0\n        else\n            rm -f $PID_FILE\n            return 1\n        fi\n    else\n        return 2\n    fi\n}\n\ndo_status() {\n    check_running\n    case $? in\n        0)\n        echo \"$NAME (pid $PID) is running...\"\n        ;;\n        1|2)\n        echo \"$NAME is stopped\"\n        RET_VAL=1\n        ;;\n    esac\n}\n\ndo_start() {\n    if check_running; then\n        echo \"$NAME (pid $PID) is already running...\"\n        return 0\n    fi\n    $DAEMON -v -c $CONF -f $PID_FILE\n    if check_running; then\n        echo \"Starting $NAME success\"\n    else\n        echo \"Starting $NAME failed\"\n        RET_VAL=1\n    fi\n}\n\ndo_stop() {\n    if check_running; then\n        kill -9 $PID\n        rm -f $PID_FILE\n        echo \"Stopping $NAME success\"\n    else\n        echo \"$NAME is stopped\"\n        RET_VAL=1\n    fi\n}\n\ndo_restart() {\n    do_stop\n    sleep 0.5\n    do_start\n}\n\ncase \"$1\" in\n    start|stop|restart|status)\n    do_$1\n    ;;\n    *)\n    echo \"Usage: $0 { start | stop | restart | status }\"\n    RET_VAL=1\n    ;;\nesac\n\nexit $RET_VAL\n"
  },
  {
    "path": "shadowsocks-libev-debian",
    "content": "#!/usr/bin/env bash\n\n### BEGIN INIT INFO\n# Provides:          Shadowsocks-libev\n# Required-Start:    $network $local_fs $remote_fs\n# Required-Stop:     $network $local_fs $remote_fs\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: Fast tunnel proxy that helps you bypass firewalls\n# Description:       Start or stop the Shadowsocks-libev server\n### END INIT INFO\n\n# Author: Teddysun <i@teddysun.com>\n\nif [ -f /usr/local/bin/ss-server ]; then\n    DAEMON=/usr/local/bin/ss-server\nelif [ -f /usr/bin/ss-server ]; then\n    DAEMON=/usr/bin/ss-server\nfi\nNAME=Shadowsocks-libev\nCONF=/etc/shadowsocks-libev/config.json\nPID_DIR=/var/run\nPID_FILE=$PID_DIR/shadowsocks-libev.pid\nRET_VAL=0\n\n[ -x $DAEMON ] || exit 0\n\nif [ ! -d $PID_DIR ]; then\n    mkdir -p $PID_DIR\n    if [ $? -ne 0 ]; then\n        echo \"Creating PID directory $PID_DIR failed\"\n        exit 1\n    fi\nfi\n\nif [ ! -f $CONF ]; then\n    echo \"$NAME config file $CONF not found\"\n    exit 1\nfi\n\ncheck_running() {\n    if [ -r $PID_FILE ]; then\n        read PID < $PID_FILE\n        if [ -d \"/proc/$PID\" ]; then\n            return 0\n        else\n            rm -f $PID_FILE\n            return 1\n        fi\n    else\n        return 2\n    fi\n}\n\ndo_status() {\n    check_running\n    case $? in\n        0)\n        echo \"$NAME (pid $PID) is running...\"\n        ;;\n        1|2)\n        echo \"$NAME is stopped\"\n        RET_VAL=1\n        ;;\n    esac\n}\n\ndo_start() {\n    if check_running; then\n        echo \"$NAME (pid $PID) is already running...\"\n        return 0\n    fi\n    $DAEMON -v -c $CONF -f $PID_FILE\n    if check_running; then\n        echo \"Starting $NAME success\"\n    else\n        echo \"Starting $NAME failed\"\n        RET_VAL=1\n    fi\n}\n\ndo_stop() {\n    if check_running; then\n        kill -9 $PID\n        rm -f $PID_FILE\n        echo \"Stopping $NAME success\"\n    else\n        echo \"$NAME is stopped\"\n        RET_VAL=1\n    fi\n}\n\ndo_restart() {\n    do_stop\n    sleep 0.5\n    do_start\n}\n\ncase \"$1\" in\n    start|stop|restart|status)\n    do_$1\n    ;;\n    *)\n    echo \"Usage: $0 { start | stop | restart | status }\"\n    RET_VAL=1\n    ;;\nesac\n\nexit $RET_VAL\n"
  },
  {
    "path": "shadowsocks-libev-debian.sh",
    "content": "#!/usr/bin/env bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\nexport PATH\n#===================================================================#\n#   System Required:  Debian or Ubuntu                              #\n#   Description: Install Shadowsocks-libev server for Debian/Ubuntu #\n#   Author: Teddysun <i@teddysun.com>                               #\n#   Thanks: @madeye <https://github.com/madeye>                     #\n#   Intro:  https://teddysun.com/358.html                           #\n#===================================================================#\n\n# Current folder\ncur_dir=$(pwd)\n\nlibsodium_file='libsodium-1.0.18'\nlibsodium_url='https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz'\n\nmbedtls_file='mbedtls-2.16.12'\nmbedtls_url='https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v2.16.12.tar.gz'\n\n# Stream Ciphers\nciphers=(\naes-256-gcm\naes-192-gcm\naes-128-gcm\naes-256-ctr\naes-192-ctr\naes-128-ctr\naes-256-cfb\naes-192-cfb\naes-128-cfb\ncamellia-128-cfb\ncamellia-192-cfb\ncamellia-256-cfb\nxchacha20-ietf-poly1305\nchacha20-ietf-poly1305\nchacha20-ietf\nchacha20\nsalsa20\nrc4-md5\n)\n# Color\nred='\\033[0;31m'\ngreen='\\033[0;32m'\nyellow='\\033[0;33m'\nplain='\\033[0m'\n\n# Make sure only root can run our script\n[[ $EUID -ne 0 ]] && echo -e \"[${red}Error${plain}] This script must be run as root!\" && exit 1\n\n# Disable selinux\ndisable_selinux(){\n    if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then\n        sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config\n        setenforce 0\n    fi\n}\n\nget_ip(){\n    local IP=$( ip addr | egrep -o '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}' | egrep -v \"^192\\.168|^172\\.1[6-9]\\.|^172\\.2[0-9]\\.|^172\\.3[0-2]\\.|^10\\.|^127\\.|^255\\.|^0\\.\" | head -n 1 )\n    [ -z \"${IP}\" ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )\n    [ -z \"${IP}\" ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip )\n    [ ! -z \"${IP}\" ] && echo \"${IP}\" || echo\n}\n\nget_ipv6(){\n    local ipv6=$(wget -qO- -t1 -T2 ipv6.icanhazip.com)\n    if [ -z \"${ipv6}\" ]; then\n        return 1\n    else\n        return 0\n    fi\n}\n\nget_char(){\n    SAVEDSTTY=$(stty -g)\n    stty -echo\n    stty cbreak\n    dd if=/dev/tty bs=1 count=1 2> /dev/null\n    stty -raw\n    stty echo\n    stty \"$SAVEDSTTY\"\n}\n\nget_latest_version(){\n    ver=$(wget --no-check-certificate -qO- https://api.github.com/repos/shadowsocks/shadowsocks-libev/releases/latest | grep 'tag_name' | cut -d\\\" -f4)\n    [ -z \"${ver}\" ] && echo \"Error: Get shadowsocks-libev latest version failed\" && exit 1\n    shadowsocks_libev_ver=\"shadowsocks-libev-$(echo \"${ver}\" | sed -e 's/^[a-zA-Z]//g')\"\n    download_link=\"https://github.com/shadowsocks/shadowsocks-libev/releases/download/${ver}/${shadowsocks_libev_ver}.tar.gz\"\n    init_script_link=\"https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-libev-debian\"\n}\n\nget_opsy(){\n    [ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return\n    [ -f /etc/os-release ] && awk -F'[= \"]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return\n    [ -f /etc/lsb-release ] && awk -F'[=\"]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return\n}\n\ncheck_installed(){\n    if [ \"$(command -v \"$1\")\" ]; then\n        return 0\n    else\n        return 1\n    fi\n}\n\ncheck_version(){\n    check_installed \"ss-server\"\n    if [ $? -eq 0 ]; then\n        installed_ver=$(ss-server -h | grep shadowsocks-libev | cut -d' ' -f2)\n        get_latest_version\n        latest_ver=$(echo \"${ver}\" | sed -e 's/^[a-zA-Z]//g')\n        if [ \"${latest_ver}\" == \"${installed_ver}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    else\n        return 2\n    fi\n}\n\nprint_info(){\n    clear\n    echo \"#############################################################\"\n    echo \"# Install Shadowsocks-libev server for Debian or Ubuntu     #\"\n    echo \"# Intro:  https://teddysun.com/358.html                     #\"\n    echo \"# Author: Teddysun <i@teddysun.com>                         #\"\n    echo \"# Github: https://github.com/shadowsocks/shadowsocks-libev  #\"\n    echo \"#############################################################\"\n    echo\n}\n\n# Check system\ncheck_sys(){\n    local checkType=$1\n    local value=$2\n\n    local release=''\n    local systemPackage=''\n\n    if [[ -f /etc/redhat-release ]]; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    elif grep -Eqi \"debian|raspbian\" /etc/issue; then\n        release=\"debian\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"ubuntu\" /etc/issue; then\n        release=\"ubuntu\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"centos|red hat|redhat\" /etc/issue; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    elif grep -Eqi \"debian|raspbian\" /proc/version; then\n        release=\"debian\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"ubuntu\" /proc/version; then\n        release=\"ubuntu\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"centos|red hat|redhat\" /proc/version; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    fi\n\n    if [[ \"${checkType}\" == \"sysRelease\" ]]; then\n        if [ \"${value}\" == \"${release}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    elif [[ \"${checkType}\" == \"packageManager\" ]]; then\n        if [ \"${value}\" == \"${systemPackage}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    fi\n}\n\nversion_gt(){\n    test \"$(echo \"$@\" | tr \" \" \"\\n\" | sort -V | head -n 1)\" != \"$1\"\n}\n\ncheck_kernel_version(){\n    local kernel_version=$(uname -r | cut -d- -f1)\n    if version_gt \"${kernel_version}\" 3.7.0; then\n        return 0\n    else\n        return 1\n    fi\n}\n\ncheck_kernel_headers(){\n    if check_sys packageManager yum; then\n        if rpm -qa | grep -q headers-$(uname -r); then\n            return 0\n        else\n            return 1\n        fi\n    elif check_sys packageManager apt; then\n        if dpkg -s linux-headers-$(uname -r) > /dev/null 2>&1; then\n            return 0\n        else\n            return 1\n        fi\n    fi\n    return 1\n}\n\ndebianversion(){\n    if check_sys sysRelease debian;then\n        local version=$( get_opsy )\n        local code=${1}\n        local main_ver=$( echo \"${version}\" | sed 's/[^0-9]//g')\n        if [ \"${main_ver}\" == \"${code}\" ];then\n            return 0\n        else\n            return 1\n        fi\n    else\n        return 1\n    fi\n}\n\n# Pre-installation settings\npre_install(){\n    # Check OS system\n    if ! check_sys packageManager apt; then\n        echo -e \"[${red}Error${plain}] Your OS is not supported to run it, please change OS to Debian/Ubuntu and try again.\"\n        exit 1\n    fi\n\n    # Check version\n    check_version\n    status=$?\n    if [ ${status} -eq 0 ]; then\n        echo -e \"[${green}Info${plain}] Latest version ${green}${shadowsocks_libev_ver}${plain} has already been installed, nothing to do...\"\n        exit 0\n    elif [ ${status} -eq 1 ]; then\n        echo -e \"Installed version: ${red}${installed_ver}${plain}\"\n        echo -e \"Latest version: ${red}${latest_ver}${plain}\"\n        echo -e \"[${green}Info${plain}] Upgrade shadowsocks libev to latest version...\"\n        ps -ef | grep -v grep | grep -i \"ss-server\" > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            /etc/init.d/shadowsocks stop\n        fi\n    elif [ ${status} -eq 2 ]; then\n        print_info\n        get_latest_version\n        echo -e \"[${green}Info${plain}] Latest version: ${green}${shadowsocks_libev_ver}${plain}\"\n        echo\n    fi\n\n    # Set shadowsocks-libev config password\n    echo \"Please input password for shadowsocks-libev:\"\n    read -p \"(Default password: teddysun.com):\" shadowsockspwd\n    [ -z \"${shadowsockspwd}\" ] && shadowsockspwd=\"teddysun.com\"\n    echo\n    echo \"---------------------------\"\n    echo \"password = ${shadowsockspwd}\"\n    echo \"---------------------------\"\n    echo\n\n    # Set shadowsocks-libev config port\n    while true\n    do\n    dport=$(shuf -i 9000-19999 -n 1)\n    echo -e \"Please enter a port for shadowsocks-libev [1-65535]\"\n    read -p \"(Default port: ${dport}):\" shadowsocksport\n    [ -z \"$shadowsocksport\" ] && shadowsocksport=${dport}\n    expr \"${shadowsocksport}\" + 1 &>/dev/null\n    if [ $? -eq 0 ]; then\n        if [ \"${shadowsocksport}\" -ge 1 ] && [ \"${shadowsocksport}\" -le 65535 ] && [ \"${shadowsocksport:0:1}\" != 0 ]; then\n            echo\n            echo \"---------------------------\"\n            echo \"port = ${shadowsocksport}\"\n            echo \"---------------------------\"\n            echo\n            break\n        fi\n    fi\n    echo -e \"[${red}Error${plain}] Please enter a correct number [1-65535]\"\n    done\n\n    # Set shadowsocks config stream ciphers\n    while true\n    do\n    echo -e \"Please select stream cipher for shadowsocks-libev:\"\n    for ((i=1;i<=${#ciphers[@]};i++ )); do\n        hint=\"${ciphers[$i-1]}\"\n        echo -e \"${green}${i}${plain}) ${hint}\"\n    done\n    read -p \"Which cipher you'd select(Default: ${ciphers[0]}):\" pick\n    [ -z \"$pick\" ] && pick=1\n    expr ${pick} + 1 &>/dev/null\n    if [ $? -ne 0 ]; then\n        echo -e \"[${red}Error${plain}] Please enter a number\"\n        continue\n    fi\n    if [[ \"$pick\" -lt 1 || \"$pick\" -gt ${#ciphers[@]} ]]; then\n        echo -e \"[${red}Error${plain}] Please enter a number between 1 and ${#ciphers[@]}\"\n        continue\n    fi\n    shadowsockscipher=${ciphers[$pick-1]}\n    echo\n    echo \"---------------------------\"\n    echo \"cipher = ${shadowsockscipher}\"\n    echo \"---------------------------\"\n    echo\n    break\n    done\n\n    echo\n    echo \"Press any key to start...or press Ctrl+C to cancel\"\n    char=$(get_char)\n\n    # Update System\n    apt-get -y update\n    # Install necessary dependencies\n    apt-get -y --no-install-recommends install gettext build-essential autoconf automake libtool openssl libssl-dev zlib1g-dev libpcre3-dev libev-dev libc-ares-dev\n}\n\ndownload() {\n    local filename=${1}\n    local cur_dir=$(pwd)\n    if [ -s \"${filename}\" ]; then\n        echo -e \"[${green}Info${plain}] ${filename} [found]\"\n    else\n        echo -e \"[${green}Info${plain}] ${filename} not found, download now...\"\n        wget --no-check-certificate -cq -t3 -T60 -O \"${1}\" \"${2}\"\n        if [ $? -eq 0 ]; then\n            echo -e \"[${green}Info${plain}] ${filename} download completed...\"\n        else\n            echo -e \"[${red}Error${plain}] Failed to download ${filename}, please download it to ${cur_dir} directory manually and try again.\"\n            exit 1\n        fi\n    fi\n}\n\n# Download latest shadowsocks-libev\ndownload_files(){\n    cd \"${cur_dir}\" || exit\n\n    download \"${shadowsocks_libev_ver}.tar.gz\" \"${download_link}\"\n    download \"${libsodium_file}.tar.gz\" \"${libsodium_url}\"\n    download \"${mbedtls_file}.tar.gz\" \"${mbedtls_url}\"\n    download \"/etc/init.d/shadowsocks\" \"${init_script_link}\"\n}\n\ninstall_libsodium() {\n    if [ ! -f /usr/lib/libsodium.a ]; then\n        cd \"${cur_dir}\" || exit\n        tar zxf ${libsodium_file}.tar.gz\n        cd ${libsodium_file} || exit\n        ./configure --prefix=/usr && make && make install\n        if [ $? -ne 0 ]; then\n            echo -e \"[${red}Error${plain}] ${libsodium_file} install failed.\"\n            exit 1\n        fi\n    else\n        echo -e \"[${green}Info${plain}] ${libsodium_file} already installed.\"\n    fi\n}\n\ninstall_mbedtls() {\n    if [ ! -f /usr/lib/libmbedtls.a ]; then\n        cd \"${cur_dir}\" || exit\n        tar zxf \"${mbedtls_file}.tar.gz\"\n        cd \"${mbedtls_file}\" || exit\n        make SHARED=1 CFLAGS=-fPIC\n        make DESTDIR=/usr install\n        if [ $? -ne 0 ]; then\n            echo -e \"[${red}Error${plain}] ${mbedtls_file} install failed.\"\n            exit 1\n        fi\n    else\n        echo -e \"[${green}Info${plain}] ${mbedtls_file} already installed.\"\n    fi\n}\n\n# Config shadowsocks\nconfig_shadowsocks(){\n    local server_value=\"\\\"0.0.0.0\\\"\"\n    if get_ipv6; then\n        server_value=\"[\\\"[::0]\\\",\\\"0.0.0.0\\\"]\"\n    fi\n\n    if [ ! -d /etc/shadowsocks-libev ]; then\n        mkdir -p /etc/shadowsocks-libev\n    fi\n    cat > /etc/shadowsocks-libev/config.json<<-EOF\n{\n    \"server\":${server_value},\n    \"server_port\":${shadowsocksport},\n    \"password\":\"${shadowsockspwd}\",\n    \"timeout\":300,\n    \"user\":\"nobody\",\n    \"method\":\"${shadowsockscipher}\",\n    \"fast_open\":false,\n    \"nameserver\":\"1.0.0.1\",\n    \"mode\":\"tcp_and_udp\"\n}\nEOF\n}\n\n# Install Shadowsocks-libev\ninstall_shadowsocks(){\n    install_libsodium\n    install_mbedtls\n\n    ldconfig\n    cd \"${cur_dir}\" || exit\n    tar zxf \"${shadowsocks_libev_ver}\".tar.gz\n    cd \"${shadowsocks_libev_ver}\" || exit\n    ./configure --disable-documentation\n    make && make install\n    if [ $? -eq 0 ]; then\n        chmod +x /etc/init.d/shadowsocks\n        update-rc.d -f shadowsocks defaults\n        # Start shadowsocks\n        /etc/init.d/shadowsocks start\n        if [ $? -eq 0 ]; then\n            echo -e \"[${green}Info${plain}] Shadowsocks-libev start success!\"\n        else\n            echo -e \"[${yellow}Warning${plain}] Shadowsocks-libev start failure!\"\n        fi\n    else\n        echo\n        echo -e \"[${red}Error${plain}] Shadowsocks-libev install failed. please visit https://teddysun.com/358.html and contact.\"\n        exit 1\n    fi\n\n    cd \"${cur_dir}\" || exit\n    rm -rf \"${shadowsocks_libev_ver}\" \"${shadowsocks_libev_ver}\".tar.gz\n    rm -rf ${libsodium_file} ${libsodium_file}.tar.gz\n    rm -rf \"${mbedtls_file}\" \"${mbedtls_file}\"-apache.tgz\n\n    clear\n    echo\n    echo -e \"Congratulations, Shadowsocks-libev server install completed!\"\n    echo -e \"Your Server IP        : \\033[41;37m $(get_ip) \\033[0m\"\n    echo -e \"Your Server Port      : \\033[41;37m ${shadowsocksport} \\033[0m\"\n    echo -e \"Your Password         : \\033[41;37m ${shadowsockspwd} \\033[0m\"\n    echo -e \"Your Encryption Method: \\033[41;37m ${shadowsockscipher} \\033[0m\"\n    echo\n    echo \"Welcome to visit:https://teddysun.com/358.html\"\n    echo \"Enjoy it!\"\n    echo\n}\n\n# Install Shadowsocks-libev\ninstall_shadowsocks_libev(){\n    disable_selinux\n    pre_install\n    download_files\n    config_shadowsocks\n    install_shadowsocks\n}\n\n# Uninstall Shadowsocks-libev\nuninstall_shadowsocks_libev(){\n    clear\n    print_info\n    printf \"Are you sure uninstall Shadowsocks-libev? (y/n)\"\n    printf \"\\n\"\n    read -p \"(Default: n):\" answer\n    [ -z \"${answer}\" ] && answer=\"n\"\n\n    if [ \"${answer}\" == \"y\" ] || [ \"${answer}\" == \"Y\" ]; then\n        ps -ef | grep -v grep | grep -i \"ss-server\" > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            /etc/init.d/shadowsocks stop\n        fi\n        update-rc.d -f shadowsocks remove\n\n        rm -fr /etc/shadowsocks-libev\n        rm -f /usr/local/bin/ss-local\n        rm -f /usr/local/bin/ss-tunnel\n        rm -f /usr/local/bin/ss-server\n        rm -f /usr/local/bin/ss-manager\n        rm -f /usr/local/bin/ss-redir\n        rm -f /usr/local/bin/ss-nat\n        rm -f /usr/local/lib/libshadowsocks-libev.a\n        rm -f /usr/local/lib/libshadowsocks-libev.la\n        rm -f /usr/local/include/shadowsocks.h\n        rm -f /usr/local/lib/pkgconfig/shadowsocks-libev.pc\n        rm -f /usr/local/share/man/man1/ss-local.1\n        rm -f /usr/local/share/man/man1/ss-tunnel.1\n        rm -f /usr/local/share/man/man1/ss-server.1\n        rm -f /usr/local/share/man/man1/ss-manager.1\n        rm -f /usr/local/share/man/man1/ss-redir.1\n        rm -f /usr/local/share/man/man1/ss-nat.1\n        rm -f /usr/local/share/man/man8/shadowsocks-libev.8\n        rm -fr /usr/local/share/doc/shadowsocks-libev\n        rm -f /etc/init.d/shadowsocks\n        echo \"Shadowsocks-libev uninstall success!\"\n    else\n        echo\n        echo \"uninstall cancelled, nothing to do...\"\n        echo\n    fi\n}\n\n# Initialization step\naction=$1\n[ -z \"$1\" ] && action=install\ncase \"$action\" in\n    install|uninstall)\n        ${action}_shadowsocks_libev\n        ;;\n    *)\n        echo \"Arguments error! [${action}]\"\n        echo \"Usage: $(basename \"$0\") [install|uninstall]\"\n        ;;\nesac\n"
  },
  {
    "path": "shadowsocks-libev.sh",
    "content": "#!/usr/bin/env bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\nexport PATH\n#===================================================================#\n#   System Required:  CentOS 6 or 7                                 #\n#   Description: Install Shadowsocks-libev server for CentOS 6 or 7 #\n#   Author: Teddysun <i@teddysun.com>                               #\n#   Thanks: @madeye <https://github.com/madeye>                     #\n#   Intro:  https://teddysun.com/357.html                           #\n#===================================================================#\n\n# Current folder\ncur_dir=$(pwd)\n\nlibsodium_file='libsodium-1.0.18'\nlibsodium_url='https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz'\n\nmbedtls_file='mbedtls-2.16.12'\nmbedtls_url='https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v2.16.12.tar.gz'\n\n# Stream Ciphers\nciphers=(\naes-256-gcm\naes-192-gcm\naes-128-gcm\naes-256-ctr\naes-192-ctr\naes-128-ctr\naes-256-cfb\naes-192-cfb\naes-128-cfb\ncamellia-128-cfb\ncamellia-192-cfb\ncamellia-256-cfb\nxchacha20-ietf-poly1305\nchacha20-ietf-poly1305\nchacha20-ietf\nchacha20\nsalsa20\nrc4-md5\n)\n# Color\nred='\\033[0;31m'\ngreen='\\033[0;32m'\nyellow='\\033[0;33m'\nplain='\\033[0m'\n\n# Make sure only root can run our script\n[[ $EUID -ne 0 ]] && echo -e \"[${red}Error${plain}] This script must be run as root!\" && exit 1\n\n# Disable selinux\ndisable_selinux(){\n    if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then\n        sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config\n        setenforce 0\n    fi\n}\n\nget_ip(){\n    local IP=$( ip addr | egrep -o '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}' | egrep -v \"^192\\.168|^172\\.1[6-9]\\.|^172\\.2[0-9]\\.|^172\\.3[0-2]\\.|^10\\.|^127\\.|^255\\.|^0\\.\" | head -n 1 )\n    [ -z \"${IP}\" ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )\n    [ -z \"${IP}\" ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip )\n    [ ! -z \"${IP}\" ] && echo \"${IP}\" || echo\n}\n\nget_ipv6(){\n    local ipv6=$(wget -qO- -t1 -T2 ipv6.icanhazip.com)\n    if [ -z \"${ipv6}\" ]; then\n        return 1\n    else\n        return 0\n    fi\n}\n\nget_char(){\n    SAVEDSTTY=$(stty -g)\n    stty -echo\n    stty cbreak\n    dd if=/dev/tty bs=1 count=1 2> /dev/null\n    stty -raw\n    stty echo\n    stty \"$SAVEDSTTY\"\n}\n\nget_latest_version(){\n    ver=$(wget --no-check-certificate -qO- https://api.github.com/repos/shadowsocks/shadowsocks-libev/releases/latest | grep 'tag_name' | cut -d\\\" -f4)\n    [ -z \"${ver}\" ] && echo \"Error: Get shadowsocks-libev latest version failed\" && exit 1\n    shadowsocks_libev_ver=\"shadowsocks-libev-$(echo \"${ver}\" | sed -e 's/^[a-zA-Z]//g')\"\n    download_link=\"https://github.com/shadowsocks/shadowsocks-libev/releases/download/${ver}/${shadowsocks_libev_ver}.tar.gz\"\n    init_script_link=\"https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-libev\"\n}\n\ncheck_installed(){\n    if [ \"$(command -v \"$1\")\" ]; then\n        return 0\n    else\n        return 1\n    fi\n}\n\ncheck_version(){\n    check_installed \"ss-server\"\n    if [ $? -eq 0 ]; then\n        installed_ver=$(ss-server -h | grep shadowsocks-libev | cut -d' ' -f2)\n        get_latest_version\n        latest_ver=$(echo \"${ver}\" | sed -e 's/^[a-zA-Z]//g')\n        if [ \"${latest_ver}\" == \"${installed_ver}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    else\n        return 2\n    fi\n}\n\nprint_info(){\n    clear\n    echo \"#############################################################\"\n    echo \"# Install Shadowsocks-libev server for CentOS 6 or 7        #\"\n    echo \"# Intro:  https://teddysun.com/357.html                     #\"\n    echo \"# Author: Teddysun <i@teddysun.com>                         #\"\n    echo \"# Github: https://github.com/shadowsocks/shadowsocks-libev  #\"\n    echo \"#############################################################\"\n    echo\n}\n\n# Check system\ncheck_sys(){\n    local checkType=$1\n    local value=$2\n\n    local release=''\n    local systemPackage=''\n\n    if [[ -f /etc/redhat-release ]]; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    elif grep -Eqi \"debian|raspbian\" /etc/issue; then\n        release=\"debian\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"ubuntu\" /etc/issue; then\n        release=\"ubuntu\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"centos|red hat|redhat\" /etc/issue; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    elif grep -Eqi \"debian|raspbian\" /proc/version; then\n        release=\"debian\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"ubuntu\" /proc/version; then\n        release=\"ubuntu\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"centos|red hat|redhat\" /proc/version; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    fi\n\n    if [[ \"${checkType}\" == \"sysRelease\" ]]; then\n        if [ \"${value}\" == \"${release}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    elif [[ \"${checkType}\" == \"packageManager\" ]]; then\n        if [ \"${value}\" == \"${systemPackage}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    fi\n}\n\nversion_gt(){\n    test \"$(echo \"$@\" | tr \" \" \"\\n\" | sort -V | head -n 1)\" != \"$1\"\n}\n\ncheck_kernel_version(){\n    local kernel_version=$(uname -r | cut -d- -f1)\n    if version_gt \"${kernel_version}\" 3.7.0; then\n        return 0\n    else\n        return 1\n    fi\n}\n\ncheck_kernel_headers(){\n    if check_sys packageManager yum; then\n        if rpm -qa | grep -q headers-$(uname -r); then\n            return 0\n        else\n            return 1\n        fi\n    elif check_sys packageManager apt; then\n        if dpkg -s linux-headers-$(uname -r) > /dev/null 2>&1; then\n            return 0\n        else\n            return 1\n        fi\n    fi\n    return 1\n}\n\n# Get version\ngetversion(){\n    if [[ -s /etc/redhat-release ]]; then\n        grep -oE  \"[0-9.]+\" /etc/redhat-release\n    else\n        grep -oE  \"[0-9.]+\" /etc/issue\n    fi\n}\n\n# CentOS version\ncentosversion(){\n    if check_sys sysRelease centos; then\n        local code=$1\n        local version=\"$(getversion)\"\n        local main_ver=${version%%.*}\n        if [ \"$main_ver\" == \"$code\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    else\n        return 1\n    fi\n}\n\n# Pre-installation settings\npre_install(){\n    # Check OS system\n    if check_sys sysRelease centos; then\n        # Not support CentOS 5\n        if centosversion 5; then\n            echo -e \"[${red}Error${plain}] Not support CentOS 5, please change to CentOS 6 or 7 and try again.\"\n            exit 1\n        fi\n    else\n        echo -e \"[${red}Error${plain}] Your OS is not supported to run it, please change OS to CentOS and try again.\"\n        exit 1\n    fi\n\n    # Check version\n    check_version\n    status=$?\n    if [ ${status} -eq 0 ]; then\n        echo -e \"[${green}Info${plain}] Latest version ${green}${shadowsocks_libev_ver}${plain} has already been installed, nothing to do...\"\n        exit 0\n    elif [ ${status} -eq 1 ]; then\n        echo -e \"Installed version: ${red}${installed_ver}${plain}\"\n        echo -e \"Latest version: ${red}${latest_ver}${plain}\"\n        echo -e \"[${green}Info${plain}] Upgrade shadowsocks libev to latest version...\"\n        ps -ef | grep -v grep | grep -i \"ss-server\" > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            /etc/init.d/shadowsocks stop\n        fi\n    elif [ ${status} -eq 2 ]; then\n        print_info\n        get_latest_version\n        echo -e \"[${green}Info${plain}] Latest version: ${green}${shadowsocks_libev_ver}${plain}\"\n        echo\n    fi\n\n    # Set shadowsocks-libev config password\n    echo \"Please enter password for shadowsocks-libev:\"\n    read -p \"(Default password: teddysun.com):\" shadowsockspwd\n    [ -z \"${shadowsockspwd}\" ] && shadowsockspwd=\"teddysun.com\"\n    echo\n    echo \"---------------------------\"\n    echo \"password = ${shadowsockspwd}\"\n    echo \"---------------------------\"\n    echo\n\n    # Set shadowsocks-libev config port\n    while true\n    do\n    dport=$(shuf -i 9000-19999 -n 1)\n    echo -e \"Please enter a port for shadowsocks-libev [1-65535]\"\n    read -p \"(Default port: ${dport}):\" shadowsocksport\n    [ -z \"$shadowsocksport\" ] && shadowsocksport=${dport}\n    expr \"${shadowsocksport}\" + 1 &>/dev/null\n    if [ $? -eq 0 ]; then\n        if [ \"${shadowsocksport}\" -ge 1 ] && [ \"${shadowsocksport}\" -le 65535 ] && [ \"${shadowsocksport:0:1}\" != 0 ]; then\n            echo\n            echo \"---------------------------\"\n            echo \"port = ${shadowsocksport}\"\n            echo \"---------------------------\"\n            echo\n            break\n        fi\n    fi\n    echo -e \"[${red}Error${plain}] Please enter a correct number [1-65535]\"\n    done\n\n    # Set shadowsocks config stream ciphers\n    while true\n    do\n    echo -e \"Please select stream cipher for shadowsocks-libev:\"\n    for ((i=1;i<=${#ciphers[@]};i++ )); do\n        hint=\"${ciphers[$i-1]}\"\n        echo -e \"${green}${i}${plain}) ${hint}\"\n    done\n    read -p \"Which cipher you'd select(Default: ${ciphers[0]}):\" pick\n    [ -z \"$pick\" ] && pick=1\n    expr ${pick} + 1 &>/dev/null\n    if [ $? -ne 0 ]; then\n        echo -e \"[${red}Error${plain}] Please enter a number\"\n        continue\n    fi\n    if [[ \"$pick\" -lt 1 || \"$pick\" -gt ${#ciphers[@]} ]]; then\n        echo -e \"[${red}Error${plain}] Please enter a number between 1 and ${#ciphers[@]}\"\n        continue\n    fi\n    shadowsockscipher=${ciphers[$pick-1]}\n    echo\n    echo \"---------------------------\"\n    echo \"cipher = ${shadowsockscipher}\"\n    echo \"---------------------------\"\n    echo\n    break\n    done\n\n    echo\n    echo \"Press any key to start...or press Ctrl+C to cancel\"\n    char=$(get_char)\n    #Install necessary dependencies\n    echo -e \"[${green}Info${plain}] Checking the EPEL repository...\"\n    if [ ! -f /etc/yum.repos.d/epel.repo ]; then\n        yum install -y -q epel-release\n    fi\n    [ ! -f /etc/yum.repos.d/epel.repo ] && echo -e \"[${red}Error${plain}] Install EPEL repository failed, please check it.\" && exit 1\n    [ ! \"$(command -v yum-config-manager)\" ] && yum install -y -q yum-utils\n    if [ x\"$(yum-config-manager epel | grep -w enabled | awk '{print $3}')\" != x\"True\" ]; then\n        yum-config-manager --enable epel\n    fi\n    echo -e \"[${green}Info${plain}] Checking the EPEL repository complete...\"\n    yum install -y -q unzip openssl openssl-devel gettext gcc autoconf libtool automake make asciidoc xmlto libev-devel pcre pcre-devel git c-ares-devel\n}\n\ndownload() {\n    local filename=${1}\n    local cur_dir=$(pwd)\n    if [ -s \"${filename}\" ]; then\n        echo -e \"[${green}Info${plain}] ${filename} [found]\"\n    else\n        echo -e \"[${green}Info${plain}] ${filename} not found, download now...\"\n        wget --no-check-certificate -cq -t3 -T60 -O \"${1}\" \"${2}\"\n        if [ $? -eq 0 ]; then\n            echo -e \"[${green}Info${plain}] ${filename} download completed...\"\n        else\n            echo -e \"[${red}Error${plain}] Failed to download ${filename}, please download it to ${cur_dir} directory manually and try again.\"\n            exit 1\n        fi\n    fi\n}\n\n# Download latest shadowsocks-libev\ndownload_files(){\n    cd \"${cur_dir}\" || exit\n\n    download \"${shadowsocks_libev_ver}.tar.gz\" \"${download_link}\"\n    download \"${libsodium_file}.tar.gz\" \"${libsodium_url}\"\n    download \"${mbedtls_file}.tar.gz\" \"${mbedtls_url}\"\n    download \"/etc/init.d/shadowsocks\" \"${init_script_link}\"\n}\n\ninstall_libsodium() {\n    if [ ! -f /usr/lib/libsodium.a ]; then\n        cd \"${cur_dir}\" || exit\n        tar zxf ${libsodium_file}.tar.gz\n        cd ${libsodium_file} || exit\n        ./configure --prefix=/usr && make && make install\n        if [ $? -ne 0 ]; then\n            echo -e \"[${red}Error${plain}] ${libsodium_file} install failed.\"\n            exit 1\n        fi\n    else\n        echo -e \"[${green}Info${plain}] ${libsodium_file} already installed.\"\n    fi\n}\n\ninstall_mbedtls() {\n    if [ ! -f /usr/lib/libmbedtls.a ]; then\n        cd \"${cur_dir}\" || exit\n        tar zxf \"${mbedtls_file}.tar.gz\"\n        cd \"${mbedtls_file}\" || exit\n        make SHARED=1 CFLAGS=-fPIC\n        make DESTDIR=/usr install\n        if [ $? -ne 0 ]; then\n            echo -e \"[${red}Error${plain}] ${mbedtls_file} install failed.\"\n            exit 1\n        fi\n    else\n        echo -e \"[${green}Info${plain}] ${mbedtls_file} already installed.\"\n    fi\n}\n\n# Config shadowsocks\nconfig_shadowsocks(){\n    local server_value=\"\\\"0.0.0.0\\\"\"\n    if get_ipv6; then\n        server_value=\"[\\\"[::0]\\\",\\\"0.0.0.0\\\"]\"\n    fi\n\n    if [ ! -d /etc/shadowsocks-libev ]; then\n        mkdir -p /etc/shadowsocks-libev\n    fi\n    cat > /etc/shadowsocks-libev/config.json<<-EOF\n{\n    \"server\":${server_value},\n    \"server_port\":${shadowsocksport},\n    \"password\":\"${shadowsockspwd}\",\n    \"timeout\":300,\n    \"user\":\"nobody\",\n    \"method\":\"${shadowsockscipher}\",\n    \"fast_open\":false,\n    \"nameserver\":\"1.0.0.1\",\n    \"mode\":\"tcp_and_udp\"\n}\nEOF\n}\n\n# Firewall set\nfirewall_set(){\n    echo -e \"[${green}Info${plain}] firewall set start...\"\n    if centosversion 6; then\n        /etc/init.d/iptables status > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            iptables -L -n | grep -i \"${shadowsocksport}\" > /dev/null 2>&1\n            if [ $? -ne 0 ]; then\n                iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport \"${shadowsocksport}\" -j ACCEPT\n                iptables -I INPUT -m state --state NEW -m udp -p udp --dport \"${shadowsocksport}\" -j ACCEPT\n                /etc/init.d/iptables save\n                /etc/init.d/iptables restart\n            else\n                echo -e \"[${green}Info${plain}] port ${shadowsocksport} has been set up.\"\n            fi\n        else\n            echo -e \"[${yellow}Warning${plain}] iptables looks like shutdown or not installed, please manually set it if necessary.\"\n        fi\n    elif centosversion 7; then\n        systemctl status firewalld > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            default_zone=$(firewall-cmd --get-default-zone)\n            firewall-cmd --permanent --zone=\"${default_zone}\" --add-port=\"${shadowsocksport}\"/tcp\n            firewall-cmd --permanent --zone=\"${default_zone}\" --add-port=\"${shadowsocksport}\"/udp\n            firewall-cmd --reload\n        else\n            echo -e \"[${yellow}Warning${plain}] firewalld looks like not running or not installed, please enable port ${shadowsocksport} manually if necessary.\"\n        fi\n    fi\n    echo -e \"[${green}Info${plain}] firewall set completed...\"\n}\n\n# Install Shadowsocks-libev\ninstall_shadowsocks(){\n    install_libsodium\n    install_mbedtls\n\n    ldconfig\n    cd \"${cur_dir}\" || exit\n    tar zxf \"${shadowsocks_libev_ver}\".tar.gz\n    cd \"${shadowsocks_libev_ver}\" || exit\n    ./configure --disable-documentation\n    make && make install\n    if [ $? -eq 0 ]; then\n        chmod +x /etc/init.d/shadowsocks\n        chkconfig --add shadowsocks\n        chkconfig shadowsocks on\n        # Start shadowsocks\n        /etc/init.d/shadowsocks start\n        if [ $? -eq 0 ]; then\n            echo -e \"[${green}Info${plain}] Shadowsocks-libev start success!\"\n        else\n            echo -e \"[${yellow}Warning${plain}] Shadowsocks-libev start failure!\"\n        fi\n    else\n        echo\n        echo -e \"[${red}Error${plain}] Shadowsocks-libev install failed. please visit https://teddysun.com/357.html and contact.\"\n        exit 1\n    fi\n\n    cd \"${cur_dir}\" || exit\n    rm -rf \"${shadowsocks_libev_ver}\" \"${shadowsocks_libev_ver}\".tar.gz\n    rm -rf ${libsodium_file} ${libsodium_file}.tar.gz\n    rm -rf \"${mbedtls_file}\" \"${mbedtls_file}\"-apache.tgz\n\n    clear\n    echo\n    echo -e \"Congratulations, Shadowsocks-libev server install completed!\"\n    echo -e \"Your Server IP        : \\033[41;37m $(get_ip) \\033[0m\"\n    echo -e \"Your Server Port      : \\033[41;37m ${shadowsocksport} \\033[0m\"\n    echo -e \"Your Password         : \\033[41;37m ${shadowsockspwd} \\033[0m\"\n    echo -e \"Your Encryption Method: \\033[41;37m ${shadowsockscipher} \\033[0m\"\n    echo\n    echo \"Welcome to visit:https://teddysun.com/357.html\"\n    echo \"Enjoy it!\"\n    echo\n}\n\n# Install Shadowsocks-libev\ninstall_shadowsocks_libev(){\n    disable_selinux\n    pre_install\n    download_files\n    config_shadowsocks\n    firewall_set\n    install_shadowsocks\n}\n\n# Uninstall Shadowsocks-libev\nuninstall_shadowsocks_libev(){\n    clear\n    print_info\n    printf \"Are you sure uninstall Shadowsocks-libev? (y/n)\"\n    printf \"\\n\"\n    read -p \"(Default: n):\" answer\n    [ -z \"${answer}\" ] && answer=\"n\"\n\n    if [ \"${answer}\" == \"y\" ] || [ \"${answer}\" == \"Y\" ]; then\n        ps -ef | grep -v grep | grep -i \"ss-server\" > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            /etc/init.d/shadowsocks stop\n        fi\n        chkconfig --del shadowsocks\n        rm -fr /etc/shadowsocks-libev\n        rm -f /usr/local/bin/ss-local\n        rm -f /usr/local/bin/ss-tunnel\n        rm -f /usr/local/bin/ss-server\n        rm -f /usr/local/bin/ss-manager\n        rm -f /usr/local/bin/ss-redir\n        rm -f /usr/local/bin/ss-nat\n        rm -f /usr/local/lib/libshadowsocks-libev.a\n        rm -f /usr/local/lib/libshadowsocks-libev.la\n        rm -f /usr/local/include/shadowsocks.h\n        rm -f /usr/local/lib/pkgconfig/shadowsocks-libev.pc\n        rm -f /usr/local/share/man/man1/ss-local.1\n        rm -f /usr/local/share/man/man1/ss-tunnel.1\n        rm -f /usr/local/share/man/man1/ss-server.1\n        rm -f /usr/local/share/man/man1/ss-manager.1\n        rm -f /usr/local/share/man/man1/ss-redir.1\n        rm -f /usr/local/share/man/man1/ss-nat.1\n        rm -f /usr/local/share/man/man8/shadowsocks-libev.8\n        rm -fr /usr/local/share/doc/shadowsocks-libev\n        rm -f /etc/init.d/shadowsocks\n        echo \"Shadowsocks-libev uninstall success!\"\n    else\n        echo\n        echo \"uninstall cancelled, nothing to do...\"\n        echo\n    fi\n}\n\n# Initialization step\naction=$1\n[ -z \"$1\" ] && action=install\ncase \"$action\" in\n    install|uninstall)\n        ${action}_shadowsocks_libev\n        ;;\n    *)\n        echo \"Arguments error! [${action}]\"\n        echo \"Usage: $(basename \"$0\") [install|uninstall]\"\n        ;;\nesac\n"
  },
  {
    "path": "shadowsocks-manager",
    "content": "#!/usr/bin/env bash\n# chkconfig: 2345 90 10\n# description: A secure socks5 proxy, designed to protect your Internet traffic.\n\n### BEGIN INIT INFO\n# Provides:          Shadowsocks-libev\n# Required-Start:    $network $syslog\n# Required-Stop:     $network\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: Fast tunnel proxy that helps you bypass firewalls\n# Description:       Start or Stop the Shadowsocks-libev server to support multiple users with ss-manager\n### END INIT INFO\n\n# Author: Teddysun <i@teddysun.com>\n\nif [ -f /usr/local/bin/ss-manager ]; then\n    MANAGER=/usr/local/bin/ss-manager\nelif [ -f /usr/bin/ss-manager ]; then\n    MANAGER=/usr/bin/ss-manager\nfi\n\nif [ -f /usr/local/bin/ss-server ]; then\n    DAEMON=/usr/local/bin/ss-server\nelif [ -f /usr/bin/ss-server ]; then\n    DAEMON=/usr/bin/ss-server\nfi\n\nNAME=Shadowsocks-manager\nCONF=/etc/shadowsocks-manager/config.json\nPID_DIR=/var/run\nPID_FILE=$PID_DIR/shadowsocks-manager.pid\nSOCK_FILE=$PID_DIR/shadowsocks-manager.sock\nWK_DIR=~/.shadowsocks\nWK_PID_LST=($WK_DIR/.*pid)\n\nRET_VAL=0\n\n[ -x $MANAGER ] || exit 0\n[ -x $DAEMON ] || exit 0\n\nif [ ! -d $PID_DIR ]; then\n    mkdir -p $PID_DIR\n    if [ $? -ne 0 ]; then\n        echo \"Creating PID directory $PID_DIR failed\"\n        exit 1\n    fi\nfi\n\nif [ ! -f $CONF ]; then\n    echo \"$NAME config file $CONF not found\"\n    exit 1\nfi\n\ncheck_running() {\n    if [ -r $PID_FILE ]; then\n        read PID < $PID_FILE\n        if [ -d \"/proc/$PID\" ]; then\n            return 0\n        else\n            rm -f $PID_FILE\n            return 1\n        fi\n    else\n        return 2\n    fi\n}\n\ndo_status() {\n    check_running\n    case $? in\n        0)\n        echo \"$NAME (pid $PID) is running...\"\n        ;;\n        1|2)\n        echo \"$NAME is stopped\"\n        RET_VAL=1\n        ;;\n    esac\n}\n\ndo_start() {\n    if check_running; then\n        echo \"$NAME (pid $PID) is already running...\"\n        return 0\n    fi\n    $MANAGER --manager-address $SOCK_FILE --executable $DAEMON -c $CONF -f $PID_FILE\n    if check_running; then\n        echo \"Starting $NAME success\"\n    else\n        echo \"Starting $NAME failed\"\n        RET_VAL=1\n    fi\n}\n\ndo_stop() {\n    if check_running; then\n        kill -9 $PID\n        rm -f $PID_FILE\n        rm -f $SOCK_FILE\n        for i in \"${WK_PID_LST[@]}\"; do\n            [ -r $i ] && read WK_PID < $i\n            [ -d \"/proc/$WK_PID\" ] && kill -9 $WK_PID\n            rm -f $i\n        done\n        echo \"Stopping $NAME success\"\n    else\n        echo \"$NAME is stopped\"\n        RET_VAL=1\n    fi\n}\n\ndo_restart() {\n    do_stop\n    sleep 0.5\n    do_start\n}\n\ncase \"$1\" in\n    start|stop|restart|status)\n    do_$1\n    ;;\n    *)\n    echo \"Usage: $0 { start | stop | restart | status }\"\n    RET_VAL=1\n    ;;\nesac\n\nexit $RET_VAL\n"
  },
  {
    "path": "shadowsocks.sh",
    "content": "#!/usr/bin/env bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\nexport PATH\n#=================================================================#\n#   System Required:  CentOS 6+, Debian 7+, Ubuntu 12+            #\n#   Description: One click Install Shadowsocks-Python server      #\n#   Author: Teddysun <i@teddysun.com>                             #\n#   Thanks: @clowwindy <https://twitter.com/clowwindy>            #\n#   Intro:  https://teddysun.com/342.html                         #\n#=================================================================#\n\nclear\necho\necho \"#############################################################\"\necho \"# One click Install Shadowsocks-Python server               #\"\necho \"# Intro: https://teddysun.com/342.html                      #\"\necho \"# Author: Teddysun <i@teddysun.com>                         #\"\necho \"# Github: https://github.com/shadowsocks/shadowsocks        #\"\necho \"#############################################################\"\necho\n\nlibsodium_file=\"libsodium-1.0.18\"\nlibsodium_url=\"https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz\"\n\n# Current folder\ncur_dir=`pwd`\n# Stream Ciphers\nciphers=(\naes-256-gcm\naes-192-gcm\naes-128-gcm\naes-256-ctr\naes-192-ctr\naes-128-ctr\naes-256-cfb\naes-192-cfb\naes-128-cfb\ncamellia-128-cfb\ncamellia-192-cfb\ncamellia-256-cfb\nchacha20-ietf-poly1305\nchacha20-ietf\nchacha20\nrc4-md5\n)\n# Color\nred='\\033[0;31m'\ngreen='\\033[0;32m'\nyellow='\\033[0;33m'\nplain='\\033[0m'\n\n# Make sure only root can run our script\n[[ $EUID -ne 0 ]] && echo -e \"[${red}Error${plain}] This script must be run as root!\" && exit 1\n\n# Disable selinux\ndisable_selinux(){\n    if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then\n        sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config\n        setenforce 0\n    fi\n}\n\n#Check system\ncheck_sys(){\n    local checkType=$1\n    local value=$2\n\n    local release=''\n    local systemPackage=''\n\n    if [[ -f /etc/redhat-release ]]; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    elif grep -Eqi \"debian|raspbian\" /etc/issue; then\n        release=\"debian\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"ubuntu\" /etc/issue; then\n        release=\"ubuntu\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"centos|red hat|redhat\" /etc/issue; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    elif grep -Eqi \"debian|raspbian\" /proc/version; then\n        release=\"debian\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"ubuntu\" /proc/version; then\n        release=\"ubuntu\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"centos|red hat|redhat\" /proc/version; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    fi\n\n    if [[ \"${checkType}\" == \"sysRelease\" ]]; then\n        if [ \"${value}\" == \"${release}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    elif [[ \"${checkType}\" == \"packageManager\" ]]; then\n        if [ \"${value}\" == \"${systemPackage}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    fi\n}\n\n# Get version\ngetversion(){\n    if [[ -s /etc/redhat-release ]]; then\n        grep -oE  \"[0-9.]+\" /etc/redhat-release\n    else\n        grep -oE  \"[0-9.]+\" /etc/issue\n    fi\n}\n\n# CentOS version\ncentosversion(){\n    if check_sys sysRelease centos; then\n        local code=$1\n        local version=\"$(getversion)\"\n        local main_ver=${version%%.*}\n        if [ \"$main_ver\" == \"$code\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    else\n        return 1\n    fi\n}\n\n# Get public IP address\nget_ip(){\n    local IP=$( ip addr | egrep -o '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}' | egrep -v \"^192\\.168|^172\\.1[6-9]\\.|^172\\.2[0-9]\\.|^172\\.3[0-2]\\.|^10\\.|^127\\.|^255\\.|^0\\.\" | head -n 1 )\n    [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )\n    [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip )\n    [ ! -z ${IP} ] && echo ${IP} || echo\n}\n\nget_char(){\n    SAVEDSTTY=`stty -g`\n    stty -echo\n    stty cbreak\n    dd if=/dev/tty bs=1 count=1 2> /dev/null\n    stty -raw\n    stty echo\n    stty $SAVEDSTTY\n}\n\n# Pre-installation settings\npre_install(){\n    if check_sys packageManager yum || check_sys packageManager apt; then\n        # Not support CentOS 5\n        if centosversion 5; then\n            echo -e \"$[{red}Error${plain}] Not supported CentOS 5, please change to CentOS 6+/Debian 7+/Ubuntu 12+ and try again.\"\n            exit 1\n        fi\n    else\n        echo -e \"[${red}Error${plain}] Your OS is not supported. please change OS to CentOS/Debian/Ubuntu and try again.\"\n        exit 1\n    fi\n    # Set shadowsocks config password\n    echo \"Please enter password for shadowsocks-python\"\n    read -p \"(Default password: teddysun.com):\" shadowsockspwd\n    [ -z \"${shadowsockspwd}\" ] && shadowsockspwd=\"teddysun.com\"\n    echo\n    echo \"---------------------------\"\n    echo \"password = ${shadowsockspwd}\"\n    echo \"---------------------------\"\n    echo\n    # Set shadowsocks config port\n    while true\n    do\n    dport=$(shuf -i 9000-19999 -n 1)\n    echo \"Please enter a port for shadowsocks-python [1-65535]\"\n    read -p \"(Default port: ${dport}):\" shadowsocksport\n    [ -z \"$shadowsocksport\" ] && shadowsocksport=${dport}\n    expr ${shadowsocksport} + 1 &>/dev/null\n    if [ $? -eq 0 ]; then\n        if [ ${shadowsocksport} -ge 1 ] && [ ${shadowsocksport} -le 65535 ] && [ ${shadowsocksport:0:1} != 0 ]; then\n            echo\n            echo \"---------------------------\"\n            echo \"port = ${shadowsocksport}\"\n            echo \"---------------------------\"\n            echo\n            break\n        fi\n    fi\n    echo -e \"[${red}Error${plain}] Please enter a correct number [1-65535]\"\n    done\n\n    # Set shadowsocks config stream ciphers\n    while true\n    do\n    echo -e \"Please select stream cipher for shadowsocks-python:\"\n    for ((i=1;i<=${#ciphers[@]};i++ )); do\n        hint=\"${ciphers[$i-1]}\"\n        echo -e \"${green}${i}${plain}) ${hint}\"\n    done\n    read -p \"Which cipher you'd select(Default: ${ciphers[0]}):\" pick\n    [ -z \"$pick\" ] && pick=1\n    expr ${pick} + 1 &>/dev/null\n    if [ $? -ne 0 ]; then\n        echo -e \"[${red}Error${plain}] Please enter a number\"\n        continue\n    fi\n    if [[ \"$pick\" -lt 1 || \"$pick\" -gt ${#ciphers[@]} ]]; then\n        echo -e \"[${red}Error${plain}] Please enter a number between 1 and ${#ciphers[@]}\"\n        continue\n    fi\n    shadowsockscipher=${ciphers[$pick-1]}\n    echo\n    echo \"---------------------------\"\n    echo \"cipher = ${shadowsockscipher}\"\n    echo \"---------------------------\"\n    echo\n    break\n    done\n\n    echo\n    echo \"Press any key to start...or Press Ctrl+C to cancel\"\n    char=`get_char`\n    # Install necessary dependencies\n    if check_sys packageManager yum; then\n        yum install -y python python-devel python-setuptools openssl openssl-devel curl wget unzip gcc automake autoconf make libtool\n    elif check_sys packageManager apt; then\n        apt-get -y update\n        apt-get -y install python python-dev python-setuptools openssl libssl-dev curl wget unzip gcc automake autoconf make libtool\n    fi\n    cd ${cur_dir}\n}\n\n# Download files\ndownload_files(){\n    # Download libsodium file\n    if ! wget --no-check-certificate -O ${libsodium_file}.tar.gz ${libsodium_url}; then\n        echo -e \"[${red}Error${plain}] Failed to download ${libsodium_file}.tar.gz!\"\n        exit 1\n    fi\n    # Download Shadowsocks file\n    if ! wget --no-check-certificate -O shadowsocks-master.zip https://github.com/shadowsocks/shadowsocks/archive/master.zip; then\n        echo -e \"[${red}Error${plain}] Failed to download shadowsocks python file!\"\n        exit 1\n    fi\n    # Download Shadowsocks init script\n    if check_sys packageManager yum; then\n        if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks -O /etc/init.d/shadowsocks; then\n            echo -e \"[${red}Error${plain}] Failed to download shadowsocks chkconfig file!\"\n            exit 1\n        fi\n    elif check_sys packageManager apt; then\n        if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-debian -O /etc/init.d/shadowsocks; then\n            echo -e \"[${red}Error${plain}] Failed to download shadowsocks chkconfig file!\"\n            exit 1\n        fi\n    fi\n}\n\n# Config shadowsocks\nconfig_shadowsocks(){\n    cat > /etc/shadowsocks.json<<-EOF\n{\n    \"server\":\"0.0.0.0\",\n    \"server_port\":${shadowsocksport},\n    \"local_address\":\"127.0.0.1\",\n    \"local_port\":1080,\n    \"password\":\"${shadowsockspwd}\",\n    \"timeout\":300,\n    \"method\":\"${shadowsockscipher}\",\n    \"fast_open\":false\n}\nEOF\n}\n\n# Firewall set\nfirewall_set(){\n    echo -e \"[${green}Info${plain}] firewall set start...\"\n    if centosversion 6; then\n        /etc/init.d/iptables status > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            iptables -L -n | grep -i ${shadowsocksport} > /dev/null 2>&1\n            if [ $? -ne 0 ]; then\n                iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${shadowsocksport} -j ACCEPT\n                iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${shadowsocksport} -j ACCEPT\n                /etc/init.d/iptables save\n                /etc/init.d/iptables restart\n            else\n                echo -e \"[${green}Info${plain}] port ${shadowsocksport} has already been set up.\"\n            fi\n        else\n            echo -e \"[${yellow}Warning${plain}] iptables looks like shutdown or not installed, please manually set it if necessary.\"\n        fi\n    elif centosversion 7; then\n        systemctl status firewalld > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            default_zone=$(firewall-cmd --get-default-zone)\n            firewall-cmd --permanent --zone=${default_zone} --add-port=${shadowsocksport}/tcp\n            firewall-cmd --permanent --zone=${default_zone} --add-port=${shadowsocksport}/udp\n            firewall-cmd --reload\n        else\n            echo -e \"[${yellow}Warning${plain}] firewalld looks like not running or not installed, please enable port ${shadowsocksport} manually if necessary.\"\n        fi\n    fi\n    echo -e \"[${green}Info${plain}] firewall set completed...\"\n}\n\n# Install Shadowsocks\ninstall(){\n    # Install libsodium\n    if [ ! -f /usr/lib/libsodium.a ]; then\n        cd ${cur_dir}\n        tar zxf ${libsodium_file}.tar.gz\n        cd ${libsodium_file}\n        ./configure --prefix=/usr && make && make install\n        if [ $? -ne 0 ]; then\n            echo -e \"[${red}Error${plain}] libsodium install failed!\"\n            install_cleanup\n            exit 1\n        fi\n    fi\n\n    ldconfig\n    # Install Shadowsocks\n    cd ${cur_dir}\n    unzip -q shadowsocks-master.zip\n    if [ $? -ne 0 ];then\n        echo -e \"[${red}Error${plain}] unzip shadowsocks-master.zip failed! please check unzip command.\"\n        install_cleanup\n        exit 1\n    fi\n\n    cd ${cur_dir}/shadowsocks-master\n    python setup.py install --record /usr/local/shadowsocks_install.log\n\n    if [ -f /usr/bin/ssserver ] || [ -f /usr/local/bin/ssserver ]; then\n        chmod +x /etc/init.d/shadowsocks\n        if check_sys packageManager yum; then\n            chkconfig --add shadowsocks\n            chkconfig shadowsocks on\n        elif check_sys packageManager apt; then\n            update-rc.d -f shadowsocks defaults\n        fi\n        /etc/init.d/shadowsocks start\n    else\n        echo\n        echo -e \"[${red}Error${plain}] Shadowsocks install failed! please visit https://teddysun.com/342.html and contact.\"\n        install_cleanup\n        exit 1\n    fi\n\n    clear\n    echo\n    echo -e \"Congratulations, Shadowsocks-python server install completed!\"\n    echo -e \"Your Server IP        : \\033[41;37m $(get_ip) \\033[0m\"\n    echo -e \"Your Server Port      : \\033[41;37m ${shadowsocksport} \\033[0m\"\n    echo -e \"Your Password         : \\033[41;37m ${shadowsockspwd} \\033[0m\"\n    echo -e \"Your Encryption Method: \\033[41;37m ${shadowsockscipher} \\033[0m\"\n    echo\n    echo \"Welcome to visit:https://teddysun.com/342.html\"\n    echo \"Enjoy it!\"\n    echo\n}\n\n# Install cleanup\ninstall_cleanup(){\n    cd ${cur_dir}\n    rm -rf shadowsocks-master.zip shadowsocks-master ${libsodium_file}.tar.gz ${libsodium_file}\n}\n\n# Uninstall Shadowsocks\nuninstall_shadowsocks(){\n    printf \"Are you sure uninstall Shadowsocks? (y/n) \"\n    printf \"\\n\"\n    read -p \"(Default: n):\" answer\n    [ -z ${answer} ] && answer=\"n\"\n    if [ \"${answer}\" == \"y\" ] || [ \"${answer}\" == \"Y\" ]; then\n        ps -ef | grep -v grep | grep -i \"ssserver\" > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            /etc/init.d/shadowsocks stop\n        fi\n        if check_sys packageManager yum; then\n            chkconfig --del shadowsocks\n        elif check_sys packageManager apt; then\n            update-rc.d -f shadowsocks remove\n        fi\n        # delete config file\n        rm -f /etc/shadowsocks.json\n        rm -f /var/run/shadowsocks.pid\n        rm -f /etc/init.d/shadowsocks\n        rm -f /var/log/shadowsocks.log\n        if [ -f /usr/local/shadowsocks_install.log ]; then\n            cat /usr/local/shadowsocks_install.log | xargs rm -rf\n        fi\n        echo \"Shadowsocks uninstall success!\"\n    else\n        echo\n        echo \"uninstall cancelled, nothing to do...\"\n        echo\n    fi\n}\n\n# Install Shadowsocks-python\ninstall_shadowsocks(){\n    disable_selinux\n    pre_install\n    download_files\n    config_shadowsocks\n    if check_sys packageManager yum; then\n        firewall_set\n    fi\n    install\n    install_cleanup\n}\n\n# Initialization step\naction=$1\n[ -z $1 ] && action=install\ncase \"$action\" in\n    install|uninstall)\n        ${action}_shadowsocks\n        ;;\n    *)\n        echo \"Arguments error! [${action}]\"\n        echo \"Usage: `basename $0` [install|uninstall]\"\n    ;;\nesac\n"
  },
  {
    "path": "shadowsocksR",
    "content": "#!/bin/bash\n# chkconfig: 2345 90 10\n# description: A secure socks5 proxy, designed to protect your Internet traffic.\n\n### BEGIN INIT INFO\n# Provides:          ShadowsocksR\n# Required-Start:    $network $syslog\n# Required-Stop:     $network\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: Fast tunnel proxy that helps you bypass firewalls\n# Description:       Start or stop the ShadowsocksR server\n### END INIT INFO\n\n# Author: Teddysun <i@teddysun.com>\n\nNAME=ShadowsocksR\nDAEMON=/usr/local/shadowsocks/server.py\nif [ -f /etc/shadowsocks-r/config.json ]; then\n    CONF=/etc/shadowsocks-r/config.json\nelif [ -f /etc/shadowsocks.json ]; then\n    CONF=/etc/shadowsocks.json\nfi\nRETVAL=0\n\ncheck_running(){\n    PID=$(ps -ef | grep -v grep | grep -i \"${DAEMON}\" | awk '{print $2}')\n    if [ -n \"$PID\" ]; then\n        return 0\n    else\n        return 1\n    fi\n}\n\ndo_start(){\n    check_running\n    if [ $? -eq 0 ]; then\n        echo \"$NAME (pid $PID) is already running...\"\n        exit 0\n    else\n        $DAEMON -c $CONF -d start\n        RETVAL=$?\n        if [ $RETVAL -eq 0 ]; then\n            echo \"Starting $NAME success\"\n        else\n            echo \"Starting $NAME failed\"\n        fi\n    fi\n}\n\ndo_stop(){\n    check_running\n    if [ $? -eq 0 ]; then\n        $DAEMON -c $CONF -d stop\n        RETVAL=$?\n        if [ $RETVAL -eq 0 ]; then\n            echo \"Stopping $NAME success\"\n        else\n            echo \"Stopping $NAME failed\"\n        fi\n    else\n        echo \"$NAME is stopped\"\n        RETVAL=1\n    fi\n}\n\ndo_status(){\n    check_running\n    if [ $? -eq 0 ]; then\n        echo \"$NAME (pid $PID) is running...\"\n    else\n        echo \"$NAME is stopped\"\n        RETVAL=1\n    fi\n}\n\ndo_restart(){\n    do_stop\n    sleep 0.5\n    do_start\n}\n\ncase \"$1\" in\n    start|stop|restart|status)\n    do_$1\n    ;;\n    *)\n    echo \"Usage: $0 { start | stop | restart | status }\"\n    RETVAL=1\n    ;;\nesac\n\nexit $RETVAL\n"
  },
  {
    "path": "shadowsocksR-debian",
    "content": "#!/bin/bash\n\n### BEGIN INIT INFO\n# Provides:          ShadowsocksR\n# Required-Start:    $network $local_fs $remote_fs\n# Required-Stop:     $network $local_fs $remote_fs\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: Fast tunnel proxy that helps you bypass firewalls\n# Description:       Start or stop the ShadowsocksR server\n### END INIT INFO\n\n# Author: Teddysun <i@teddysun.com>\n\nNAME=ShadowsocksR\nDAEMON=/usr/local/shadowsocks/server.py\nif [ -f /etc/shadowsocks-r/config.json ]; then\n    CONF=/etc/shadowsocks-r/config.json\nelif [ -f /etc/shadowsocks.json ]; then\n    CONF=/etc/shadowsocks.json\nfi\nRETVAL=0\n\ncheck_running(){\n    PID=$(ps -ef | grep -v grep | grep -i \"${DAEMON}\" | awk '{print $2}')\n    if [ -n \"$PID\" ]; then\n        return 0\n    else\n        return 1\n    fi\n}\n\ndo_start(){\n    check_running\n    if [ $? -eq 0 ]; then\n        echo \"$NAME (pid $PID) is already running...\"\n        exit 0\n    else\n        $DAEMON -c $CONF -d start\n        RETVAL=$?\n        if [ $RETVAL -eq 0 ]; then\n            echo \"Starting $NAME success\"\n        else\n            echo \"Starting $NAME failed\"\n        fi\n    fi\n}\n\ndo_stop(){\n    check_running\n    if [ $? -eq 0 ]; then\n        $DAEMON -c $CONF -d stop\n        RETVAL=$?\n        if [ $RETVAL -eq 0 ]; then\n            echo \"Stopping $NAME success\"\n        else\n            echo \"Stopping $NAME failed\"\n        fi\n    else\n        echo \"$NAME is stopped\"\n        RETVAL=1\n    fi\n}\n\ndo_status(){\n    check_running\n    if [ $? -eq 0 ]; then\n        echo \"$NAME (pid $PID) is running...\"\n    else\n        echo \"$NAME is stopped\"\n        RETVAL=1\n    fi\n}\n\ndo_restart(){\n    do_stop\n    sleep 0.5\n    do_start\n}\n\ncase \"$1\" in\n    start|stop|restart|status)\n    do_$1\n    ;;\n    *)\n    echo \"Usage: $0 { start | stop | restart | status }\"\n    RETVAL=1\n    ;;\nesac\n\nexit $RETVAL\n"
  },
  {
    "path": "shadowsocksR.sh",
    "content": "#!/usr/bin/env bash\nPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin\nexport PATH\n#=================================================================#\n#   System Required:  CentOS 6,7, Debian, Ubuntu                  #\n#   Description: One click Install ShadowsocksR Server            #\n#   Author: Teddysun <i@teddysun.com>                             #\n#   Thanks: @breakwa11 <https://twitter.com/breakwa11>            #\n#   Intro:  https://shadowsocks.be/9.html                         #\n#=================================================================#\n\nclear\necho\necho \"#############################################################\"\necho \"# One click Install ShadowsocksR Server                     #\"\necho \"# Intro: https://shadowsocks.be/9.html                      #\"\necho \"# Author: Teddysun <i@teddysun.com>                         #\"\necho \"# Github: https://github.com/shadowsocksr/shadowsocksr      #\"\necho \"#############################################################\"\necho\n\nlibsodium_file=\"libsodium-1.0.18\"\nlibsodium_url=\"https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz\"\nshadowsocks_r_file=\"shadowsocksr-3.2.2\"\nshadowsocks_r_url=\"https://github.com/shadowsocksrr/shadowsocksr/archive/3.2.2.tar.gz\"\n\n#Current folder\ncur_dir=`pwd`\n# Stream Ciphers\nciphers=(\nnone\naes-256-cfb\naes-192-cfb\naes-128-cfb\naes-256-cfb8\naes-192-cfb8\naes-128-cfb8\naes-256-ctr\naes-192-ctr\naes-128-ctr\nchacha20-ietf\nchacha20\nsalsa20\nxchacha20\nxsalsa20\nrc4-md5\n)\n# Reference URL:\n# https://github.com/shadowsocksr-rm/shadowsocks-rss/blob/master/ssr.md\n# https://github.com/shadowsocksrr/shadowsocksr/commit/a3cf0254508992b7126ab1151df0c2f10bf82680\n# Protocol\nprotocols=(\norigin\nverify_deflate\nauth_sha1_v4\nauth_sha1_v4_compatible\nauth_aes128_md5\nauth_aes128_sha1\nauth_chain_a\nauth_chain_b\nauth_chain_c\nauth_chain_d\nauth_chain_e\nauth_chain_f\n)\n# obfs\nobfs=(\nplain\nhttp_simple\nhttp_simple_compatible\nhttp_post\nhttp_post_compatible\ntls1.2_ticket_auth\ntls1.2_ticket_auth_compatible\ntls1.2_ticket_fastauth\ntls1.2_ticket_fastauth_compatible\n)\n# Color\nred='\\033[0;31m'\ngreen='\\033[0;32m'\nyellow='\\033[0;33m'\nplain='\\033[0m'\n\n# Make sure only root can run our script\n[[ $EUID -ne 0 ]] && echo -e \"[${red}Error${plain}] This script must be run as root!\" && exit 1\n\n# Disable selinux\ndisable_selinux(){\n    if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then\n        sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config\n        setenforce 0\n    fi\n}\n\n#Check system\ncheck_sys(){\n    local checkType=$1\n    local value=$2\n\n    local release=''\n    local systemPackage=''\n\n    if [[ -f /etc/redhat-release ]]; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    elif grep -Eqi \"debian|raspbian\" /etc/issue; then\n        release=\"debian\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"ubuntu\" /etc/issue; then\n        release=\"ubuntu\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"centos|red hat|redhat\" /etc/issue; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    elif grep -Eqi \"debian|raspbian\" /proc/version; then\n        release=\"debian\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"ubuntu\" /proc/version; then\n        release=\"ubuntu\"\n        systemPackage=\"apt\"\n    elif grep -Eqi \"centos|red hat|redhat\" /proc/version; then\n        release=\"centos\"\n        systemPackage=\"yum\"\n    fi\n\n    if [[ \"${checkType}\" == \"sysRelease\" ]]; then\n        if [ \"${value}\" == \"${release}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    elif [[ \"${checkType}\" == \"packageManager\" ]]; then\n        if [ \"${value}\" == \"${systemPackage}\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    fi\n}\n\n# Get version\ngetversion(){\n    if [[ -s /etc/redhat-release ]]; then\n        grep -oE  \"[0-9.]+\" /etc/redhat-release\n    else\n        grep -oE  \"[0-9.]+\" /etc/issue\n    fi\n}\n\n# CentOS version\ncentosversion(){\n    if check_sys sysRelease centos; then\n        local code=$1\n        local version=\"$(getversion)\"\n        local main_ver=${version%%.*}\n        if [ \"$main_ver\" == \"$code\" ]; then\n            return 0\n        else\n            return 1\n        fi\n    else\n        return 1\n    fi\n}\n\n# Get public IP address\nget_ip(){\n    local IP=$( ip addr | egrep -o '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}' | egrep -v \"^192\\.168|^172\\.1[6-9]\\.|^172\\.2[0-9]\\.|^172\\.3[0-2]\\.|^10\\.|^127\\.|^255\\.|^0\\.\" | head -n 1 )\n    [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )\n    [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip )\n    [ ! -z ${IP} ] && echo ${IP} || echo\n}\n\nget_char(){\n    SAVEDSTTY=`stty -g`\n    stty -echo\n    stty cbreak\n    dd if=/dev/tty bs=1 count=1 2> /dev/null\n    stty -raw\n    stty echo\n    stty $SAVEDSTTY\n}\n\n# Pre-installation settings\npre_install(){\n    if check_sys packageManager yum || check_sys packageManager apt; then\n        # Not support CentOS 5\n        if centosversion 5; then\n            echo -e \"$[{red}Error${plain}] Not supported CentOS 5, please change to CentOS 6+/Debian 7+/Ubuntu 12+ and try again.\"\n            exit 1\n        fi\n    else\n        echo -e \"[${red}Error${plain}] Your OS is not supported. please change OS to CentOS/Debian/Ubuntu and try again.\"\n        exit 1\n    fi\n    # Set ShadowsocksR config password\n    echo \"Please enter password for ShadowsocksR:\"\n    read -p \"(Default password: teddysun.com):\" shadowsockspwd\n    [ -z \"${shadowsockspwd}\" ] && shadowsockspwd=\"teddysun.com\"\n    echo\n    echo \"---------------------------\"\n    echo \"password = ${shadowsockspwd}\"\n    echo \"---------------------------\"\n    echo\n    # Set ShadowsocksR config port\n    while true\n    do\n    dport=$(shuf -i 9000-19999 -n 1)\n    echo -e \"Please enter a port for ShadowsocksR [1-65535]\"\n    read -p \"(Default port: ${dport}):\" shadowsocksport\n    [ -z \"${shadowsocksport}\" ] && shadowsocksport=${dport}\n    expr ${shadowsocksport} + 1 &>/dev/null\n    if [ $? -eq 0 ]; then\n        if [ ${shadowsocksport} -ge 1 ] && [ ${shadowsocksport} -le 65535 ] && [ ${shadowsocksport:0:1} != 0 ]; then\n            echo\n            echo \"---------------------------\"\n            echo \"port = ${shadowsocksport}\"\n            echo \"---------------------------\"\n            echo\n            break\n        fi\n    fi\n    echo -e \"[${red}Error${plain}] Please enter a correct number [1-65535]\"\n    done\n\n    # Set shadowsocksR config stream ciphers\n    while true\n    do\n    echo -e \"Please select stream cipher for ShadowsocksR:\"\n    for ((i=1;i<=${#ciphers[@]};i++ )); do\n        hint=\"${ciphers[$i-1]}\"\n        echo -e \"${green}${i}${plain}) ${hint}\"\n    done\n    read -p \"Which cipher you'd select(Default: ${ciphers[1]}):\" pick\n    [ -z \"$pick\" ] && pick=2\n    expr ${pick} + 1 &>/dev/null\n    if [ $? -ne 0 ]; then\n        echo -e \"[${red}Error${plain}] Please enter a number\"\n        continue\n    fi\n    if [[ \"$pick\" -lt 1 || \"$pick\" -gt ${#ciphers[@]} ]]; then\n        echo -e \"[${red}Error${plain}] Please enter a number between 1 and ${#ciphers[@]}\"\n        continue\n    fi\n    shadowsockscipher=${ciphers[$pick-1]}\n    echo\n    echo \"---------------------------\"\n    echo \"cipher = ${shadowsockscipher}\"\n    echo \"---------------------------\"\n    echo\n    break\n    done\n\n    # Set shadowsocksR config protocol\n    while true\n    do\n    echo -e \"Please select protocol for ShadowsocksR:\"\n    for ((i=1;i<=${#protocols[@]};i++ )); do\n        hint=\"${protocols[$i-1]}\"\n        echo -e \"${green}${i}${plain}) ${hint}\"\n    done\n    read -p \"Which protocol you'd select(Default: ${protocols[0]}):\" protocol\n    [ -z \"$protocol\" ] && protocol=1\n    expr ${protocol} + 1 &>/dev/null\n    if [ $? -ne 0 ]; then\n        echo -e \"[${red}Error${plain}] Input error, please input a number\"\n        continue\n    fi\n    if [[ \"$protocol\" -lt 1 || \"$protocol\" -gt ${#protocols[@]} ]]; then\n        echo -e \"[${red}Error${plain}] Input error, please input a number between 1 and ${#protocols[@]}\"\n        continue\n    fi\n    shadowsockprotocol=${protocols[$protocol-1]}\n    echo\n    echo \"---------------------------\"\n    echo \"protocol = ${shadowsockprotocol}\"\n    echo \"---------------------------\"\n    echo\n    break\n    done\n\n    # Set shadowsocksR config obfs\n    while true\n    do\n    echo -e \"Please select obfs for ShadowsocksR:\"\n    for ((i=1;i<=${#obfs[@]};i++ )); do\n        hint=\"${obfs[$i-1]}\"\n        echo -e \"${green}${i}${plain}) ${hint}\"\n    done\n    read -p \"Which obfs you'd select(Default: ${obfs[0]}):\" r_obfs\n    [ -z \"$r_obfs\" ] && r_obfs=1\n    expr ${r_obfs} + 1 &>/dev/null\n    if [ $? -ne 0 ]; then\n        echo -e \"[${red}Error${plain}] Input error, please input a number\"\n        continue\n    fi\n    if [[ \"$r_obfs\" -lt 1 || \"$r_obfs\" -gt ${#obfs[@]} ]]; then\n        echo -e \"[${red}Error${plain}] Input error, please input a number between 1 and ${#obfs[@]}\"\n        continue\n    fi\n    shadowsockobfs=${obfs[$r_obfs-1]}\n    echo\n    echo \"---------------------------\"\n    echo \"obfs = ${shadowsockobfs}\"\n    echo \"---------------------------\"\n    echo\n    break\n    done\n\n    echo\n    echo \"Press any key to start...or Press Ctrl+C to cancel\"\n    char=`get_char`\n    # Install necessary dependencies\n    if check_sys packageManager yum; then\n        yum install -y python python-devel python-setuptools openssl openssl-devel curl wget unzip gcc automake autoconf make libtool\n    elif check_sys packageManager apt; then\n        apt-get -y update\n        apt-get -y install python python-dev python-setuptools openssl libssl-dev curl wget unzip gcc automake autoconf make libtool\n    fi\n    cd ${cur_dir}\n}\n\n# Download files\ndownload_files(){\n    # Download libsodium file\n    if ! wget --no-check-certificate -O ${libsodium_file}.tar.gz ${libsodium_url}; then\n        echo -e \"[${red}Error${plain}] Failed to download ${libsodium_file}.tar.gz!\"\n        exit 1\n    fi\n    # Download ShadowsocksR file\n    if ! wget --no-check-certificate -O ${shadowsocks_r_file}.tar.gz ${shadowsocks_r_url}; then\n        echo -e \"[${red}Error${plain}] Failed to download ShadowsocksR file!\"\n        exit 1\n    fi\n    # Download ShadowsocksR init script\n    if check_sys packageManager yum; then\n        if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocksR -O /etc/init.d/shadowsocks; then\n            echo -e \"[${red}Error${plain}] Failed to download ShadowsocksR chkconfig file!\"\n            exit 1\n        fi\n    elif check_sys packageManager apt; then\n        if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocksR-debian -O /etc/init.d/shadowsocks; then\n            echo -e \"[${red}Error${plain}] Failed to download ShadowsocksR chkconfig file!\"\n            exit 1\n        fi\n    fi\n}\n\n# Firewall set\nfirewall_set(){\n    echo -e \"[${green}Info${plain}] firewall set start...\"\n    if centosversion 6; then\n        /etc/init.d/iptables status > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            iptables -L -n | grep -i ${shadowsocksport} > /dev/null 2>&1\n            if [ $? -ne 0 ]; then\n                iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${shadowsocksport} -j ACCEPT\n                iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${shadowsocksport} -j ACCEPT\n                /etc/init.d/iptables save\n                /etc/init.d/iptables restart\n            else\n                echo -e \"[${green}Info${plain}] port ${shadowsocksport} has been set up.\"\n            fi\n        else\n            echo -e \"[${yellow}Warning${plain}] iptables looks like shutdown or not installed, please manually set it if necessary.\"\n        fi\n    elif centosversion 7; then\n        systemctl status firewalld > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            default_zone=$(firewall-cmd --get-default-zone)\n            firewall-cmd --permanent --zone=${default_zone} --add-port=${shadowsocksport}/tcp\n            firewall-cmd --permanent --zone=${default_zone} --add-port=${shadowsocksport}/udp\n            firewall-cmd --reload\n        else\n            echo -e \"[${yellow}Warning${plain}] firewalld looks like not running or not installed, please enable port ${shadowsocksport} manually if necessary.\"\n        fi\n    fi\n    echo -e \"[${green}Info${plain}] firewall set completed...\"\n}\n\n# Config ShadowsocksR\nconfig_shadowsocks(){\n    cat > /etc/shadowsocks.json<<-EOF\n{\n    \"server\":\"0.0.0.0\",\n    \"server_ipv6\":\"[::]\",\n    \"server_port\":${shadowsocksport},\n    \"local_address\":\"127.0.0.1\",\n    \"local_port\":1080,\n    \"password\":\"${shadowsockspwd}\",\n    \"timeout\":120,\n    \"method\":\"${shadowsockscipher}\",\n    \"protocol\":\"${shadowsockprotocol}\",\n    \"protocol_param\":\"\",\n    \"obfs\":\"${shadowsockobfs}\",\n    \"obfs_param\":\"\",\n    \"redirect\":\"\",\n    \"dns_ipv6\":false,\n    \"fast_open\":false,\n    \"workers\":1\n}\nEOF\n}\n\n# Install ShadowsocksR\ninstall(){\n    # Install libsodium\n    if [ ! -f /usr/lib/libsodium.a ]; then\n        cd ${cur_dir}\n        tar zxf ${libsodium_file}.tar.gz\n        cd ${libsodium_file}\n        ./configure --prefix=/usr && make && make install\n        if [ $? -ne 0 ]; then\n            echo -e \"[${red}Error${plain}] libsodium install failed!\"\n            install_cleanup\n            exit 1\n        fi\n    fi\n\n    ldconfig\n    # Install ShadowsocksR\n    cd ${cur_dir}\n    tar zxf ${shadowsocks_r_file}.tar.gz\n    mv ${shadowsocks_r_file}/shadowsocks /usr/local/\n    if [ -f /usr/local/shadowsocks/server.py ]; then\n        chmod +x /etc/init.d/shadowsocks\n        if check_sys packageManager yum; then\n            chkconfig --add shadowsocks\n            chkconfig shadowsocks on\n        elif check_sys packageManager apt; then\n            update-rc.d -f shadowsocks defaults\n        fi\n        /etc/init.d/shadowsocks start\n\n        clear\n        echo\n        echo -e \"Congratulations, ShadowsocksR server install completed!\"\n        echo -e \"Your Server IP        : \\033[41;37m $(get_ip) \\033[0m\"\n        echo -e \"Your Server Port      : \\033[41;37m ${shadowsocksport} \\033[0m\"\n        echo -e \"Your Password         : \\033[41;37m ${shadowsockspwd} \\033[0m\"\n        echo -e \"Your Protocol         : \\033[41;37m ${shadowsockprotocol} \\033[0m\"\n        echo -e \"Your obfs             : \\033[41;37m ${shadowsockobfs} \\033[0m\"\n        echo -e \"Your Encryption Method: \\033[41;37m ${shadowsockscipher} \\033[0m\"\n        echo\n        echo \"Welcome to visit:https://shadowsocks.be/9.html\"\n        echo \"Enjoy it!\"\n        echo\n    else\n        echo \"ShadowsocksR install failed, please Email to Teddysun <i@teddysun.com> and contact\"\n        install_cleanup\n        exit 1\n    fi\n}\n\n# Install cleanup\ninstall_cleanup(){\n    cd ${cur_dir}\n    rm -rf ${shadowsocks_r_file}.tar.gz ${shadowsocks_r_file} ${libsodium_file}.tar.gz ${libsodium_file}\n}\n\n\n# Uninstall ShadowsocksR\nuninstall_shadowsocksr(){\n    printf \"Are you sure uninstall ShadowsocksR? (y/n)\"\n    printf \"\\n\"\n    read -p \"(Default: n):\" answer\n    [ -z ${answer} ] && answer=\"n\"\n    if [ \"${answer}\" == \"y\" ] || [ \"${answer}\" == \"Y\" ]; then\n        /etc/init.d/shadowsocks status > /dev/null 2>&1\n        if [ $? -eq 0 ]; then\n            /etc/init.d/shadowsocks stop\n        fi\n        if check_sys packageManager yum; then\n            chkconfig --del shadowsocks\n        elif check_sys packageManager apt; then\n            update-rc.d -f shadowsocks remove\n        fi\n        rm -f /etc/shadowsocks.json\n        rm -f /etc/init.d/shadowsocks\n        rm -f /var/log/shadowsocks.log\n        rm -rf /usr/local/shadowsocks\n        echo \"ShadowsocksR uninstall success!\"\n    else\n        echo\n        echo \"uninstall cancelled, nothing to do...\"\n        echo\n    fi\n}\n\n# Install ShadowsocksR\ninstall_shadowsocksr(){\n    disable_selinux\n    pre_install\n    download_files\n    config_shadowsocks\n    if check_sys packageManager yum; then\n        firewall_set\n    fi\n    install\n    install_cleanup\n}\n\n# Initialization step\naction=$1\n[ -z $1 ] && action=install\ncase \"$action\" in\n    install|uninstall)\n        ${action}_shadowsocksr\n        ;;\n    *)\n        echo \"Arguments error! [${action}]\"\n        echo \"Usage: `basename $0` [install|uninstall]\"\n        ;;\nesac\n"
  }
]