1. 秋水的一键安装脚本
  1. #!/usr/bin/env bash
  2. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
  3. export PATH
  4. #
  5. # Auto install Shadowsocks Server (all version)
  6. #
  7. # Copyright (C) - Teddysun <i@teddysun.com>
  8. #
  9. # System Required: CentOS +, Debian7+, Ubuntu12+
  10. #
  11. # Reference URL:
  12. # https://github.com/shadowsocks/shadowsocks
  13. # https://github.com/shadowsocks/shadowsocks-go
  14. # https://github.com/shadowsocks/shadowsocks-libev
  15. # https://github.com/shadowsocks/shadowsocks-windows
  16. # https://github.com/shadowsocksr-rm/shadowsocksr
  17. # https://github.com/shadowsocksrr/shadowsocksr
  18. # https://github.com/shadowsocksrr/shadowsocksr-csharp
  19. #
  20. # Thanks:
  21. # @clowwindy <https://twitter.com/clowwindy>
  22. # @breakwa11 <https://twitter.com/breakwa11>
  23. # @cyfdecyf <https://twitter.com/cyfdecyf>
  24. # @madeye <https://github.com/madeye>
  25. # @linusyang <https://github.com/linusyang>
  26. # @Akkariiin <https://github.com/Akkariiin>
  27. #
  28. # Intro: https://teddysun.com/486.html
  29.  
  30. red='\033[0;31m'
  31. green='\033[0;32m'
  32. yellow='\033[0;33m'
  33. plain='\033[0m'
  34.  
  35. [[ $EUID -ne ]] &&
  36.  
  37. cur_dir=$( pwd )
  38. software=(Shadowsocks-Python ShadowsocksR Shadowsocks-Go Shadowsocks-libev)
  39.  
  40. libsodium_file="libsodium-1.0.16"
  41. libsodium_url="https://github.com/jedisct1/libsodium/releases/download/1.0.16/libsodium-1.0.16.tar.gz"
  42.  
  43. mbedtls_file="mbedtls-2.12.0"
  44. mbedtls_url="https://tls.mbed.org/download/mbedtls-2.12.0-gpl.tgz"
  45.  
  46. shadowsocks_python_file="shadowsocks-master"
  47. shadowsocks_python_url="https://github.com/shadowsocks/shadowsocks/archive/master.zip"
  48. shadowsocks_python_init="/etc/init.d/shadowsocks-python"
  49. shadowsocks_python_config="/etc/shadowsocks-python/config.json"
  50. shadowsocks_python_centos="https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks"
  51. shadowsocks_python_debian="https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-debian"
  52.  
  53. shadowsocks_r_file="shadowsocksr-3.2.2"
  54. shadowsocks_r_url="https://github.com/shadowsocksrr/shadowsocksr/archive/3.2.2.tar.gz"
  55. shadowsocks_r_init="/etc/init.d/shadowsocks-r"
  56. shadowsocks_r_config="/etc/shadowsocks-r/config.json"
  57. shadowsocks_r_centos="https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocksR"
  58. shadowsocks_r_debian="https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocksR-debian"
  59.  
  60. shadowsocks_go_file_64="shadowsocks-server-linux64-1.2.1"
  61. shadowsocks_go_url_64="https://dl.lamp.sh/shadowsocks/shadowsocks-server-linux64-1.2.1.gz"
  62. shadowsocks_go_file_32="shadowsocks-server-linux32-1.2.1"
  63. shadowsocks_go_url_32="https://dl.lamp.sh/shadowsocks/shadowsocks-server-linux32-1.2.1.gz"
  64. shadowsocks_go_init="/etc/init.d/shadowsocks-go"
  65. shadowsocks_go_config="/etc/shadowsocks-go/config.json"
  66. shadowsocks_go_centos="https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-go"
  67. shadowsocks_go_debian="https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-go-debian"
  68.  
  69. shadowsocks_libev_init="/etc/init.d/shadowsocks-libev"
  70. shadowsocks_libev_config="/etc/shadowsocks-libev/config.json"
  71. shadowsocks_libev_centos="https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-libev"
  72. shadowsocks_libev_debian="https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-libev-debian"
  73.  
  74. # Stream Ciphers
  75. common_ciphers=(
  76. aes--gcm
  77. aes--gcm
  78. aes--gcm
  79. aes--ctr
  80. aes--ctr
  81. aes--ctr
  82. aes--cfb
  83. aes--cfb
  84. aes--cfb
  85. camellia--cfb
  86. camellia--cfb
  87. camellia--cfb
  88. xchacha20-ietf-poly1305
  89. chacha20-ietf-poly1305
  90. chacha20-ietf
  91. chacha20
  92. salsa20
  93. rc4-md5
  94. )
  95. go_ciphers=(
  96. aes--cfb
  97. aes--cfb
  98. aes--cfb
  99. aes--ctr
  100. aes--ctr
  101. aes--ctr
  102. chacha20-ietf
  103. chacha20
  104. salsa20
  105. rc4-md5
  106. )
  107. r_ciphers=(
  108. none
  109. aes--cfb
  110. aes--cfb
  111. aes--cfb
  112. aes--cfb8
  113. aes--cfb8
  114. aes--cfb8
  115. aes--ctr
  116. aes--ctr
  117. aes--ctr
  118. chacha20-ietf
  119. chacha20
  120. salsa20
  121. xchacha20
  122. xsalsa20
  123. rc4-md5
  124. )
  125. # Reference URL:
  126. # https://github.com/shadowsocksr-rm/shadowsocks-rss/blob/master/ssr.md
  127. # https://github.com/shadowsocksrr/shadowsocksr/commit/a3cf0254508992b7126ab1151df0c2f10bf82680
  128. # Protocol
  129. protocols=(
  130. origin
  131. verify_deflate
  132. auth_sha1_v4
  133. auth_sha1_v4_compatible
  134. auth_aes128_md5
  135. auth_aes128_sha1
  136. auth_chain_a
  137. auth_chain_b
  138. auth_chain_c
  139. auth_chain_d
  140. auth_chain_e
  141. auth_chain_f
  142. )
  143. # obfs
  144. obfs=(
  145. plain
  146. http_simple
  147. http_simple_compatible
  148. http_post
  149. http_post_compatible
  150. tls1.2_ticket_auth
  151. tls1.2_ticket_auth_compatible
  152. tls1.2_ticket_fastauth
  153. tls1.2_ticket_fastauth_compatible
  154. )
  155. # libev obfuscating
  156. obfs_libev=(http tls)
  157. # initialization parameter
  158. libev_obfs=""
  159.  
  160. disable_selinux(){
  161. if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
  162. sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
  163. setenforce
  164. fi
  165. }
  166.  
  167. check_sys(){
  168. local checkType=$
  169. local value=$
  170.  
  171. local release=''
  172. local systemPackage=''
  173.  
  174. if [[ -f /etc/redhat-release ]]; then
  175. release="centos"
  176. systemPackage="yum"
  177. elif grep -Eqi "debian" /etc/issue; then
  178. release="debian"
  179. systemPackage="apt"
  180. elif grep -Eqi "ubuntu" /etc/issue; then
  181. release="ubuntu"
  182. systemPackage="apt"
  183. elif grep -Eqi "centos|red hat|redhat" /etc/issue; then
  184. release="centos"
  185. systemPackage="yum"
  186. elif grep -Eqi "debian|raspbian" /proc/version; then
  187. release="debian"
  188. systemPackage="apt"
  189. elif grep -Eqi "ubuntu" /proc/version; then
  190. release="ubuntu"
  191. systemPackage="apt"
  192. elif grep -Eqi "centos|red hat|redhat" /proc/version; then
  193. release="centos"
  194. systemPackage="yum"
  195. fi
  196.  
  197. if [[ "${checkType}" == "sysRelease" ]]; then
  198. if [ "${value}" == "${release}" ]; then
  199. return
  200. else
  201. return
  202. fi
  203. elif [[ "${checkType}" == "packageManager" ]]; then
  204. if [ "${value}" == "${systemPackage}" ]; then
  205. return
  206. else
  207. return
  208. fi
  209. fi
  210. }
  211.  
  212. version_ge(){
  213. test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"
  214. }
  215.  
  216. version_gt(){
  217. test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"
  218. }
  219.  
  220. check_kernel_version(){
  221. local kernel_version=$(uname -r | cut -d- -f1)
  222. ; then
  223. return
  224. else
  225. return
  226. fi
  227. }
  228.  
  229. check_kernel_headers(){
  230. if check_sys packageManager yum; then
  231. if rpm -qa | grep -q headers-$(uname -r); then
  232. return
  233. else
  234. return
  235. fi
  236. elif check_sys packageManager apt; then
  237. >&; then
  238. return
  239. else
  240. return
  241. fi
  242. fi
  243. return
  244. }
  245.  
  246. getversion(){
  247. if [[ -s /etc/redhat-release ]]; then
  248. grep -oE "[0-9.]+" /etc/redhat-release
  249. else
  250. grep -oE "[0-9.]+" /etc/issue
  251. fi
  252. }
  253.  
  254. centosversion(){
  255. if check_sys sysRelease centos; then
  256. local code=$
  257. local version="$(getversion)"
  258. local main_ver=${version%%.*}
  259. if [ "$main_ver" == "$code" ]; then
  260. return
  261. else
  262. return
  263. fi
  264. else
  265. return
  266. fi
  267. }
  268.  
  269. autoconf_version(){
  270. if [ ! "$(command -v autoconf)" ]; then
  271. echo -e "[${green}Info${plain}] Starting install package autoconf"
  272. if check_sys packageManager yum; then
  273. >& || echo -e "[${red}Error:${plain}] Failed to install autoconf"
  274. elif check_sys packageManager apt; then
  275. apt-get -y update > /dev/>&
  276. apt-get -y >& || echo -e "[${red}Error:${plain}] Failed to install autoconf"
  277. fi
  278. fi
  279. local autoconf_ver=$(autoconf --version | grep autoconf | grep -oE "[0-9.]+")
  280. if version_ge ${autoconf_ver} 2.67; then
  281. return
  282. else
  283. return
  284. fi
  285. }
  286.  
  287. get_ip(){
  288. local IP=$( ip addr | )
  289. [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )
  290. [ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip )
  291. echo ${IP}
  292. }
  293.  
  294. get_ipv6(){
  295. local ipv6=$(wget -qO- -t1 -T2 ipv6.icanhazip.com)
  296. [ -z ${ipv6} ] && return || return
  297. }
  298.  
  299. get_libev_ver(){
  300. libev_ver=$(wget --no-check-certificate -qO- https://api.github.com/repos/shadowsocks/shadowsocks-libev/releases/latest | grep 'tag_name' | cut -d\" -f4)
  301. [ -z ${libev_ver} ] &&
  302. }
  303.  
  304. get_opsy(){
  305. [ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
  306. [ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
  307. [ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
  308. }
  309.  
  310. is_64bit(){
  311. ' ] ; then
  312. return
  313. else
  314. return
  315. fi
  316. }
  317.  
  318. debianversion(){
  319. if check_sys sysRelease debian;then
  320. local version=$( get_opsy )
  321. local code=${}
  322. local main_ver=$( echo ${version} | sed 's/[^0-9]//g')
  323. if [ "${main_ver}" == "${code}" ];then
  324. return
  325. else
  326. return
  327. fi
  328. else
  329. return
  330. fi
  331. }
  332.  
  333. download(){
  334. local filename=$()
  335. } ]; then
  336. echo "${filename} [found]"
  337. else
  338. echo "${filename} not found, download now..."
  339. } ${}
  340. ]; then
  341. echo -e "[${red}Error${plain}] Download ${filename} failed."
  342. exit
  343. fi
  344. fi
  345. }
  346.  
  347. download_files(){
  348. cd ${cur_dir}
  349.  
  350. " ]; then
  351. download "${shadowsocks_python_file}.zip" "${shadowsocks_python_url}"
  352. if check_sys packageManager yum; then
  353. download "${shadowsocks_python_init}" "${shadowsocks_python_centos}"
  354. elif check_sys packageManager apt; then
  355. download "${shadowsocks_python_init}" "${shadowsocks_python_debian}"
  356. fi
  357. " ]; then
  358. download "${shadowsocks_r_file}.tar.gz" "${shadowsocks_r_url}"
  359. if check_sys packageManager yum; then
  360. download "${shadowsocks_r_init}" "${shadowsocks_r_centos}"
  361. elif check_sys packageManager apt; then
  362. download "${shadowsocks_r_init}" "${shadowsocks_r_debian}"
  363. fi
  364. " ]; then
  365. if is_64bit; then
  366. download "${shadowsocks_go_file_64}.gz" "${shadowsocks_go_url_64}"
  367. else
  368. download "${shadowsocks_go_file_32}.gz" "${shadowsocks_go_url_32}"
  369. fi
  370. if check_sys packageManager yum; then
  371. download "${shadowsocks_go_init}" "${shadowsocks_go_centos}"
  372. elif check_sys packageManager apt; then
  373. download "${shadowsocks_go_init}" "${shadowsocks_go_debian}"
  374. fi
  375. " ]; then
  376. get_libev_ver
  377. shadowsocks_libev_file="shadowsocks-libev-$(echo ${libev_ver} | sed -e 's/^[a-zA-Z]//g')"
  378. shadowsocks_libev_url="https://github.com/shadowsocks/shadowsocks-libev/releases/download/${libev_ver}/${shadowsocks_libev_file}.tar.gz"
  379.  
  380. download "${shadowsocks_libev_file}.tar.gz" "${shadowsocks_libev_url}"
  381. if check_sys packageManager yum; then
  382. download "${shadowsocks_libev_init}" "${shadowsocks_libev_centos}"
  383. elif check_sys packageManager apt; then
  384. download "${shadowsocks_libev_init}" "${shadowsocks_libev_debian}"
  385. fi
  386. fi
  387.  
  388. }
  389.  
  390. get_char(){
  391. SAVEDSTTY=$(stty -g)
  392. stty -echo
  393. stty cbreak
  394. count= > /dev/null
  395. stty -raw
  396. stty echo
  397. stty $SAVEDSTTY
  398. }
  399.  
  400. error_detect_depends(){
  401. local command=$
  402. local depend=`echo "${command}" | awk '{print $4}'`
  403. echo -e "[${green}Info${plain}] Starting to install package ${depend}"
  404. ${command} > /dev/>&
  405. ]; then
  406. echo -e "[${red}Error${plain}] Failed to install ${red}${depend}${plain}"
  407. echo "Please visit: https://teddysun.com/486.html and contact."
  408. exit
  409. fi
  410. }
  411.  
  412. config_firewall(){
  413. ; then
  414. /etc/init.d/iptables status > /dev/>&
  415. ]; then
  416. iptables -L -n | >&
  417. ]; then
  418. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${shadowsocksport} -j ACCEPT
  419. iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${shadowsocksport} -j ACCEPT
  420. /etc/init.d/iptables save
  421. /etc/init.d/iptables restart
  422. else
  423. echo -e "[${green}Info${plain}] port ${green}${shadowsocksport}${plain} already be enabled."
  424. fi
  425. else
  426. echo -e "[${yellow}Warning${plain}] iptables looks like not running or not installed, please enable port ${shadowsocksport} manually if necessary."
  427. fi
  428. ; then
  429. systemctl status firewalld > /dev/>&
  430. ]; then
  431. firewall-cmd --permanent --zone=public --add-port=${shadowsocksport}/tcp
  432. firewall-cmd --permanent --zone=public --add-port=${shadowsocksport}/udp
  433. firewall-cmd --reload
  434. else
  435. echo -e "[${yellow}Warning${plain}] firewalld looks like not running or not installed, please enable port ${shadowsocksport} manually if necessary."
  436. fi
  437. fi
  438. }
  439.  
  440. config_shadowsocks(){
  441.  
  442. if check_kernel_version && check_kernel_headers; then
  443. fast_open="true"
  444. else
  445. fast_open="false"
  446. fi
  447.  
  448. " ]; then
  449. if [ ! -d "$(dirname ${shadowsocks_python_config})" ]; then
  450. mkdir -p $(dirname ${shadowsocks_python_config})
  451. fi
  452. cat > ${shadowsocks_python_config}<<-EOF
  453. {
  454. "server":"0.0.0.0",
  455. "server_port":${shadowsocksport},
  456. "local_address":"127.0.0.1",
  457. ,
  458. "password":"${shadowsockspwd}",
  459. ,
  460. "method":"${shadowsockscipher}",
  461. "fast_open":${fast_open}
  462. }
  463. EOF
  464. " ]; then
  465. if [ ! -d "$(dirname ${shadowsocks_r_config})" ]; then
  466. mkdir -p $(dirname ${shadowsocks_r_config})
  467. fi
  468. cat > ${shadowsocks_r_config}<<-EOF
  469. {
  470. "server":"0.0.0.0",
  471. "server_ipv6":"::",
  472. "server_port":${shadowsocksport},
  473. "local_address":"127.0.0.1",
  474. ,
  475. "password":"${shadowsockspwd}",
  476. ,
  477. "method":"${shadowsockscipher}",
  478. "protocol":"${shadowsockprotocol}",
  479. "protocol_param":"",
  480. "obfs":"${shadowsockobfs}",
  481. "obfs_param":"",
  482. "redirect":"",
  483. "dns_ipv6":false,
  484. "fast_open":${fast_open},
  485.  
  486. }
  487. EOF
  488. " ]; then
  489. if [ ! -d "$(dirname ${shadowsocks_go_config})" ]; then
  490. mkdir -p $(dirname ${shadowsocks_go_config})
  491. fi
  492. cat > ${shadowsocks_go_config}<<-EOF
  493. {
  494. "server":"0.0.0.0",
  495. "server_port":${shadowsocksport},
  496. ,
  497. "password":"${shadowsockspwd}",
  498. "method":"${shadowsockscipher}",
  499.  
  500. }
  501. EOF
  502. " ]; then
  503. local server_value="\"0.0.0.0\""
  504. if get_ipv6; then
  505. server_value="[\"[::0]\",\"0.0.0.0\"]"
  506. fi
  507.  
  508. if [ ! -d "$(dirname ${shadowsocks_libev_config})" ]; then
  509. mkdir -p $(dirname ${shadowsocks_libev_config})
  510. fi
  511.  
  512. if [ "${libev_obfs}" == "y" ] || [ "${libev_obfs}" == "Y" ]; then
  513. cat > ${shadowsocks_libev_config}<<-EOF
  514. {
  515. "server":${server_value},
  516. "server_port":${shadowsocksport},
  517. "password":"${shadowsockspwd}",
  518. ,
  519. "user":"nobody",
  520. "method":"${shadowsockscipher}",
  521. "fast_open":${fast_open},
  522. "nameserver":"8.8.8.8",
  523. "mode":"tcp_and_udp",
  524. "plugin":"obfs-server",
  525. "plugin_opts":"obfs=${shadowsocklibev_obfs}"
  526. }
  527. EOF
  528. else
  529. cat > ${shadowsocks_libev_config}<<-EOF
  530. {
  531. "server":${server_value},
  532. "server_port":${shadowsocksport},
  533. "password":"${shadowsockspwd}",
  534. ,
  535. "user":"nobody",
  536. "method":"${shadowsockscipher}",
  537. "fast_open":${fast_open},
  538. "nameserver":"8.8.8.8",
  539. "mode":"tcp_and_udp"
  540. }
  541. EOF
  542. fi
  543.  
  544. fi
  545. }
  546.  
  547. install_dependencies(){
  548. if check_sys packageManager yum; then
  549. echo -e "[${green}Info${plain}] Checking the EPEL repository..."
  550. if [ ! -f /etc/yum.repos.d/epel.repo ]; then
  551. >&
  552. fi
  553. [ ! -f /etc/
  554. [ ! >&
  555. [ x>&
  556. echo -e "[${green}Info${plain}] Checking the EPEL repository complete..."
  557.  
  558. yum_depends=(
  559. unzip gzip openssl openssl-devel gcc python python-devel python-setuptools pcre pcre-devel libtool libevent
  560. autoconf automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel
  561. libev-devel c-ares-devel git qrencode
  562. )
  563. for depend in ${yum_depends[@]}; do
  564. error_detect_depends "yum -y install ${depend}"
  565. done
  566. elif check_sys packageManager apt; then
  567. apt_depends=(
  568. gettext build-essential unzip gzip python python-dev python-setuptools curl openssl libssl-dev
  569. autoconf automake libtool gcc make perl cpio libpcre3 libpcre3-dev zlib1g-dev libev-dev libc-ares-dev git qrencode
  570. )
  571.  
  572. apt-get -y update
  573. for depend in ${apt_depends[@]}; do
  574. error_detect_depends "apt-get -y install ${depend}"
  575. done
  576. fi
  577. }
  578.  
  579. install_check(){
  580. if check_sys packageManager yum || check_sys packageManager apt; then
  581. ; then
  582. return
  583. fi
  584. return
  585. else
  586. return
  587. fi
  588. }
  589.  
  590. install_select(){
  591. if ! install_check; then
  592. echo -e "[${red}Error${plain}] Your OS is not supported to run it!"
  593. echo "Please change to CentOS 6+/Debian 7+/Ubuntu 12+ and try again."
  594. exit
  595. fi
  596.  
  597. clear
  598. while true
  599. do
  600. echo "Which Shadowsocks server you'd select:"
  601. ;i<=${#software[@]};i++ )); do
  602. hint="${software[$i-1]}"
  603. echo -e "${green}${i}${plain}) ${hint}"
  604. done
  605. read -p "Please enter a number (Default ${software[0]}):" selected
  606. [ -z "
  607. case "${selected}" in
  608. |||)
  609. echo
  610. echo "You choose = ${software[${selected}-1]}"
  611. echo
  612. break
  613. ;;
  614. *)
  615. echo -e "[${red}Error${plain}] Please only enter a number [1-4]"
  616. ;;
  617. esac
  618. done
  619. }
  620.  
  621. install_prepare_password(){
  622. echo "Please enter password for ${software[${selected}-1]}"
  623. read -p "(Default password: teddysun.com):" shadowsockspwd
  624. [ -z "${shadowsockspwd}" ] && shadowsockspwd="teddysun.com"
  625. echo
  626. echo "password = ${shadowsockspwd}"
  627. echo
  628. }
  629.  
  630. install_prepare_port() {
  631. while true
  632. do
  633. dport=$(shuf -i - -n )
  634. echo -e "Please enter a port for ${software[${selected}-1]} [1-65535]"
  635. read -p "(Default port: ${dport}):" shadowsocksport
  636. [ -z "${shadowsocksport}" ] && shadowsocksport=${dport}
  637. &>/dev/null
  638. ]; then
  639. ] && [ ${shadowsocksport} -le ] && [ ${shadowsocksport::} != ]; then
  640. echo
  641. echo "port = ${shadowsocksport}"
  642. echo
  643. break
  644. fi
  645. fi
  646. echo -e "[${red}Error${plain}] Please enter a correct number [1-65535]"
  647. done
  648. }
  649.  
  650. install_prepare_cipher(){
  651. while true
  652. do
  653. echo -e "Please select stream cipher for ${software[${selected}-1]}:"
  654.  
  655. " ]]; then
  656. ;i<=${#common_ciphers[@]};i++ )); do
  657. hint="${common_ciphers[$i-1]}"
  658. echo -e "${green}${i}${plain}) ${hint}"
  659. done
  660. read -p "Which cipher you'd select(Default: ${common_ciphers[0]}):" pick
  661. [ -z
  662. &>/dev/null
  663. ]; then
  664. echo -e "[${red}Error${plain}] Please enter a number"
  665. continue
  666. fi
  667. || "$pick" -gt ${#common_ciphers[@]} ]]; then
  668. echo -e "[${red}Error${plain}] Please enter a number between 1 and ${#common_ciphers[@]}"
  669. continue
  670. fi
  671. shadowsockscipher=${common_ciphers[$pick-]}
  672. " ]; then
  673. ;i<=${#r_ciphers[@]};i++ )); do
  674. hint="${r_ciphers[$i-1]}"
  675. echo -e "${green}${i}${plain}) ${hint}"
  676. done
  677. read -p "Which cipher you'd select(Default: ${r_ciphers[1]}):" pick
  678. [ -z
  679. &>/dev/null
  680. ]; then
  681. echo -e "[${red}Error${plain}] Please enter a number"
  682. continue
  683. fi
  684. || "$pick" -gt ${#r_ciphers[@]} ]]; then
  685. echo -e "[${red}Error${plain}] Please enter a number between 1 and ${#r_ciphers[@]}"
  686. continue
  687. fi
  688. shadowsockscipher=${r_ciphers[$pick-]}
  689. " ]; then
  690. ;i<=${#go_ciphers[@]};i++ )); do
  691. hint="${go_ciphers[$i-1]}"
  692. echo -e "${green}${i}${plain}) ${hint}"
  693. done
  694. read -p "Which cipher you'd select(Default: ${go_ciphers[0]}):" pick
  695. [ -z
  696. &>/dev/null
  697. ]; then
  698. echo -e "[${red}Error${plain}] Please enter a number"
  699. continue
  700. fi
  701. || "$pick" -gt ${#go_ciphers[@]} ]]; then
  702. echo -e "[${red}Error${plain}] Please enter a number between 1 and ${#go_ciphers[@]}"
  703. continue
  704. fi
  705. shadowsockscipher=${go_ciphers[$pick-]}
  706. fi
  707.  
  708. echo
  709. echo "cipher = ${shadowsockscipher}"
  710. echo
  711. break
  712. done
  713. }
  714.  
  715. install_prepare_protocol(){
  716. while true
  717. do
  718. echo -e "Please select protocol for ${software[${selected}-1]}:"
  719. ;i<=${#protocols[@]};i++ )); do
  720. hint="${protocols[$i-1]}"
  721. echo -e "${green}${i}${plain}) ${hint}"
  722. done
  723. read -p "Which protocol you'd select(Default: ${protocols[0]}):" protocol
  724. [ -z
  725. &>/dev/null
  726. ]; then
  727. echo -e "[${red}Error${plain}] Please enter a number"
  728. continue
  729. fi
  730. || "$protocol" -gt ${#protocols[@]} ]]; then
  731. echo -e "[${red}Error${plain}] Please enter a number between 1 and ${#protocols[@]}"
  732. continue
  733. fi
  734. shadowsockprotocol=${protocols[$protocol-]}
  735. echo
  736. echo "protocol = ${shadowsockprotocol}"
  737. echo
  738. break
  739. done
  740. }
  741.  
  742. install_prepare_obfs(){
  743. while true
  744. do
  745. echo -e "Please select obfs for ${software[${selected}-1]}:"
  746. ;i<=${#obfs[@]};i++ )); do
  747. hint="${obfs[$i-1]}"
  748. echo -e "${green}${i}${plain}) ${hint}"
  749. done
  750. read -p "Which obfs you'd select(Default: ${obfs[0]}):" r_obfs
  751. [ -z
  752. &>/dev/null
  753. ]; then
  754. echo -e "[${red}Error${plain}] Please enter a number"
  755. continue
  756. fi
  757. || "$r_obfs" -gt ${#obfs[@]} ]]; then
  758. echo -e "[${red}Error${plain}] Please enter a number between 1 and ${#obfs[@]}"
  759. continue
  760. fi
  761. shadowsockobfs=${obfs[$r_obfs-]}
  762. echo
  763. echo "obfs = ${shadowsockobfs}"
  764. echo
  765. break
  766. done
  767. }
  768.  
  769. install_prepare_libev_obfs(){
  770. ; then
  771. while true
  772. do
  773. echo -e "Do you want install simple-obfs for ${software[${selected}-1]}? [y/n]"
  774. read -p "(default: n):" libev_obfs
  775. [ -z "$libev_obfs" ] && libev_obfs=n
  776. case "${libev_obfs}" in
  777. y|Y|n|N)
  778. echo
  779. echo "You choose = ${libev_obfs}"
  780. echo
  781. break
  782. ;;
  783. *)
  784. echo -e "[${red}Error${plain}] Please only enter [y/n]"
  785. ;;
  786. esac
  787. done
  788.  
  789. if [ "${libev_obfs}" == "y" ] || [ "${libev_obfs}" == "Y" ]; then
  790. while true
  791. do
  792. echo -e "Please select obfs for simple-obfs:"
  793. ;i<=${#obfs_libev[@]};i++ )); do
  794. hint="${obfs_libev[$i-1]}"
  795. echo -e "${green}${i}${plain}) ${hint}"
  796. done
  797. read -p "Which obfs you'd select(Default: ${obfs_libev[0]}):" r_libev_obfs
  798. [ -z
  799. &>/dev/null
  800. ]; then
  801. echo -e "[${red}Error${plain}] Please enter a number"
  802. continue
  803. fi
  804. || "$r_libev_obfs" -gt ${#obfs_libev[@]} ]]; then
  805. echo -e "[${red}Error${plain}] Please enter a number between 1 and ${#obfs_libev[@]}"
  806. continue
  807. fi
  808. shadowsocklibev_obfs=${obfs_libev[$r_libev_obfs-]}
  809. echo
  810. echo "obfs = ${shadowsocklibev_obfs}"
  811. echo
  812. break
  813. done
  814. fi
  815. else
  816. echo -e "[${green}Info${plain}] autoconf version is less than 2.67, simple-obfs for ${software[${selected}-1]} installation has been skipped"
  817. fi
  818. }
  819.  
  820. install_prepare(){
  821.  
  822. " ]]; then
  823. install_prepare_password
  824. install_prepare_port
  825. install_prepare_cipher
  826. " ]; then
  827. install_prepare_libev_obfs
  828. fi
  829. " ]; then
  830. install_prepare_password
  831. install_prepare_port
  832. install_prepare_cipher
  833. install_prepare_protocol
  834. install_prepare_obfs
  835. fi
  836.  
  837. echo
  838. echo "Press any key to start...or Press Ctrl+C to cancel"
  839. char=`get_char`
  840.  
  841. }
  842.  
  843. install_libsodium(){
  844. if [ ! -f /usr/lib/libsodium.a ]; then
  845. cd ${cur_dir}
  846. download "${libsodium_file}.tar.gz" "${libsodium_url}"
  847. tar zxf ${libsodium_file}.tar.gz
  848. cd ${libsodium_file}
  849. ./configure --prefix=/usr && make && make install
  850. ]; then
  851. echo -e "[${red}Error${plain}] ${libsodium_file} install failed."
  852. install_cleanup
  853. exit
  854. fi
  855. else
  856. echo -e "[${green}Info${plain}] ${libsodium_file} already installed."
  857. fi
  858. }
  859.  
  860. install_mbedtls(){
  861. if [ ! -f /usr/lib/libmbedtls.a ]; then
  862. cd ${cur_dir}
  863. download "${mbedtls_file}-gpl.tgz" "${mbedtls_url}"
  864. tar xf ${mbedtls_file}-gpl.tgz
  865. cd ${mbedtls_file}
  866. CFLAGS=-fPIC
  867. make DESTDIR=/usr install
  868. ]; then
  869. echo -e "[${red}Error${plain}] ${mbedtls_file} install failed."
  870. install_cleanup
  871. exit
  872. fi
  873. else
  874. echo -e "[${green}Info${plain}] ${mbedtls_file} already installed."
  875. fi
  876. }
  877.  
  878. install_shadowsocks_python(){
  879. cd ${cur_dir}
  880. unzip -q ${shadowsocks_python_file}.zip
  881. ];then
  882. echo -e "[${red}Error${plain}] unzip ${shadowsocks_python_file}.zip failed, please check unzip command."
  883. install_cleanup
  884. exit
  885. fi
  886.  
  887. cd ${shadowsocks_python_file}
  888. python setup.py install --record /usr/local/shadowsocks_python.log
  889.  
  890. if [ -f /usr/bin/ssserver ] || [ -f /usr/local/bin/ssserver ]; then
  891. chmod +x ${shadowsocks_python_init}
  892. local service_name=$(basename ${shadowsocks_python_init})
  893. if check_sys packageManager yum; then
  894. chkconfig --add ${service_name}
  895. chkconfig ${service_name} on
  896. elif check_sys packageManager apt; then
  897. update-rc.d -f ${service_name} defaults
  898. fi
  899. else
  900. echo
  901. echo -e "[${red}Error${plain}] ${software[0]} install failed."
  902. echo "Please visit: https://teddysun.com/486.html and contact."
  903. install_cleanup
  904. exit
  905. fi
  906. }
  907.  
  908. install_shadowsocks_r(){
  909. cd ${cur_dir}
  910. tar zxf ${shadowsocks_r_file}.tar.gz
  911. mv ${shadowsocks_r_file}/shadowsocks /usr/local/
  912. if [ -f /usr/local/shadowsocks/server.py ]; then
  913. chmod +x ${shadowsocks_r_init}
  914. local service_name=$(basename ${shadowsocks_r_init})
  915. if check_sys packageManager yum; then
  916. chkconfig --add ${service_name}
  917. chkconfig ${service_name} on
  918. elif check_sys packageManager apt; then
  919. update-rc.d -f ${service_name} defaults
  920. fi
  921. else
  922. echo
  923. echo -e "[${red}Error${plain}] ${software[1]} install failed."
  924. echo "Please visit; https://teddysun.com/486.html and contact."
  925. install_cleanup
  926. exit
  927. fi
  928. }
  929.  
  930. install_shadowsocks_go(){
  931. cd ${cur_dir}
  932. if is_64bit; then
  933. gzip -d ${shadowsocks_go_file_64}.gz
  934. ];then
  935. echo -e "[${red}Error${plain}] Decompress ${shadowsocks_go_file_64}.gz failed."
  936. install_cleanup
  937. exit
  938. fi
  939. mv -f ${shadowsocks_go_file_64} /usr/bin/shadowsocks-server
  940. else
  941. gzip -d ${shadowsocks_go_file_32}.gz
  942. ];then
  943. echo -e "[${red}Error${plain}] Decompress ${shadowsocks_go_file_32}.gz failed."
  944. install_cleanup
  945. exit
  946. fi
  947. mv -f ${shadowsocks_go_file_32} /usr/bin/shadowsocks-server
  948. fi
  949.  
  950. if [ -f /usr/bin/shadowsocks-server ]; then
  951. chmod +x /usr/bin/shadowsocks-server
  952. chmod +x ${shadowsocks_go_init}
  953.  
  954. local service_name=$(basename ${shadowsocks_go_init})
  955. if check_sys packageManager yum; then
  956. chkconfig --add ${service_name}
  957. chkconfig ${service_name} on
  958. elif check_sys packageManager apt; then
  959. update-rc.d -f ${service_name} defaults
  960. fi
  961. else
  962. echo
  963. echo -e "[${red}Error${plain}] ${software[2]} install failed."
  964. echo "Please visit: https://teddysun.com/486.html and contact."
  965. install_cleanup
  966. exit
  967. fi
  968. }
  969.  
  970. install_shadowsocks_libev(){
  971. cd ${cur_dir}
  972. tar zxf ${shadowsocks_libev_file}.tar.gz
  973. cd ${shadowsocks_libev_file}
  974. ./configure --disable-documentation && make && make install
  975. ]; then
  976. chmod +x ${shadowsocks_libev_init}
  977. local service_name=$(basename ${shadowsocks_libev_init})
  978. if check_sys packageManager yum; then
  979. chkconfig --add ${service_name}
  980. chkconfig ${service_name} on
  981. elif check_sys packageManager apt; then
  982. update-rc.d -f ${service_name} defaults
  983. fi
  984. else
  985. echo
  986. echo -e "[${red}Error${plain}] ${software[3]} install failed."
  987. echo "Please visit: https://teddysun.com/486.html and contact."
  988. install_cleanup
  989. exit
  990. fi
  991. }
  992.  
  993. install_shadowsocks_libev_obfs(){
  994. if [ "${libev_obfs}" == "y" ] || [ "${libev_obfs}" == "Y" ]; then
  995. cd ${cur_dir}
  996. git clone https://github.com/shadowsocks/simple-obfs.git
  997. [ -d simple-obfs ] && cd simple-obfs || echo -e "[${red}Error:${plain}] Failed to git clone simple-obfs."
  998. git submodule update --init --recursive
  999. ; then
  1000. if [ ! "$(command -v autoconf268)" ]; then
  1001. echo -e "[${green}Info${plain}] Starting install autoconf268..."
  1002. >& || echo -e "[${red}Error:${plain}] Failed to install autoconf268."
  1003. fi
  1004. # replace command autoreconf to autoreconf268
  1005. sed -i 's/autoreconf/autoreconf268/' autogen.sh
  1006. # replace #include <ev.h> to #include <libev/ev.h>
  1007. sed -i 's@^#include <ev.h>@#include <libev/ev.h>@' src/local.h
  1008. sed -i 's@^#include <ev.h>@#include <libev/ev.h>@' src/server.h
  1009. fi
  1010. ./autogen.sh
  1011. ./configure --disable-documentation
  1012. make
  1013. make install
  1014. if [ ! "$(command -v obfs-server)" ]; then
  1015. echo -e "[${red}Error${plain}] simple-obfs for ${software[${selected}-1]} install failed."
  1016. echo "Please visit: https://teddysun.com/486.html and contact."
  1017. install_cleanup
  1018. exit
  1019. fi
  1020. [ -f /usr/local/bin/obfs-server ] && ln -s /usr/local/bin/obfs-server /usr/bin
  1021. fi
  1022. }
  1023.  
  1024. install_completed_python(){
  1025. clear
  1026. ${shadowsocks_python_init} start
  1027. echo
  1028. echo -e "Congratulations, ${green}${software[0]}${plain} server install completed!"
  1029. echo -e "Your Server IP : ${red} $(get_ip) ${plain}"
  1030. echo -e "Your Server Port : ${red} ${shadowsocksport} ${plain}"
  1031. echo -e "Your Password : ${red} ${shadowsockspwd} ${plain}"
  1032. echo -e "Your Encryption Method: ${red} ${shadowsockscipher} ${plain}"
  1033. }
  1034.  
  1035. install_completed_r(){
  1036. clear
  1037. ${shadowsocks_r_init} start
  1038. echo
  1039. echo -e "Congratulations, ${green}${software[1]}${plain} server install completed!"
  1040. echo -e "Your Server IP : ${red} $(get_ip) ${plain}"
  1041. echo -e "Your Server Port : ${red} ${shadowsocksport} ${plain}"
  1042. echo -e "Your Password : ${red} ${shadowsockspwd} ${plain}"
  1043. echo -e "Your Protocol : ${red} ${shadowsockprotocol} ${plain}"
  1044. echo -e "Your obfs : ${red} ${shadowsockobfs} ${plain}"
  1045. echo -e "Your Encryption Method: ${red} ${shadowsockscipher} ${plain}"
  1046. }
  1047.  
  1048. install_completed_go(){
  1049. clear
  1050. ${shadowsocks_go_init} start
  1051. echo
  1052. echo -e "Congratulations, ${green}${software[2]}${plain} server install completed!"
  1053. echo -e "Your Server IP : ${red} $(get_ip) ${plain}"
  1054. echo -e "Your Server Port : ${red} ${shadowsocksport} ${plain}"
  1055. echo -e "Your Password : ${red} ${shadowsockspwd} ${plain}"
  1056. echo -e "Your Encryption Method: ${red} ${shadowsockscipher} ${plain}"
  1057. }
  1058.  
  1059. install_completed_libev(){
  1060. clear
  1061. ldconfig
  1062. ${shadowsocks_libev_init} start
  1063. echo
  1064. echo -e "Congratulations, ${green}${software[3]}${plain} server install completed!"
  1065. echo -e "Your Server IP : ${red} $(get_ip) ${plain}"
  1066. echo -e "Your Server Port : ${red} ${shadowsocksport} ${plain}"
  1067. echo -e "Your Password : ${red} ${shadowsockspwd} ${plain}"
  1068. if [ "$(command -v obfs-server)" ]; then
  1069. echo -e "Your obfs : ${red} ${shadowsocklibev_obfs} ${plain}"
  1070. fi
  1071. echo -e "Your Encryption Method: ${red} ${shadowsockscipher} ${plain}"
  1072. }
  1073.  
  1074. qr_generate_python(){
  1075. if [ "$(command -v qrencode)" ]; then
  1076. local tmp=$(echo -n "${shadowsockscipher}:${shadowsockspwd}@$(get_ip):${shadowsocksport}" | base64 -w0)
  1077. local qr_code="ss://${tmp}"
  1078. echo
  1079. echo "Your QR Code: (For Shadowsocks Windows, OSX, Android and iOS clients)"
  1080. echo -e "${green} ${qr_code} ${plain}"
  1081. echo -n "${qr_code}" | qrencode -s8 -o ${cur_dir}/shadowsocks_python_qr.png
  1082. echo "Your QR Code has been saved as a PNG file path:"
  1083. echo -e "${green} ${cur_dir}/shadowsocks_python_qr.png ${plain}"
  1084. fi
  1085. }
  1086.  
  1087. qr_generate_r(){
  1088. if [ "$(command -v qrencode)" ]; then
  1089. local tmp1=$(echo -n "${shadowsockspwd}" | base64 -w0 | sed 's/=//g;s/\//_/g;s/+/-/g')
  1090. local tmp2=$(echo -n "$(get_ip):${shadowsocksport}:${shadowsockprotocol}:${shadowsockscipher}:${shadowsockobfs}:${tmp1}/?obfsparam=" | base64 -w0)
  1091. local qr_code="ssr://${tmp2}"
  1092. echo
  1093. echo "Your QR Code: (For ShadowsocksR Windows, Android clients only)"
  1094. echo -e "${green} ${qr_code} ${plain}"
  1095. echo -n "${qr_code}" | qrencode -s8 -o ${cur_dir}/shadowsocks_r_qr.png
  1096. echo "Your QR Code has been saved as a PNG file path:"
  1097. echo -e "${green} ${cur_dir}/shadowsocks_r_qr.png ${plain}"
  1098. fi
  1099. }
  1100.  
  1101. qr_generate_go(){
  1102. if [ "$(command -v qrencode)" ]; then
  1103. local tmp=$(echo -n "${shadowsockscipher}:${shadowsockspwd}@$(get_ip):${shadowsocksport}" | base64 -w0)
  1104. local qr_code="ss://${tmp}"
  1105. echo
  1106. echo "Your QR Code: (For Shadowsocks Windows, OSX, Android and iOS clients)"
  1107. echo -e "${green} ${qr_code} ${plain}"
  1108. echo -n "${qr_code}" | qrencode -s8 -o ${cur_dir}/shadowsocks_go_qr.png
  1109. echo "Your QR Code has been saved as a PNG file path:"
  1110. echo -e "${green} ${cur_dir}/shadowsocks_go_qr.png ${plain}"
  1111. fi
  1112. }
  1113.  
  1114. qr_generate_libev(){
  1115. if [ "$(command -v qrencode)" ]; then
  1116. local tmp=$(echo -n "${shadowsockscipher}:${shadowsockspwd}@$(get_ip):${shadowsocksport}" | base64 -w0)
  1117. local qr_code="ss://${tmp}"
  1118. echo
  1119. echo "Your QR Code: (For Shadowsocks Windows, OSX, Android and iOS clients)"
  1120. echo -e "${green} ${qr_code} ${plain}"
  1121. echo -n "${qr_code}" | qrencode -s8 -o ${cur_dir}/shadowsocks_libev_qr.png
  1122. echo "Your QR Code has been saved as a PNG file path:"
  1123. echo -e "${green} ${cur_dir}/shadowsocks_libev_qr.png ${plain}"
  1124. fi
  1125. }
  1126.  
  1127. install_main(){
  1128. install_libsodium
  1129. if ! ldconfig -p | grep -wq "/usr/lib"; then
  1130. echo "/usr/lib" > /etc/ld.so.conf.d/lib.conf
  1131. fi
  1132. ldconfig
  1133.  
  1134. " ]; then
  1135. install_shadowsocks_python
  1136. install_completed_python
  1137. qr_generate_python
  1138. " ]; then
  1139. install_shadowsocks_r
  1140. install_completed_r
  1141. qr_generate_r
  1142. " ]; then
  1143. install_shadowsocks_go
  1144. install_completed_go
  1145. qr_generate_go
  1146. " ]; then
  1147. install_mbedtls
  1148. install_shadowsocks_libev
  1149. install_shadowsocks_libev_obfs
  1150. install_completed_libev
  1151. qr_generate_libev
  1152. fi
  1153.  
  1154. echo
  1155. echo "Welcome to visit: https://teddysun.com/486.html"
  1156. echo "Enjoy it!"
  1157. echo
  1158. }
  1159.  
  1160. install_cleanup(){
  1161. cd ${cur_dir}
  1162. rm -rf simple-obfs
  1163. rm -rf ${libsodium_file} ${libsodium_file}.tar.gz
  1164. rm -rf ${mbedtls_file} ${mbedtls_file}-gpl.tgz
  1165. rm -rf ${shadowsocks_python_file} ${shadowsocks_python_file}.zip
  1166. rm -rf ${shadowsocks_r_file} ${shadowsocks_r_file}.tar.gz
  1167. rm -rf ${shadowsocks_go_file_64}.gz ${shadowsocks_go_file_32}.gz
  1168. rm -rf ${shadowsocks_libev_file} ${shadowsocks_libev_file}.tar.gz
  1169. }
  1170.  
  1171. install_shadowsocks(){
  1172. disable_selinux
  1173. install_select
  1174. install_prepare
  1175. install_dependencies
  1176. download_files
  1177. config_shadowsocks
  1178. if check_sys packageManager yum; then
  1179. config_firewall
  1180. fi
  1181. install_main
  1182. install_cleanup
  1183. }
  1184.  
  1185. uninstall_shadowsocks_python(){
  1186. printf "Are you sure uninstall ${red}${software[0]}${plain}? [y/n]\n"
  1187. read -p "(default: n):" answer
  1188. [ -z ${answer} ] && answer="n"
  1189. if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then
  1190. ${shadowsocks_python_init} status > /dev/>&
  1191. ]; then
  1192. ${shadowsocks_python_init} stop
  1193. fi
  1194. local service_name=$(basename ${shadowsocks_python_init})
  1195. if check_sys packageManager yum; then
  1196. chkconfig --del ${service_name}
  1197. elif check_sys packageManager apt; then
  1198. update-rc.d -f ${service_name} remove
  1199. fi
  1200.  
  1201. rm -fr $(dirname ${shadowsocks_python_config})
  1202. rm -f ${shadowsocks_python_init}
  1203. rm -f /var/log/shadowsocks.log
  1204. if [ -f /usr/local/shadowsocks_python.log ]; then
  1205. cat /usr/local/shadowsocks_python.log | xargs rm -rf
  1206. rm -f /usr/local/shadowsocks_python.log
  1207. fi
  1208. echo -e "[${green}Info${plain}] ${software[0]} uninstall success"
  1209. else
  1210. echo
  1211. echo -e "[${green}Info${plain}] ${software[0]} uninstall cancelled, nothing to do..."
  1212. echo
  1213. fi
  1214. }
  1215.  
  1216. uninstall_shadowsocks_r(){
  1217. printf "Are you sure uninstall ${red}${software[1]}${plain}? [y/n]\n"
  1218. read -p "(default: n):" answer
  1219. [ -z ${answer} ] && answer="n"
  1220. if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then
  1221. ${shadowsocks_r_init} status > /dev/>&
  1222. ]; then
  1223. ${shadowsocks_r_init} stop
  1224. fi
  1225. local service_name=$(basename ${shadowsocks_r_init})
  1226. if check_sys packageManager yum; then
  1227. chkconfig --del ${service_name}
  1228. elif check_sys packageManager apt; then
  1229. update-rc.d -f ${service_name} remove
  1230. fi
  1231. rm -fr $(dirname ${shadowsocks_r_config})
  1232. rm -f ${shadowsocks_r_init}
  1233. rm -f /var/log/shadowsocks.log
  1234. rm -fr /usr/local/shadowsocks
  1235. echo -e "[${green}Info${plain}] ${software[1]} uninstall success"
  1236. else
  1237. echo
  1238. echo -e "[${green}Info${plain}] ${software[1]} uninstall cancelled, nothing to do..."
  1239. echo
  1240. fi
  1241. }
  1242.  
  1243. uninstall_shadowsocks_go(){
  1244. printf "Are you sure uninstall ${red}${software[2]}${plain}? [y/n]\n"
  1245. read -p "(default: n):" answer
  1246. [ -z ${answer} ] && answer="n"
  1247. if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then
  1248. ${shadowsocks_go_init} status > /dev/>&
  1249. ]; then
  1250. ${shadowsocks_go_init} stop
  1251. fi
  1252. local service_name=$(basename ${shadowsocks_go_init})
  1253. if check_sys packageManager yum; then
  1254. chkconfig --del ${service_name}
  1255. elif check_sys packageManager apt; then
  1256. update-rc.d -f ${service_name} remove
  1257. fi
  1258. rm -fr $(dirname ${shadowsocks_go_config})
  1259. rm -f ${shadowsocks_go_init}
  1260. rm -f /usr/bin/shadowsocks-server
  1261. echo -e "[${green}Info${plain}] ${software[2]} uninstall success"
  1262. else
  1263. echo
  1264. echo -e "[${green}Info${plain}] ${software[2]} uninstall cancelled, nothing to do..."
  1265. echo
  1266. fi
  1267. }
  1268.  
  1269. uninstall_shadowsocks_libev(){
  1270. printf "Are you sure uninstall ${red}${software[3]}${plain}? [y/n]\n"
  1271. read -p "(default: n):" answer
  1272. [ -z ${answer} ] && answer="n"
  1273. if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then
  1274. ${shadowsocks_libev_init} status > /dev/>&
  1275. ]; then
  1276. ${shadowsocks_libev_init} stop
  1277. fi
  1278. local service_name=$(basename ${shadowsocks_libev_init})
  1279. if check_sys packageManager yum; then
  1280. chkconfig --del ${service_name}
  1281. elif check_sys packageManager apt; then
  1282. update-rc.d -f ${service_name} remove
  1283. fi
  1284. rm -fr $(dirname ${shadowsocks_libev_config})
  1285. rm -f /usr/local/bin/ss-local
  1286. rm -f /usr/local/bin/ss-tunnel
  1287. rm -f /usr/local/bin/ss-server
  1288. rm -f /usr/local/bin/ss-manager
  1289. rm -f /usr/local/bin/ss-redir
  1290. rm -f /usr/local/bin/ss-nat
  1291. rm -f /usr/local/bin/obfs-local
  1292. rm -f /usr/local/bin/obfs-server
  1293. rm -f /usr/local/lib/libshadowsocks-libev.a
  1294. rm -f /usr/local/lib/libshadowsocks-libev.la
  1295. rm -f /usr/local/include/shadowsocks.h
  1296. rm -f /usr/local/lib/pkgconfig/shadowsocks-libev.pc
  1297.  
  1298. rm -fr /usr/local/share/doc/shadowsocks-libev
  1299. rm -f ${shadowsocks_libev_init}
  1300. echo -e "[${green}Info${plain}] ${software[3]} uninstall success"
  1301. else
  1302. echo
  1303. echo -e "[${green}Info${plain}] ${software[3]} uninstall cancelled, nothing to do..."
  1304. echo
  1305. fi
  1306. }
  1307.  
  1308. uninstall_shadowsocks(){
  1309. while true
  1310. do
  1311. echo "Which Shadowsocks server you want to uninstall?"
  1312. ;i<=${#software[@]};i++ )); do
  1313. hint="${software[$i-1]}"
  1314. echo -e "${green}${i}${plain}) ${hint}"
  1315. done
  1316. read -p "Please enter a number [1-4]:" un_select
  1317. case "${un_select}" in
  1318. |||)
  1319. echo
  1320. echo "You choose = ${software[${un_select}-1]}"
  1321. echo
  1322. break
  1323. ;;
  1324. *)
  1325. echo -e "[${red}Error${plain}] Please only enter a number [1-4]"
  1326. ;;
  1327. esac
  1328. done
  1329.  
  1330. " ]; then
  1331. if [ -f ${shadowsocks_python_init} ]; then
  1332. uninstall_shadowsocks_python
  1333. else
  1334. echo -e "[${red}Error${plain}] ${software[${un_select}-1]} not installed, please check it and try again."
  1335. echo
  1336. exit
  1337. fi
  1338. " ]; then
  1339. if [ -f ${shadowsocks_r_init} ]; then
  1340. uninstall_shadowsocks_r
  1341. else
  1342. echo -e "[${red}Error${plain}] ${software[${un_select}-1]} not installed, please check it and try again."
  1343. echo
  1344. exit
  1345. fi
  1346. " ]; then
  1347. if [ -f ${shadowsocks_go_init} ]; then
  1348. uninstall_shadowsocks_go
  1349. else
  1350. echo -e "[${red}Error${plain}] ${software[${un_select}-1]} not installed, please check it and try again."
  1351. echo
  1352. exit
  1353. fi
  1354. " ]; then
  1355. if [ -f ${shadowsocks_libev_init} ]; then
  1356. uninstall_shadowsocks_libev
  1357. else
  1358. echo -e "[${red}Error${plain}] ${software[${un_select}-1]} not installed, please check it and try again."
  1359. echo
  1360. exit
  1361. fi
  1362. fi
  1363. }
  1364.  
  1365. # Initialization step
  1366. action=$
  1367. [ -z $ ] && action=install
  1368. case "${action}" in
  1369. install|uninstall)
  1370. ${action}_shadowsocks
  1371. ;;
  1372. *)
  1373. echo "Arguments error! [${action}]"
  1374. echo "Usage: $(basename $0) [install|uninstall]"
  1375. ;;
  1376. esac

关于本脚本

1、一键安装 Shadowsocks-Python, ShadowsocksR, Shadowsocks-Go, Shadowsocks-libev 版(四选一)服务端;
2、各版本的启动脚本及配置文件名不再重合;
3、每次运行可安装一种版本;
4、支持以多次运行来安装多个版本,且各个版本可以共存(注意端口号需设成不同);
5、若已安装多个版本,则卸载时也需多次运行(每次卸载一种);
6、Shadowsocks-Python 和 ShadowsocksR 安装后不可同时启动(因为本质上都属 Python 版)。

友情提示:如果你有问题,请先阅读这篇《Shadowsocks Troubleshooting》之后再询问。

默认配置

服务器端口:自己设定(如不设定,默认为 8989)
密码:自己设定(如不设定,默认为 teddysun.com)
加密方式:自己设定(如不设定,Python 和 libev 版默认为 aes-256-gcm,R 和 Go 版默认为 aes-256-cfb)
协议(protocol):自己设定(如不设定,默认为 origin)(仅限 ShadowsocksR 版)
混淆(obfs):自己设定(如不设定,默认为 plain)(仅限 ShadowsocksR 版)
备注:脚本默认创建单用户配置文件,如需配置多用户,请手动修改相应的配置文件后重启即可。

客户端下载

常规版 Windows 客户端
https://github.com/shadowsocks/shadowsocks-windows/releases

ShadowsocksR 版 Windows 客户端
https://github.com/shadowsocksr-backup/shadowsocksr-csharp/releases

使用方法

使用root用户登录,运行以下命令:

  1. wget --no-check-certificate -O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh
  2. chmod +x shadowsocks-all.sh
  3. ./shadowsocks-all.sh 2>&1 | tee shadowsocks-all.log

安装完成后,脚本提示如下

  1. Congratulations, your_shadowsocks_version install completed!
  2. Your Server IP :your_server_ip
  3. Your Server Port :your_server_port
  4. Your Password :your_password
  5. Your Encryption Method:your_encryption_method
  6.  
  7. Your QR Code: (For Shadowsocks Windows, OSX, Android and iOS clients)
  8. ss://your_encryption_method:your_password@your_server_ip:your_server_port
  9. Your QR Code has been saved as a PNG file path:
  10. your_path.png
  11.  
  12. Welcome to visit:https://teddysun.com/486.html
  13. Enjoy it!

卸载方法

若已安装多个版本,则卸载时也需多次运行(每次卸载一种)

使用root用户登录,运行以下命令:

  1. ./shadowsocks-all.sh uninstall

启动脚本

启动脚本后面的参数含义,从左至右依次为:启动,停止,重启,查看状态。

Shadowsocks-Python 版:
/etc/init.d/shadowsocks-python start | stop | restart | status

ShadowsocksR 版:
/etc/init.d/shadowsocks-r start | stop | restart | status

Shadowsocks-Go 版:
/etc/init.d/shadowsocks-go start | stop | restart | status

Shadowsocks-libev 版:
/etc/init.d/shadowsocks-libev start | stop | restart | status

各版本默认配置文件

Shadowsocks-Python 版:
/etc/shadowsocks-python/config.json

ShadowsocksR 版:
/etc/shadowsocks-r/config.json

Shadowsocks-Go 版:
/etc/shadowsocks-go/config.json

Shadowsocks-libev 版:
/etc/shadowsocks-libev/config.json

sha0dow0socks的更多相关文章

随机推荐

  1. Unity shader学习之屏幕后期处理效果之Bloom效果

    Bloom特效是游戏中常见的一种屏幕效果.这种特效可以模拟真实摄像机的一种图像效果,它让画面中较亮的区域“扩散”到周围的区域中,造成一种朦胧的效果. Bloom的实现原理很简单,首先根据一个阈值提取出 ...

  2. SlimScroll插件学习

    SlimScroll插件学习 SlimScroll插件,是一个很好用的滚动条插件. 第一个实例程序: js代码: <script src="../slimScroll/jquery-3 ...

  3. CSS背景与边框属性-----box-shadow

    box-shadow:none | <shadow> [ , <shadow> ]*   <shadow> = inset? && <leng ...

  4. ModelState查看错误字段的信息

    if (!ModelState.IsValid) { List<string> sb = new List<string>(); //获取所有错误的Key List<st ...

  5. STL容器之vector

    [1]模板类vector 模板类vector可理解为广义数组.广义数组,即与类型无关的数组,具有与数组相同的所有操作. 那么,你或许要问:既然C++语言本身已提供了一个序列式容器array,为什么还要 ...

  6. HOG基本原理

    图像识别,图像预处理,HOG算法介绍. 转自: https://blog.csdn.net/gy429476195/article/details/50156813

  7. USMART 组件移植到STM32

    USMART是由ALIENTEK开发的一个串口调试助手组件,通过它可以通过串口调试助手,调用程序里面的任何函数并执行,单个函数最多支持10个输入参数,并支持函数返回值显示. USMART支持的参数类型 ...

  8. 新服务器上装java PHP环境有什么一键安装的方便的方法?一般都是怎么安装环境的?

     新服务器上装java PHP环境有什么一键安装的方便的方法?一般都是怎么安装环境的?  linode digitalocean都有很好的教程,下面是ubuntu和centos的两个教程连接. How ...

  9. vue之component

    因为组件是可复用的 Vue 实例,所以它们与 new Vue 接收相同的选项,例如 data.computed.watch.methods 以及生命周期钩子等.仅有的例外是像 el 这样根实例特有的选 ...

  10. Hbase 过滤器的使用

    Filter filter= new RowFilter(CompareFilter.CompareOp.EQUAL,new RegexStringComparator("."+d ...