Skip to content

Commit

Permalink
提交正式版
Browse files Browse the repository at this point in the history
  • Loading branch information
chiakge committed Nov 1, 2017
1 parent 46c934b commit 8cce3f9
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 472 deletions.
83 changes: 62 additions & 21 deletions tcp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export PATH
#=================================================
# System Required: CentOS 6+,Debian7+,Ubuntu12+
# Description: BBR+BBR魔改版+Lotserver
# Version: 0.9
# Version: 1.0
# Author: 千影
# Blog: https://www.94ish.me/
#=================================================

sh_ver="0.9"
github="raw.githubusercontent.com/chiakge/Linux-NetSpeed/master"
sh_ver="1.0"
github="raw.githubusercontent.com/chiakge/Centos-NetSpeed/master"

Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m"
Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Expand Down Expand Up @@ -92,7 +92,7 @@ startbbr(){
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=tsunami" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
echo -e "${Info}BBR启动成功!"
}
Expand Down Expand Up @@ -159,7 +159,7 @@ Update_Shell(){
[[ -z ${sh_new_ver} ]] && echo -e "${Error} 检测最新版本失败 !" && start_menu
if [[ ${sh_new_ver} != ${sh_ver} ]]; then
echo -e "发现新版本[ ${sh_new_ver} ],是否更新?[Y/n]"
stty erase '^H' && read -p "(默认: y):" yn
read -p "(默认: y):" yn
[[ -z "${yn}" ]] && yn="y"
if [[ ${yn} == [Yy] ]]; then
wget -N --no-check-certificate http://${github}/tcp.sh && chmod +x tcp.sh
Expand All @@ -169,6 +169,7 @@ Update_Shell(){
fi
else
echo -e "当前已是最新版本[ ${sh_new_ver} ] !"
sleep 5s
fi
start_menu
}
Expand All @@ -192,18 +193,16 @@ echo && echo -e " TCP加速 一键安装管理脚本 ${Red_font_prefix}[v${sh_ve
${Green_font_prefix}7.${Font_color_suffix} 系统配置优化
${Green_font_prefix}8.${Font_color_suffix} 退出脚本
————————————————————————————————" && echo
if [[ -e ${file} ]]; then
check_pid
if [[ ! -z "${PID}" ]]; then
echo -e " 当前状态: ${Green_font_prefix}已安装${Font_color_suffix} ${Green_font_prefix}已启动${Font_color_suffix}"

check_status
if [[ ${kernel_status} == "noinstall" ]]; then
echo -e " 当前状态: ${Green_font_prefix}未安装${Font_color_suffix} 加速内核 ${Red_font_prefix}请先安装内核${Font_color_suffix}"
else
echo -e " 当前状态: ${Green_font_prefix}已安装${Font_color_suffix}${Red_font_prefix}未启动${Font_color_suffix}"
echo -e " 当前状态: ${Green_font_prefix}已安装${Font_color_suffix} ${_font_prefix}${kernel_status}${Font_color_suffix} 加速内核 , ${Green_font_prefix}${run_status}${Font_color_suffix}"

fi
else
echo -e " 当前状态: ${Red_font_prefix}未安装${Font_color_suffix}"
fi
echo
stty erase '^H' && read -p " 请输入数字 [0-8]:" num
read -p " 请输入数字 [0-8]:" num
case "$num" in
0)
Update_Shell
Expand All @@ -227,7 +226,7 @@ case "$num" in
remove_all
;;
7)
View_Config
echo -e "尚未完工"
;;
8)
exit 1
Expand Down Expand Up @@ -364,10 +363,10 @@ check_sys_bbr(){
check_sys_Lotsever(){
check_version
if [[ "${release}" == "centos" ]]; then
if [[ ${version} = "6" ]]; then
if [[ ${version} == "6" ]]; then
kernel_version="2.6.32-504"
installlot
elif [[ ${version} = "7" ]]; then
elif [[ ${version} == "7" ]]; then
yum -y install net-tools
kernel_version="3.10.0-327"
installlot
Expand All @@ -376,10 +375,10 @@ check_sys_Lotsever(){
fi
elif [[ "${release}" == "debian" ]]; then
if [[ ${version} -ge "7" ]]; then
if [[ ${bit} = "x64" ]]; then
if [[ ${bit} == "x64" ]]; then
kernel_version="3.16.0-4"
installlot
elif [[ ${bit} = "x32" ]]; then
elif [[ ${bit} == "x32" ]]; then
kernel_version="3.2.0-4"
installlot
fi
Expand All @@ -388,10 +387,10 @@ check_sys_Lotsever(){
fi
elif [[ "${release}" == "ubuntu" ]]; then
if [[ ${version} -ge "12" ]]; then
if [[ ${bit} = "x64" ]]; then
if [[ ${bit} == "x64" ]]; then
kernel_version="4.4.0-47"
installlot
elif [[ ${bit} = "x32" ]]; then
elif [[ ${bit} == "x32" ]]; then
kernel_version="3.13.0-29"
installlot
fi
Expand All @@ -403,9 +402,51 @@ check_sys_Lotsever(){
fi
}

check_status(){
kernel_version=`uname -r | awk -F "-" '{print $1}'`
if [[ ${kernel_version} == "4.11.8" ]]; then
kernel_status="BBR"
elif [[ ${kernel_version} == "3.10.0" || ${kernel_version} = "3.16.0" || ${kernel_version} = "3.2.0" || ${kernel_version} = "4.4.0" ]] || [[ ${kernel_version} = "3.13.0" ]]; then
kernel_status="Lotserver"
else
kernel_status="noinstall"
fi
if [[ ${kernel_status} == "Lotserver" ]]; then
if [[ -e /appex/bin/serverSpeeder.sh ]]; then
run_status=`bash /appex/bin/serverSpeeder.sh status | grep "ServerSpeeder" `]
if [[ ${run_status} == "Lotserver" ]]; then
run_status="启动成功"
else
run_status="启动失败"
fi
else
run_status="未安装加速模块"
fi
elif [[ ${kernel_status} == "BBR" ]]; then
run_status=`grep "net.ipv4.tcp_congestion_control" /etc/sysctl.conf | awk -F "=" '{print $2}'`
if [[ ${run_status} == "bbr" ]]; then
run_status=`lsmod | grep "tcp" | awk '{print $1}'`
if [[ ${run_status} == "tcp_bbr" ]]; then
run_status="BBR启动成功"
else
run_status="BBR启动失败"
fi
elif [[ ${run_status} == "tsunami" ]]; then
run_status=`lsmod | grep "tcp" | awk '{print $1}'`
if [[ ${run_status} == "tcp_tsunami" ]]; then
run_status="BBR魔改版启动成功"
else
run_status="BBR魔改版启动失败"
fi
else
run_status="未安装加速模块"
fi
fi
}

#############系统检测组件#############
check_sys
check_version
[[ ${release} != "debian" ]] && [[ ${release} != "ubuntu" ]] && [[ ${release} != "centos" ]] && echo -e "${Error} 本脚本不支持当前系统 ${release} !" && exit 1
start_menu

Loading

0 comments on commit 8cce3f9

Please sign in to comment.