From 7e199b895b66aad5447cb9eaa8ccec6b52384800 Mon Sep 17 00:00:00 2001 From: Toyo Date: Wed, 26 Jul 2017 11:53:06 +0800 Subject: [PATCH] =?UTF-8?q?#=20v2.0.20=20=E4=BF=AE=E5=A4=8DCentOS7=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BAIP=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20Git=20=E5=AE=89=E8=A3=85=E6=88=90=E5=8A=9F=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ssr.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ssr.sh b/ssr.sh index 0a30524..c019c1f 100644 --- a/ssr.sh +++ b/ssr.sh @@ -5,12 +5,12 @@ export PATH #================================================= # System Required: CentOS 6+/Debian 6+/Ubuntu 14.04+ # Description: Install the ShadowsocksR server -# Version: 2.0.19 +# Version: 2.0.20 # Author: Toyo # Blog: https://doub.io/ss-jc42/ #================================================= -sh_ver="2.0.19" +sh_ver="2.0.20" ssr_folder="/usr/local/shadowsocksr" ssr_ss_file="${ssr_folder}/shadowsocks" config_file="${ssr_folder}/config.json" @@ -622,6 +622,7 @@ Installation_dependency(){ else Debian_apt fi + [[ ! -e "/usr/bin/git" ]] && echo -e "${Error} 依赖 Git 安装失败,多半是软件包源的问题,请检查 !" && exit 1 Check_python echo "nameserver 8.8.8.8" > /etc/resolv.conf echo "nameserver 8.8.4.4" >> /etc/resolv.conf @@ -731,7 +732,7 @@ debian_View_user_connection_info(){ user_IP=`echo ${user_IP}|sed 's/ / | /g'` fi user_list_all="端口: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, 链接IP总数: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, 当前链接IP: ${Green_font_prefix}"${user_IP}"${Font_color_suffix}\n" - echo -e "当前模式: ${Green_font_prefix} "${now_mode}" ${Font_color_suffix}" + echo -e "当前模式: ${Green_background_prefix} "${now_mode}" ${Font_color_suffix},链接IP总数: ${Green_background_prefix} "${IP_total}" ${Font_color_suffix}" echo -e ${user_list_all} else now_mode="多端口" && user_total=`${jq_file} '.port_password' ${config_user_file} |sed '$d;1d' | wc -l` @@ -749,14 +750,14 @@ debian_View_user_connection_info(){ fi user_list_all=${user_list_all}"端口: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, 链接IP总数: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, 当前链接IP: ${Green_font_prefix}"${user_IP}"${Font_color_suffix}\n" done - echo -e "当前模式: ${Green_font_prefix} "${now_mode}" ${Font_color_suffix} ,用户总数: ${Green_font_prefix} "${user_total}" ${Font_color_suffix} ,链接IP总数: ${Green_font_prefix} "${IP_total}" ${Font_color_suffix} " + echo -e "当前模式: ${Green_background_prefix} "${now_mode}" ${Font_color_suffix} ,用户总数: ${Green_background_prefix} "${user_total}" ${Font_color_suffix} ,链接IP总数: ${Green_background_prefix} "${IP_total}" ${Font_color_suffix} " echo -e ${user_list_all} fi } centos_View_user_connection_info(){ if [[ -z "${now_mode}" ]]; then now_mode="单端口" && user_total="1" - IP_total=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp' |grep '::ffff:' |awk '{print $4}' |sort -u |wc -l` + IP_total=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp' |grep '::ffff:' |awk '{print $5}' |awk -F ":" '{print $4}' |sort -u |wc -l` user_port=`${jq_file} '.server_port' ${config_user_file}` user_IP=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp' |grep "${user_port}" | grep '::ffff:' |awk '{print $5}' |awk -F ":" '{print $4}' |sort -u` if [[ -z ${user_IP} ]]; then @@ -766,11 +767,11 @@ centos_View_user_connection_info(){ user_IP=`echo ${user_IP}|sed 's/ / | /g'` fi user_list_all="端口: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, 链接IP总数: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, 当前链接IP: ${Green_font_prefix}"${user_IP}"${Font_color_suffix}\n" - echo -e "当前模式: ${Green_font_prefix} "${now_mode}" ${Font_color_suffix}" + echo -e "当前模式: ${Green_background_prefix} "${now_mode}" ${Font_color_suffix},链接IP总数: ${Green_background_prefix} "${IP_total}" ${Font_color_suffix}" echo -e ${user_list_all} else now_mode="多端口" && user_total=`${jq_file} '.port_password' ${config_user_file} |sed '$d;1d' | wc -l` - IP_total=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp' | grep '::ffff:' |awk '{print $4}' |sort -u |wc -l` + IP_total=`netstat -anp |grep 'ESTABLISHED' |grep 'python' |grep 'tcp' | grep '::ffff:' |awk '{print $5}' |awk -F ":" '{print $4}' |sort -u |wc -l` user_list_all="" for((integer = 1; integer <= ${user_total}; integer++)) do @@ -784,14 +785,19 @@ centos_View_user_connection_info(){ fi user_list_all=${user_list_all}"端口: ${Green_font_prefix}"${user_port}"${Font_color_suffix}, 链接IP总数: ${Green_font_prefix}"${user_IP_total}"${Font_color_suffix}, 当前链接IP: ${Green_font_prefix}"${user_IP}"${Font_color_suffix}\n" done - echo -e "当前模式: ${Green_font_prefix} "${now_mode}" ${Font_color_suffix} ,用户总数: ${Green_font_prefix} "${user_total}" ${Font_color_suffix} ,链接IP总数: ${Green_font_prefix} "${IP_total}" ${Font_color_suffix} " + echo -e "当前模式: ${Green_background_prefix} "${now_mode}" ${Font_color_suffix} ,用户总数: ${Green_background_prefix} "${user_total}" ${Font_color_suffix} ,链接IP总数: ${Green_background_prefix} "${IP_total}" ${Font_color_suffix} " echo -e ${user_list_all} fi } View_user_connection_info(){ SSR_installation_status if [[ ${release} = "centos" ]]; then - centos_View_user_connection_info + cat /etc/redhat-release |grep 7\..*|grep -i centos>/dev/null + if [[ $? = 0 ]]; then + debian_View_user_connection_info + else + centos_View_user_connection_info + fi else debian_View_user_connection_info fi