1
0

install_ss-server.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/bin/bash
  2. # 定义文字颜色
  3. Green="\033[32m" && Red="\033[31m" && GreenBG="\033[42;37m" && RedBG="\033[41;37m" && Font="\033[0m"
  4. echo -e "${Green}:: 注意 快速安装 shadowsocks-libev 脚本 For debian 9 ${Font}"
  5. echo -e "${RedBG}:: Centos和Ubuntu系统,进行编译安装 ${RedBG} shadowsocks-libev ${Font}"
  6. echo -e "${Green}$ bash <(curl -L -s git.io/fhExJ) update ${Font}"
  7. debian_fast(){
  8. # 安装所需运行库
  9. apt update
  10. apt install -y libev-dev libc-ares-dev libmbedtls-dev libsodium-dev
  11. # 下载 ss-server
  12. wget https://raw.githubusercontent.com/hongwenjun/vps_setup/master/ss-server
  13. chmod +x ss-server && mv ss-server /usr/local/bin/ss-server
  14. }
  15. debian_ubuntu_dev(){
  16. # Debian 9 & Ubuntu 安装编译环境和运行库
  17. apt update
  18. apt install -y gcc g++ git gettext build-essential autoconf libtool libpcre3-dev asciidoc xmlto libev-dev libc-ares-dev automake libmbedtls-dev libsodium-dev
  19. }
  20. centos7_dev(){
  21. # Cetons 安装编译环境和运行库
  22. yum install epel-release git -y
  23. yum install gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto c-ares-devel libev-devel libsodium-devel mbedtls-devel -y
  24. }
  25. inst_ss-server(){
  26. # 下载shadowsocks代码
  27. git clone https://github.com/shadowsocks/shadowsocks-libev.git
  28. cd shadowsocks-libev
  29. git submodule update --init --recursive
  30. # 编译安装ss-server
  31. ./autogen.sh
  32. ./configure
  33. make
  34. make install
  35. cd ..
  36. rm shadowsocks-libev -rf
  37. }
  38. # 检查系统
  39. check_sys(){
  40. if [[ -f /etc/redhat-release ]]; then
  41. release="centos"
  42. elif cat /etc/issue | grep -q -E -i "debian"; then
  43. release="debian"
  44. elif cat /etc/issue | grep -q -E -i "ubuntu"; then
  45. release="ubuntu"
  46. elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
  47. release="centos"
  48. elif cat /proc/version | grep -q -E -i "debian"; then
  49. release="debian"
  50. elif cat /proc/version | grep -q -E -i "ubuntu"; then
  51. release="ubuntu"
  52. elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
  53. release="centos"
  54. fi
  55. bit=`uname -m`
  56. }
  57. sysctl_config() {
  58. sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
  59. sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
  60. echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf
  61. echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.conf
  62. sysctl -p >/dev/null 2>&1
  63. }
  64. # 开启 BBR
  65. sysctl_config
  66. lsmod | grep bbr
  67. # 判断系统安装软件
  68. install_ss-server(){
  69. if [[ ${release} == "centos" ]]; then
  70. centos7_dev
  71. inst_ss-server
  72. fi
  73. if [[ ${release} == "ubuntu" ]]; then
  74. debian_ubuntu_dev
  75. inst_ss-server
  76. fi
  77. if [[ ${release} == "debian" ]]; then
  78. debian_ubuntu_dev
  79. inst_ss-server
  80. fi
  81. }
  82. def_install(){
  83. if [[ ${release} == "debian" ]]; then
  84. debian_fast
  85. else
  86. install_ss-server
  87. fi
  88. }
  89. # 安装 ss-server
  90. check_sys
  91. if [[ $# > 0 ]]; then
  92. key="$1"
  93. case $key in
  94. update)
  95. install_ss-server
  96. ;;
  97. esac
  98. else
  99. if [ ! -f '/usr/local/bin/ss-server' ]; then
  100. def_install
  101. fi
  102. fi