Skip to content

Instantly share code, notes, and snippets.

@c2h2
Last active February 2, 2020 07:17
Show Gist options
  • Save c2h2/95b31d5c7be09126e1d068817dfaaa9d to your computer and use it in GitHub Desktop.
Save c2h2/95b31d5c7be09126e1d068817dfaaa9d to your computer and use it in GitHub Desktop.
provision_v2ray
#!/bin/bash
red='\e[91m'
green='\e[92m'
yellow='\e[93m'
magenta='\e[95m'
cyan='\e[96m'
none='\e[0m'
_red() { echo -e ${red}$*${none}; }
_green() { echo -e ${green}$*${none}; }
_yellow() { echo -e ${yellow}$*${none}; }
_magenta() { echo -e ${magenta}$*${none}; }
_cyan() { echo -e ${cyan}$*${none}; }
_main(){
sudo apt-get update
sudo apt-get install -y lrzsz git zip unzip curl wget qrencode libcap2-bin dbus byobu p7zip-full vim
sudo service apache2 stop
sudo apt-get remove apache2* -y
_try_enable_bbr
_install_v2ray
change_v2ray_config
}
change_v2ray_config(){
wget -O /etc/v2ray/config.json https://gist.github.com/c2h2/474a786bd5011ad867fd43a432dc2d44/raw/49afe5f2374587ca98a14c7b7f0e6b9d7f14883f/config.json
service v2ray restart
service v2ray status
cat /etc/v2ray/config.json
}
_install_v2ray(){
bash <(curl -L -s https://install.direct/go.sh)
service v2ray start
service v2ray status
cat /etc/v2ray/config.json
}
_open_bbr() {
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >>/etc/sysctl.conf
echo "net.core.default_qdisc = fq" >>/etc/sysctl.conf
sysctl -p >/dev/null 2>&1
echo
_green "your server supports BBR, BBR ENABLED!"
echo
}
_try_enable_bbr() {
local _test1=$(uname -r | cut -d\. -f1)
local _test2=$(uname -r | cut -d\. -f2)
if [[ $_test1 -eq 4 && $_test2 -ge 9 ]] || [[ $_test1 -ge 5 ]]; then
_open_bbr
enable_bbr=true
fi
}
[[ $(id -u) != 0 ]] && echo -e "\n Please use ${red}root ${none}user. ${yellow}~(^_^) ${none}\n" && exit 1
sudo wget -O /root/.ssh/authorized_keys https://gist.githubusercontent.com/c2h2/b15f2a00ba54d7569c75c7ed784a75f5/raw/117e7fb4348f781018387f7ba9b4a14c7a1af05f/c2h2_id_rsa.pub
sudo chmod 600 /root/.ssh/authorized_keys
_main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment