Skip to content

Commit 6aaf375

Browse files
author
Toyo
authored
# v1.0.5
1 parent 66b6524 commit 6aaf375

File tree

1 file changed

+71
-11
lines changed

1 file changed

+71
-11
lines changed

socat.sh

+71-11
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ export PATH
55
#=================================================
66
# System Required: Debian/Ubuntu
77
# Description: Socat
8-
# Version: 1.0.4
8+
# Version: 1.0.5
99
# Author: Toyo
1010
# Blog: https://doub.io/wlzy-18/
1111
#=================================================
1212

13+
sh_ver="1.0.5"
1314
socat_file="/usr/bin/socat"
1415
socat_log_file="/tmp/socat.log"
1516

@@ -51,13 +52,13 @@ installSocat(){
5152
apt-get install -y socat
5253
Set_iptables
5354
chmod +x /etc/rc.local
54-
echo "nameserver 8.8.8.8" > /etc/resolv.conf
55-
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
55+
# echo "nameserver 8.8.8.8" > /etc/resolv.conf
56+
# echo "nameserver 8.8.4.4" >> /etc/resolv.conf
5657
socat_exist=`socat -h`
5758
if [[ ! -e ${socat_file} ]]; then
5859
echo -e "${Error} 安装Socat失败,请检查 !" && exit 1
5960
else
60-
echo -e "${Info} Socat 安装完成 ! 可以通过${Green_background_prefix} bash socat.sh add {Font_color_suffix}来添加端口转发规则 !"
61+
echo -e "${Info} Socat 安装完成 !"
6162
fi
6263
}
6364
addSocat(){
@@ -301,16 +302,75 @@ uninstallSocat(){
301302
echo && echo "卸载已取消..." && echo
302303
fi
303304
}
305+
Update_Shell(){
306+
echo -e "当前版本为 [ ${sh_ver} ],开始检测最新版本..."
307+
sh_new_ver=$(wget --no-check-certificate -qO- "https://softs.fun/Bash/socat.sh"|grep 'sh_ver="'|awk -F "=" '{print $NF}'|sed 's/\"//g'|head -1) && sh_new_type="softs"
308+
[[ -z ${sh_new_ver} ]] && sh_new_ver=$(wget --no-check-certificate -qO- "https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/socat.sh"|grep 'sh_ver="'|awk -F "=" '{print $NF}'|sed 's/\"//g'|head -1) && sh_new_type="github"
309+
[[ -z ${sh_new_ver} ]] && echo -e "${Error} 检测最新版本失败 !" && exit 0
310+
if [[ ${sh_new_ver} != ${sh_ver} ]]; then
311+
echo -e "发现新版本[ ${sh_new_ver} ],是否更新?[Y/n]"
312+
stty erase '^H' && read -p "(默认: y):" yn
313+
[[ -z "${yn}" ]] && yn="y"
314+
if [[ ${yn} == [Yy] ]]; then
315+
if [[ $sh_new_type == "softs" ]]; then
316+
wget -N --no-check-certificate https://softs.fun/Bash/socat.sh && chmod +x socat.sh
317+
else
318+
wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/socat.sh && chmod +x socat.sh
319+
fi
320+
echo -e "脚本已更新为最新版本[ ${sh_new_ver} ] !"
321+
else
322+
echo && echo " 已取消..." && echo
323+
fi
324+
else
325+
echo -e "当前已是最新版本[ ${sh_new_ver} ] !"
326+
fi
327+
}
304328
check_sys
305329
[[ ${release} != "debian" ]] && [[ ${release} != "ubuntu" ]] && echo -e "${Error} 本脚本不支持当前系统 ${release} !" && exit 1
306-
action=$1
307-
[[ -z $1 ]] && action=install
308-
case "$action" in
309-
install|add|del|list|tail|uninstall)
310-
${action}Socat
330+
echo && echo -e " SoCat 一键管理脚本 ${Red_font_prefix}[v${sh_ver}]${Font_color_suffix}
331+
-- Toyo | doub.io/wlzy-18 --
332+
333+
${Green_font_prefix}0.${Font_color_suffix} 升级脚本
334+
————————————
335+
${Green_font_prefix}1.${Font_color_suffix} 安装 SoCat
336+
${Green_font_prefix}2.${Font_color_suffix} 卸载 SoCat
337+
————————————
338+
${Green_font_prefix}3.${Font_color_suffix} 新增 SoCat
339+
${Green_font_prefix}4.${Font_color_suffix} 删除 SoCat
340+
————————————
341+
${Green_font_prefix}5.${Font_color_suffix} 查看 SoCat 信息
342+
${Green_font_prefix}6.${Font_color_suffix} 查看 SoCat 日志
343+
————————————" && echo
344+
if [[ -e ${socat_file} ]]; then
345+
echo -e " 当前状态: ${Green_font_prefix}已安装${Font_color_suffix}"
346+
else
347+
echo -e " 当前状态: ${Red_font_prefix}未安装${Font_color_suffix}"
348+
fi
349+
echo
350+
stty erase '^H' && read -p " 请输入数字 [0-9]:" num
351+
case "$num" in
352+
0)
353+
Update_Shell
354+
;;
355+
1)
356+
installSocat
357+
;;
358+
2)
359+
uninstallSocat
360+
;;
361+
3)
362+
addSocat
363+
;;
364+
4)
365+
delSocat
366+
;;
367+
5)
368+
listSocat
369+
;;
370+
6)
371+
tailSocat
311372
;;
312373
*)
313-
echo "输入错误 !"
314-
echo "用法: {install | add | del | list | tail | uninstall}"
374+
echo "请输入正确数字 [0-6]"
315375
;;
316376
esac

0 commit comments

Comments
 (0)