Last active
May 18, 2018 02:30
-
-
Save tiancheng91/20621c76c2301ab64eb69cc911a6af1e to your computer and use it in GitHub Desktop.
shadowsocks init
This file contains 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 | |
""" | |
install: | |
curl -L git.io/shadow | bash -s password 23 | |
- password: 自定义ss密码,默认为 tun_host | |
- 23: 自定义端口号,默认为23 | |
help: | |
`https://gist.github.com/tiancheng91/20621c76c2301ab64eb69cc911a6af1e` | |
""" | |
set -e | |
# 设置密码 | |
if [ $1 ];then | |
password=$1 | |
else | |
password="tun_host" | |
fi | |
# 设置端口号 | |
if [ $2 ];then | |
port=$2 | |
else | |
port=23 | |
fi | |
# gost版本 | |
version=$(uname -m) | |
if [ "$version" = "x86_64" ]; then | |
version="gost_2.5_linux_amd64" | |
else | |
version="gost_2.5_linux_386" | |
fi | |
# 安装gost | |
download=https://github.com/ginuerzh/gost/releases/download/v2.5/"$version".tar.gz | |
wget $download || curl $download > "$version".tar.gz | |
tar -zxf "$version".tar.gz && mv "$version"/gost /usr/local/bin/ | |
chmod a+x /usr/local/bin/gost | |
# 添加开机自启 | |
echo "#!/bin/sh | |
/usr/bin/nohup /usr/local/bin/gost -L=ss://aes-256-cfb:${password}@:${port} > /dev/null 2>&1 & | |
exit 0 | |
" > /etc/rc.local | |
chmod a+x /etc/rc.local | |
# 尝试启用bbr | |
set +e | |
modprobe tcp_bbr | |
if [ $? -eq 0 ]; then | |
echo 'bbr enabled' | |
echo "tcp_bbr" >> /etc/modules-load.d/modules.conf | |
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf | |
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf | |
sysctl -p | |
fi | |
# ss连接信息 | |
address=$(curl http://ip.42.pl/short) | |
echo "安装成功, ss连接信息: ss://aes-256-cfb:${password}@${address}:${port}" | |
# 启动 | |
bash /etc/rc.local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment