Forked from NNdroid/hev-socks5-tunnel-installer.sh
Created
December 24, 2025 13:38
-
-
Save svenyurgensson/4fdf5e8d520c789027b5f40f27af2311 to your computer and use it in GitHub Desktop.
hev-socks5-tunnel installer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| RELEASE_API="https://api.github.com/repos/heiher/hev-socks5-tunnel/releases/latest" | |
| BIN_DST_DIR=/usr/local/bin | |
| RESOURCE_DST_DIR=/usr/local/etc/hev-socks5-tunnel | |
| function getReleaseInfo() { | |
| response=$(curl ${RELEASE_API}) | |
| if [ $? == 0 ]; then | |
| echo $response | |
| return 0 | |
| else | |
| return 1 | |
| fi | |
| } | |
| function check_error() { | |
| if [ $? == 1 ]; then | |
| echo $1 | |
| exit 1 | |
| fi | |
| } | |
| function install() { | |
| assetDownloadUrl=$(curl $RELEASE_API | jq -r ".assets[] | select(.name == \"hev-socks5-tunnel-linux-x86_64\") | .browser_download_url") | |
| echo $assetDownloadUrl | |
| wget -O ${BIN_DST_DIR}/hev-socks5-tunnel $assetDownloadUrl | |
| check_error "download binary error!" | |
| chmod +x ${BIN_DST_DIR}/hev-socks5-tunnel | |
| mkdir $RESOURCE_DST_DIR | |
| cat << EOT > ${RESOURCE_DST_DIR}/config.yml | |
| tunnel: | |
| # Interface name | |
| name: tun0 | |
| # Interface MTU | |
| mtu: 8500 | |
| # Multi-queue | |
| multi-queue: false | |
| # IPv4 address | |
| ipv4: 198.18.0.1 | |
| # IPv6 address | |
| ipv6: 'fc00::1' | |
| socks5: | |
| # Socks5 server port | |
| port: 1080 | |
| # Socks5 server address (ipv4/ipv6) | |
| address: 127.0.0.1 | |
| # Socks5 UDP relay mode (tcp|udp) | |
| udp: 'udp' | |
| # Socks5 server username | |
| # username: 'username' | |
| # Socks5 server password | |
| # password: 'password' | |
| #misc: | |
| # task stack size (bytes) | |
| # task-stack-size: 20480 | |
| # connect timeout (ms) | |
| # connect-timeout: 5000 | |
| # read-write timeout (ms) | |
| # read-write-timeout: 60000 | |
| # stdout, stderr or file-path | |
| # log-file: stderr | |
| # debug, info, warn or error | |
| # log-level: warn | |
| # If present, run as a daemon with this pid file | |
| # pid-file: /run/hev-socks5-tunnel.pid | |
| # If present, set rlimit nofile; else use default value | |
| # limit-nofile: 65535 | |
| EOT | |
| cat << EOT > /etc/systemd/system/hev-socks5-tunnel.service | |
| [unit] | |
| Description=hev-socks5-tunnel | |
| Wants=network.target | |
| After=syslog.target network-online.target | |
| [Service] | |
| Type=simple | |
| Environment=GOGC=20 | |
| ExecStart=${BIN_DST_DIR}/hev-socks5-tunnel ${RESOURCE_DST_DIR}/config.yml | |
| Restart=on-failure | |
| RestartSec=10 | |
| KillMode=process | |
| LimitNOFILE=65535 | |
| [Install] | |
| WantedBy=multi-user.target | |
| EOT | |
| systemctl enable --now hev-socks5-tunnel | |
| clear | |
| echo "finished" | |
| } | |
| function remove() { | |
| systemctl stop hev-socks5-tunnel | |
| systemctl disable hev-socks5-tunnel | |
| rm -rf /etc/systemd/system/hev-socks5-tunnel.service | |
| rm -rf ${BIN_DST_DIR}/hev-socks5-tunnel | |
| rm -rf $RESOURCE_DST_DIR | |
| clear | |
| echo "remove finished!" | |
| } | |
| function help() { | |
| cat << EOF | |
| hev-socks5-server install helper!!! | |
| usage: | |
| ./hev-socks5-tunnel.sh menu | |
| install: install hev-socks5-tunnel | |
| remove: remove hev-socks5-tunnel | |
| EOF | |
| } | |
| function main() { | |
| if [ $# -lt 1 ]; then | |
| help | |
| else | |
| case $1 in | |
| install) | |
| install | |
| ;; | |
| remove) | |
| remove | |
| ;; | |
| *) | |
| echo 'command not found!' | |
| help | |
| ;; | |
| esac | |
| fi | |
| exit 0 | |
| } | |
| main $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment