@@ -5,11 +5,12 @@ export PATH
5
5
# =================================================
6
6
# System Required: Debian/Ubuntu
7
7
# Description: Socat
8
- # Version: 1.0.4
8
+ # Version: 1.0.5
9
9
# Author: Toyo
10
10
# Blog: https://doub.io/wlzy-18/
11
11
# =================================================
12
12
13
+ sh_ver=" 1.0.5"
13
14
socat_file=" /usr/bin/socat"
14
15
socat_log_file=" /tmp/socat.log"
15
16
@@ -51,13 +52,13 @@ installSocat(){
51
52
apt-get install -y socat
52
53
Set_iptables
53
54
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
56
57
socat_exist=` socat -h`
57
58
if [[ ! -e ${socat_file} ]]; then
58
59
echo -e " ${Error} 安装Socat失败,请检查 !" && exit 1
59
60
else
60
- echo -e " ${Info} Socat 安装完成 ! 可以通过 ${Green_background_prefix} bash socat.sh add {Font_color_suffix}来添加端口转发规则 ! "
61
+ echo -e " ${Info} Socat 安装完成 !"
61
62
fi
62
63
}
63
64
addSocat (){
@@ -301,16 +302,75 @@ uninstallSocat(){
301
302
echo && echo " 卸载已取消..." && echo
302
303
fi
303
304
}
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
+ }
304
328
check_sys
305
329
[[ ${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
311
372
;;
312
373
* )
313
- echo " 输入错误 !"
314
- echo " 用法: {install | add | del | list | tail | uninstall}"
374
+ echo " 请输入正确数字 [0-6]"
315
375
;;
316
376
esac
0 commit comments