-
-
Save khorevaa/89e62f18f2dbe84ee5579e35ce087dd5 to your computer and use it in GitHub Desktop.
Server scripts for installations
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/sh | |
# Check whether apt-get support https | |
[ -e /usr/lib/apt/methods/https ] || { | |
apt-get update | |
apt-get install apt-transport-https | |
} | |
# Add offical key | |
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 | |
# Add docker repository to apt source list | |
sudo sh -c "echo deb https://get.docker.com/ubuntu docker main\ | |
> /etc/apt/sources.list.d/docker.list" | |
# Install Docker | |
apt-get update | |
apt-get install -y lxc-docker |
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/sh | |
# Install Python PIP & Supervisor | |
apt-get install -y python-pip python-m2crypto supervisor | |
# Install Shadowsocks | |
pip install shadowsocks | |
# Create Shadowsocks config file | |
cat << EOF > /etc/shadowsocks.json | |
{ | |
"server":"server_ip", | |
"local_port":1080, | |
"port_password": { | |
"8387": "foobar", | |
"8388": "barfoo" | |
}, | |
"timeout":120, | |
"method":"rc4-md5", | |
"fast_open": true, | |
"workers": 1 | |
} | |
EOF | |
# Get the IP from eth0 | |
IP=`ifconfig | sed -rn '/eth0/n;s/.*dr:([0-9.]+) .*/\1/p;q'` | |
# Update IP in Shadowsocks config file | |
sed -i "s/server_ip/$IP/g" /etc/shadowsocks.json | |
# Create Shadowsocks config file for supervisor | |
cat << EOF > /etc/supervisor/conf.d/shadowsocks.conf | |
[program:shadowsocks] | |
command=ssserver -c /etc/shadowsocks.json | |
autorestart=true | |
user=root | |
EOF | |
# Optimize | |
echo ulimit -n 51200 >> /etc/default/supervisor | |
cat << EOF >> /etc/security/limits.conf | |
* soft nofile 51200 | |
* hard nofile 51200 | |
EOF | |
cat << EOF >> /etc/sysctl.conf | |
fs.file-max = 51200 | |
net.core.rmem_max = 67108864 | |
net.core.wmem_max = 67108864 | |
net.core.netdev_max_backlog = 250000 | |
net.core.somaxconn = 4096 | |
net.ipv4.tcp_syncookies = 1 | |
net.ipv4.tcp_tw_reuse = 1 | |
net.ipv4.tcp_tw_recycle = 0 | |
net.ipv4.tcp_fin_timeout = 30 | |
net.ipv4.tcp_keepalive_time = 1200 | |
net.ipv4.ip_local_port_range = 10000 65000 | |
net.ipv4.tcp_max_syn_backlog = 8192 | |
net.ipv4.tcp_max_tw_buckets = 5000 | |
net.ipv4.tcp_fastopen = 3 | |
net.ipv4.tcp_mem = 25600 51200 102400 | |
net.ipv4.tcp_rmem = 4096 87380 67108864 | |
net.ipv4.tcp_wmem = 4096 65536 67108864 | |
net.ipv4.tcp_mtu_probing = 1 | |
net.ipv4.tcp_congestion_control = hybla | |
EOF | |
sysctl -p | |
# Restart Supervisor | |
service supervisor restart | |
supervisorctl reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment