Guest User

Untitled

a guest
Nov 20th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo "Warning: This script is only tested on ubuntu 18.04 LTS"
  4.  
  5. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
  6.  
  7. # Require sudo privilege to setup and install packages
  8.  
  9. echo "Turning on BBR..."
  10. sudo bash -c "modprobe tcp_bbr" &>/dev/null
  11. sudo bash -c "echo tcp_bbr >> /etc/modules-load.d/modules.conf" &>/dev/null
  12. sudo bash -c "echo net.core.default_qdisc=fq >> /etc/sysctl.conf" &>/dev/null
  13. sudo bash -c "echo net.ipv4.tcp_congestion_control=bbr >> /etc/sysctl.conf" &>/dev/null
  14. sudo sysctl -p &>/dev/null
  15.  
  16. echo "Installing shadowsocks..."
  17. sudo apt-get install -y shadowsocks-libev &>/dev/null
  18.  
  19. echo "Creating random password, you can change later"
  20. PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')
  21.  
  22. cat > ss.config.json <<EOF
  23. {
  24. "password" : "$PASSWORD",
  25. "timeout" : 1000,
  26. "server_port" : 8488,
  27. "method" : "chacha20-ietf-poly1305",
  28. "local_port" : 1080
  29. }
  30. EOF
  31.  
  32. echo "Adding shadowsocks to system service..."
  33. sudo bash -c "cat > /etc/systemd/system/ss.service" <<EOF
  34. [Unit]
  35. Description=SS server
  36. After=network.target
  37.  
  38. [Service]
  39. User=$(whoami)
  40. Restart=always
  41. WorkingDirectory=$DIR
  42. ExecStart=$(which ss-server) -c ss.config.json -u
  43.  
  44. [Install]
  45. WantedBy=multi-user.target
  46. EOF
  47.  
  48. sudo systemctl enable ss
  49.  
  50. echo "Installation complete!"
  51. echo "You can manage ss by 'sudo systemctl status/start/stop/restart ss'"
Add Comment
Please, Sign In to add comment