diff --git a/scripts/lang/chs/common.lang b/scripts/lang/chs/common.lang index 0895be08..6d10dd61 100644 --- a/scripts/lang/chs/common.lang +++ b/scripts/lang/chs/common.lang @@ -1,6 +1,7 @@ COMMON_INPUT="请输入对应数字" COMMON_INPUT_L="请输入对应字母或数字" +COMMON_INPUT_R="是否启用?(1/0) > " COMMON_BACK="返回上级菜单" COMMON_SUCCESS="操作成功!" COMMON_FAILED="操作失败!" diff --git a/scripts/lang/chs/userguide.lang b/scripts/lang/chs/userguide.lang new file mode 100644 index 00000000..6a0acf85 --- /dev/null +++ b/scripts/lang/chs/userguide.lang @@ -0,0 +1,14 @@ +# 新手引导 +UG_WELCOME="欢迎使用新手引导!" +UG_CHOOSE_ENV="请先选择你的使用环境:" +UG_TIP_CONFIG="(你之后依然可以在设置中更改各种配置)" +UG_OPTION_1="路由设备配置局域网透明代理" +UG_OPTION_2="Linux设备仅配置本机代理" +UG_OPTION_3="还原之前备份的设置" +UG_RESTORE_OK="脚本设置已还原!请重新启动脚本!" +UG_IP_FORWARD_WARN="检测到你的设备尚未开启ip转发,局域网设备将无法正常连接网络,是否立即开启?" +UG_ENABLE_LOW_MEM="检测到你的安装目录空间不足10M,是否开启小闪存模式?" +UG_IMPORT_CONFIG="是否导入配置文件?(这是运行前的最后一步)" +UG_CONFIG_TIP="你必须拥有一份配置文件才能运行服务!" +UG_CONFIG_RES="现在开始导入?" +UG_FINAL_TIP="很好!现在只需要执行启动就可以愉快的使用了!" diff --git a/scripts/lang/en/common.lang b/scripts/lang/en/common.lang index 25d435ee..9637da78 100644 --- a/scripts/lang/en/common.lang +++ b/scripts/lang/en/common.lang @@ -1,6 +1,7 @@ COMMON_INPUT="Please enter a number" COMMON_INPUT_L="Enter a letter or a number" +COMMON_INPUT_R="Enable? (1/0) > " COMMON_BACK="Back" COMMON_SUCCESS="Setup Success!" COMMON_FAILED="Setup failed!" diff --git a/scripts/lang/en/userguide.lang b/scripts/lang/en/userguide.lang new file mode 100644 index 00000000..34814a7c --- /dev/null +++ b/scripts/lang/en/userguide.lang @@ -0,0 +1,14 @@ + +UG_WELCOME="Welcome to User Guide!" +UG_CHOOSE_ENV="Please select your usage environment:" +UG_TIP_CONFIG="(You can still change various settings later)" +UG_OPTION_1="Router: LAN transparent proxy" +UG_OPTION_2="Linux device: local proxy only" +UG_OPTION_3="Restore previous backup settings" +UG_RESTORE_OK="Script settings have been restored! Please restart the script!" +UG_IP_FORWARD_WARN="Your device has not enabled IP forwarding, LAN devices will not connect properly. Enable now?" +UG_ENABLE_LOW_MEM="Your installation directory is less than 10MB, enable low-flash mode?" +UG_IMPORT_CONFIG="Import configuration file? (Last step before running)" +UG_CONFIG_TIP="You must have a configuration file to run the service!" +UG_CONFIG_RES="Importing now? " +UG_FINAL_TIP="Great! Now just start the service to enjoy!" diff --git a/scripts/menus/userguide.sh b/scripts/menus/userguide.sh index b51cd5ed..475082d5 100644 --- a/scripts/menus/userguide.sh +++ b/scripts/menus/userguide.sh @@ -4,24 +4,26 @@ [ -n "$__IS_MODULE_USERGUIDE_LOADED" ] && return __IS_MODULE_USERGUIDE_LOADED=1 +load_lang userguide + forwhat() { while true; do - echo "-----------------------------------------------" - echo -e "\033[30;46m 欢迎使用ShellCrash新手引导! \033[0m" - echo "-----------------------------------------------" - echo -e "\033[33m请先选择你的使用环境: \033[0m" - echo -e "\033[0m(你之后依然可以在设置中更改各种配置)\033[0m" - echo "-----------------------------------------------" - echo -e " 1 \033[32m路由设备配置局域网透明代理\033[0m" - echo -e " 2 \033[36mLinux设备仅配置本机代理\033[0m" - [ -f "$CFG_PATH.bak" ] && echo -e " 3 \033[33m还原之前备份的设置\033[0m" - echo "-----------------------------------------------" - read -r -p "请输入对应数字 > " num + separator_line "=" + content_line "\033[30;46m $UG_WELCOME \033[0m" + separator_line "-" + content_line "\033[33m$UG_CHOOSE_ENV \033[0m" + content_line "\033[0m$UG_TIP_CONFIG\033[0m" + separator_line "-" + content_line " 1 \033[32m$UG_OPTION_1\033[0m" + content_line " 2 \033[36m$UG_OPTION_2\033[0m" + [ -s "$CRASHDIR"/configs.tar.gz ] && content_line " 3 \033[33m$UG_OPTION_3\033[0m" + separator_line "=" + read -r -p "$COMMON_INPUT > " num case "$num" in "" | 1) # 设置运行模式 redir_mod="Mix" - echo "$cputype" | grep -Eq 'linux.*mips.*' && { + content_line "$cputype" | grep -Eq 'linux.*mips.*' && { if grep -qE '^TPROXY$' /proc/net/ip_tables_targets || modprobe xt_TPROXY >/dev/null 2>&1; then redir_mod="Tproxy" else @@ -53,13 +55,13 @@ forwhat() { autostart=enable # 检测IP转发 if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ]; then - echo "-----------------------------------------------" - echo -e "\033[33m检测到你的设备尚未开启ip转发,局域网设备将无法正常连接网络,是否立即开启?\033[0m" - read -r -p "是否开启?(1/0) > " res + separator_line "-" + content_line "\033[33m$UG_IP_FORWARD_WARN\033[0m" + read -r -p "$COMMON_INPUT_R" res [ "$res" = 1 ] && { - echo 'net.ipv4.ip_forward = 1' >>/etc/sysctl.conf + content_line 'net.ipv4.ip_forward = 1' >>/etc/sysctl.conf sysctl -w net.ipv4.ip_forward=1 - } && echo "已成功开启ipv4转发,如未正常开启,请手动重启设备!" || echo "开启失败!请自行谷歌查找当前设备的开启方法!" + } fi # 禁止docker启用的net.bridge.bridge-nf-call-iptables sysctl -w net.bridge.bridge-nf-call-iptables=0 >/dev/null 2>&1 @@ -68,15 +70,14 @@ forwhat() { ;; 2) setconfig redir_mod "Redir" - echo "$cputype" | grep -Eq "linux.*mips.*" && setconfig crashcore "clash" + content_line "$cputype" | grep -Eq "linux.*mips.*" && setconfig crashcore "clash" setconfig common_ports "OFF" setconfig firewall_area '2' break ;; 3) - mv -f "$CFG_PATH.bak" "$CFG_PATH" - echo -e "\033[32m脚本设置已还原!\033[0m" - echo -e "\033[33m请重新启动脚本!\033[0m" + tar -zxf "$CRASHDIR"/configs.tar.gz -C "$CRASHDIR"/configs + content_line "\033[32m$UG_RESTORE_OK\033[0m" exit 0 ;; *) @@ -95,12 +96,10 @@ userguide() { # 检测小内存模式 dir_size=$(dir_avail "$CRASHDIR") if [ "$dir_size" -lt 10240 ]; then - echo "-----------------------------------------------" - echo -e "\033[33m检测到你的安装目录空间不足10M,是否开启小闪存模式?\033[0m" - echo -e "\033[0m开启后核心及数据库文件将被下载到内存中,这将占用一部分内存空间\033[0m" - echo -e "\033[0m每次开机后首次运行服务时都会自动的重新下载相关文件\033[0m" - echo "-----------------------------------------------" - read -r -p "是否开启?(1/0) > " res + separator_line "-" + content_line "\033[33m$UG_ENABLE_LOW_MEM\033[0m" + separator_line "-" + read -r -p "$COMMON_INPUT_R" res [ "$res" = 1 ] && { BINDIR=/tmp/ShellCrash setconfig BINDIR /tmp/ShellCrash "$CRASHDIR"/configs/command.env @@ -110,21 +109,13 @@ userguide() { # 启用推荐的自动任务配置 . "$CRASHDIR"/menus/5_task.sh && task_recom - # 小米设备软固化 - if [ "$systype" = "mi_snapshot" ]; then - echo "-----------------------------------------------" - echo -e "\033[33m检测到为小米路由设备,启用软固化可防止路由升级后丢失SSH\033[0m" - read -r -p "是否启用软固化功能?(1/0) > " res - [ "$res" = 1 ] && mi_autoSSH - fi - # 提示导入订阅或者配置文件 if [ ! -s "$CRASHDIR"/yamls/config.yaml ] && [ ! -s "$CRASHDIR"/jsons/config.json ]; then - echo "-----------------------------------------------" - echo -e "\033[32m是否导入配置文件?\033[0m(这是运行前的最后一步)" - echo -e "\033[0m你必须拥有一份配置文件才能运行服务!\033[0m" - echo "-----------------------------------------------" - read -r -p "现在开始导入?(1/0) > " res + separator_line "-" + content_line "\033[32m$UG_IMPORT_CONFIG\033[0m" + content_line "\033[0m$UG_CONFIG_TIP\033[0m" + separator_line "-" + read -r -p "$UG_CONFIG_RES(1/0) > " res [ "$res" = 1 ] && inuserguide=1 && { . "$CRASHDIR"/menus/6_core_config.sh && set_core_config inuserguide="" @@ -132,10 +123,9 @@ userguide() { fi # 回到主界面 - echo "-----------------------------------------------" - echo -e "\033[36m很好!现在只需要执行启动就可以愉快的使用了!\033[0m" - echo "-----------------------------------------------" - read -r -p "立即启动服务?(1/0) > " res - [ "$res" = 1 ] && start_core && sleep 2 + separator_line "=" + content_line "\033[36m$UG_FINAL_TIP\033[0m" + separator_line "=" + sleep 1 return 0 }