1. #! /bin/bash
  2. [ -z `ls /etc/yum.repos.d/epel.repo` ] && echo '
  3. [epel]
  4. name=Extra Packages for Enterprise Linux 7 - $basearch
  5. baseurl=http://mirrors.aliyun.com/epel/7/$basearch
  6. http://mirrors.aliyuncs.com/epel/7/$basearch
  7. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
  8. failovermethod=priority
  9. enabled=1
  10. gpgcheck=0
  11. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  12. [epel-debuginfo]
  13. name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
  14. baseurl=http://mirrors.aliyun.com/epel/7/$basearch/debug
  15. http://mirrors.aliyuncs.com/epel/7/$basearch/debug
  16. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
  17. failovermethod=priority
  18. enabled=0
  19. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  20. gpgcheck=0
  21. [epel-source]
  22. name=Extra Packages for Enterprise Linux 7 - $basearch - Source
  23. baseurl=http://mirrors.aliyun.com/epel/7/SRPMS
  24. http://mirrors.aliyuncs.com/epel/7/SRPMS
  25. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
  26. failovermethod=priority
  27. enabled=0
  28. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  29. gpgcheck=0
  30. ' >/etc/yum.repos.d/epel.repo
  31. setuptools=`rpm -qa python-setuptools`
  32. python_version=`rpm -qa python | awk -F '-' '{print $2}'`
  33. [ "${python_version%%.*}" -eq 2 ] && { [ -z "$setuptools" ] && yum install -y python-setuptools &>/dev/null ; echo ''>/dev/null; } && easy_install pip &>/dev/null && pip install shadowsocks &>/dev/null
  34. echo '
  35. [Unit]
  36. Description=Shadowsocks Client Service
  37. After=network.target
  38. [Service]
  39. Type=simple
  40. User=root
  41. ExecStart=/usr/bin/sslocal -c /etc/shadowsocks.json
  42. [Install]
  43. WantedBy=multi-user.target' >/etc/systemd/system/shadowsocks.service
  44. #etc
  45. echo '
  46. {
  47. "server": "172.96.206.71",
  48. "local_port": 1080,
  49. "server_port": 443,
  50. "password": "NjU5YmRmNT",
  51. "timeout": 300,
  52. "method": "aes-256-cfb"
  53. }
  54. '>/etc/shadowsocks.json
  55. yum install -y privoxy
  56. echo 'forward-socks5t / 127.0.0.1:1080 .' >>/etc/privoxy/config
  57. #setup script
  58. echo '#! /bin/bash
  59. systemctl start shadowsocks.service
  60. export https_proxy=http://127.0.0.1:8118
  61. export http_proxy=http://127.0.0.1:8118
  62. export ftp_proxy=http://127.0.0.1:8118
  63. systemctl start privoxy
  64. ' >/usr/bin/startss
  65. echo '#! /bin/bash
  66. systemctl stop privoxy
  67. export https_proxy=""
  68. export http_proxy=""
  69. export ftp_proxy=""
  70. systemctl stop shadowsocks.service
  71. ' >/usr/bin/stopss
  72. echo '#! /bin/bash
  73. rm -rf /etc/shadowsocks.json
  74. rm -rf `ls -l /proc/$$/fd/255|cut -d' ' -f12- | awk '{print $2}'`
  75. ' >/usr/bin/destroyss
  76. chmod 700 /usr/bin/startss
  77. chmod 700 /usr/bin/stopss
  78. chmod 700 /usr/bin/destroyss
  79. rm -rf `ls -l /proc/$$/fd/255|cut -d' ' -f12- | awk '{print $2}'`
文档更新时间: 2018-12-12 20:55   作者:张尚