Skip to content

Commit

Permalink
# 彻底解决退格键提示 ^? 或 ^H 以及其他按键无法使用的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Toyo committed Oct 6, 2018
1 parent a594e29 commit f48eac4
Show file tree
Hide file tree
Showing 29 changed files with 340 additions and 297 deletions.
4 changes: 2 additions & 2 deletions adbyby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Uninstall_adbyby(){
check_installed_status
echo "确定要卸载 ADbyby ? (y/N)"
echo
stty erase '^H' && read -p "(默认: n):" unyn
read -e -p "(默认: n):" unyn
[[ -z ${unyn} ]] && unyn="n"
if [[ ${unyn} == [Yy] ]]; then
check_pid
Expand Down Expand Up @@ -195,7 +195,7 @@ else
echo -e " 当前状态: ${Red_font_prefix}未安装${Font_color_suffix}"
fi
echo
stty erase '^H' && read -p " 请输入数字 [1-8]:" num
read -e -p " 请输入数字 [1-8]:" num
case "$num" in
1)
Install_adbyby
Expand Down
22 changes: 11 additions & 11 deletions aria2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ check_new_ver(){
aria2_new_ver=$(wget --no-check-certificate -qO- https://api.github.com/repos/q3aql/aria2-static-builds/releases | grep -o '"tag_name": ".*"' |head -n 1| sed 's/"//g;s/v//g' | sed 's/tag_name: //g')
if [[ -z ${aria2_new_ver} ]]; then
echo -e "${Error} Aria2 最新版本获取失败,请手动获取最新版本号[ https://github.com/q3aql/aria2-static-builds/releases ]"
stty erase '^H' && read -p "请输入版本号 [ 格式如 1.34.0 ] :" aria2_new_ver
read -e -p "请输入版本号 [ 格式如 1.34.0 ] :" aria2_new_ver
[[ -z "${aria2_new_ver}" ]] && echo "取消..." && exit 1
else
echo -e "${Info} 检测到 Aria2 最新版本为 [ ${aria2_new_ver} ]"
Expand All @@ -83,7 +83,7 @@ check_ver_comparison(){
[[ -z ${aria2_now_ver} ]] && echo -e "${Error} Brook 当前版本获取失败 !" && exit 1
if [[ "${aria2_now_ver}" != "${aria2_new_ver}" ]]; then
echo -e "${Info} 发现 Aria2 已有新版本 [ ${aria2_new_ver} ](当前版本:${aria2_now_ver})"
stty erase '^H' && read -p "是否更新(会中断当前下载任务,请注意) ? [Y/n] :" yn
read -e -p "是否更新(会中断当前下载任务,请注意) ? [Y/n] :" yn
[[ -z "${yn}" ]] && yn="y"
if [[ $yn == [Yy] ]]; then
check_pid
Expand Down Expand Up @@ -211,7 +211,7 @@ Set_aria2(){
${Green_font_prefix}3.${Font_color_suffix} 修改 Aria2 文件下载位置
${Green_font_prefix}4.${Font_color_suffix} 修改 Aria2 密码+端口+文件下载位置
${Green_font_prefix}5.${Font_color_suffix} 手动 打开配置文件修改" && echo
stty erase '^H' && read -p "(默认: 取消):" aria2_modify
read -e -p "(默认: 取消):" aria2_modify
[[ -z "${aria2_modify}" ]] && echo "已取消..." && exit 1
if [[ ${aria2_modify} == "1" ]]; then
Set_aria2_RPC_passwd
Expand All @@ -238,7 +238,7 @@ Set_aria2_RPC_passwd(){
aria2_passwd_1=${aria2_passwd}
fi
echo -e "请输入要设置的 Aria2 RPC密码(旧密码为:${Green_font_prefix}${aria2_passwd_1}${Font_color_suffix})"
stty erase '^H' && read -p "(默认密码: 随机生成 密码请不要包含等号 = 和井号 #):" aria2_RPC_passwd
read -e -p "(默认密码: 随机生成 密码请不要包含等号 = 和井号 #):" aria2_RPC_passwd
echo
[[ -z "${aria2_RPC_passwd}" ]] && aria2_RPC_passwd=$(date +%s%N | md5sum | head -c 20)
if [[ "${aria2_passwd}" != "${aria2_RPC_passwd}" ]]; then
Expand Down Expand Up @@ -278,7 +278,7 @@ Set_aria2_RPC_port(){
aria2_port_1=${aria2_port}
fi
echo -e "请输入要设置的 Aria2 RPC端口(旧端口为:${Green_font_prefix}${aria2_port_1}${Font_color_suffix})"
stty erase '^H' && read -p "(默认端口: 6800):" aria2_RPC_port
read -e -p "(默认端口: 6800):" aria2_RPC_port
echo
[[ -z "${aria2_RPC_port}" ]] && aria2_RPC_port="6800"
if [[ "${aria2_port}" != "${aria2_RPC_port}" ]]; then
Expand Down Expand Up @@ -324,7 +324,7 @@ Set_aria2_RPC_dir(){
aria2_dir_1=${aria2_dir}
fi
echo -e "请输入要设置的 Aria2 文件下载位置(旧位置为:${Green_font_prefix}${aria2_dir_1}${Font_color_suffix})"
stty erase '^H' && read -p "(默认位置: /usr/local/caddy/www/aria2/Download):" aria2_RPC_dir
read -e -p "(默认位置: /usr/local/caddy/www/aria2/Download):" aria2_RPC_dir
[[ -z "${aria2_RPC_dir}" ]] && aria2_RPC_dir="/usr/local/caddy/www/aria2/Download"
echo
if [[ -d "${aria2_RPC_dir}" ]]; then
Expand Down Expand Up @@ -375,7 +375,7 @@ ${Green_font_prefix}2.${Font_color_suffix} 一会自动打开配置文件后,
${Green_font_prefix}3.${Font_color_suffix} 如果要退出并保存文件,那么按 ${Green_font_prefix}Ctrl+X键${Font_color_suffix} 后,输入 ${Green_font_prefix}y${Font_color_suffix} 后,再按一下 ${Green_font_prefix}回车键${Font_color_suffix} 即可。
${Green_font_prefix}4.${Font_color_suffix} 如果要退出并不保存文件,那么按 ${Green_font_prefix}Ctrl+X键${Font_color_suffix} 后,输入 ${Green_font_prefix}n${Font_color_suffix} 即可。
${Green_font_prefix}5.${Font_color_suffix} 如果你想在本地编辑配置文件,那么配置文件位置: ${Green_font_prefix}/root/.aria2/aria2.conf${Font_color_suffix} (注意是隐藏目录) 。" && echo
stty erase '^H' && read -p "如果已经理解 nano 使用方法,请按任意键继续,如要取消请使用 Ctrl+C 。" var
read -e -p "如果已经理解 nano 使用方法,请按任意键继续,如要取消请使用 Ctrl+C 。" var
nano "${aria2_conf}"
Read_config
if [[ ${aria2_port_old} != ${aria2_port} ]]; then
Expand Down Expand Up @@ -436,7 +436,7 @@ Update_bt_tracker(){
if [[ -z "${crontab_update_status}" ]]; then
echo && echo -e "当前自动更新模式: ${Red_font_prefix}未开启${Font_color_suffix}" && echo
echo -e "确定要开启 ${Green_font_prefix}Aria2 自动更新 BT-Tracker服务器${Font_color_suffix} 功能吗?(一般情况下会加强BT下载效果)[Y/n]"
stty erase '^H' && read -p "注意:该功能会定时重启 Aria2!(默认: y):" crontab_update_status_ny
read -e -p "注意:该功能会定时重启 Aria2!(默认: y):" crontab_update_status_ny
[[ -z "${crontab_update_status_ny}" ]] && crontab_update_status_ny="y"
if [[ ${crontab_update_status_ny} == [Yy] ]]; then
crontab_update_start
Expand All @@ -446,7 +446,7 @@ Update_bt_tracker(){
else
echo && echo -e "当前自动更新模式: ${Green_font_prefix}已开启${Font_color_suffix}" && echo
echo -e "确定要关闭 ${Red_font_prefix}Aria2 自动更新 BT-Tracker服务器${Font_color_suffix} 功能吗?(一般情况下会加强BT下载效果)[y/N]"
stty erase '^H' && read -p "注意:该功能会定时重启 Aria2!(默认: n):" crontab_update_status_ny
read -e -p "注意:该功能会定时重启 Aria2!(默认: n):" crontab_update_status_ny
[[ -z "${crontab_update_status_ny}" ]] && crontab_update_status_ny="n"
if [[ ${crontab_update_status_ny} == [Yy] ]]; then
crontab_update_stop
Expand Down Expand Up @@ -504,7 +504,7 @@ Uninstall_aria2(){
check_installed_status "un"
echo "确定要卸载 Aria2 ? (y/N)"
echo
stty erase '^H' && read -p "(默认: n):" unyn
read -e -p "(默认: n):" unyn
[[ -z ${unyn} ]] && unyn="n"
if [[ ${unyn} == [Yy] ]]; then
crontab -l > "$file_1/crontab.bak"
Expand Down Expand Up @@ -601,7 +601,7 @@ else
echo -e " 当前状态: ${Red_font_prefix}未安装${Font_color_suffix}"
fi
echo
stty erase '^H' && read -p " 请输入数字 [0-10]:" num
read -e -p " 请输入数字 [0-10]:" num
case "$num" in
0)
Update_Shell
Expand Down
16 changes: 8 additions & 8 deletions ban_iptables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ ENTER_Ban_KEY_WORDS_type(){
1. 手动输入(只支持单个关键词)
2. 本地文件读取(支持批量读取关键词,每行一个关键词)
3. 网络地址读取(支持批量读取关键词,每行一个关键词)" && echo
stty erase '^H' && read -p "(默认: 1. 手动输入):" key_word_type
read -e -p "(默认: 1. 手动输入):" key_word_type
fi
[[ -z "${key_word_type}" ]] && key_word_type="1"
if [[ ${key_word_type} == "1" ]]; then
Expand Down Expand Up @@ -287,7 +287,7 @@ ENTER_Ban_PORT(){
多端口:25,26,465,587(多个端口用英文逗号分割)
连续端口段:25:587(25-587之间的所有端口)" && echo
fi
stty erase '^H' && read -p "(回车默认取消):" PORT
read -e -p "(回车默认取消):" PORT
[[ -z "${PORT}" ]] && echo "已取消..." && View_ALL && exit 0
}
ENTER_Ban_KEY_WORDS(){
Expand All @@ -299,12 +299,12 @@ ENTER_Ban_KEY_WORDS(){
关键词:www.youtube.com,即禁止访问任何包含关键词 www.youtube.com 的域名(子域名屏蔽)。
更多效果自行测试(如关键词 .zip 即可禁止下载任何 .zip 后缀的文件)。" && echo
fi
stty erase '^H' && read -p "(回车默认取消):" key_word
read -e -p "(回车默认取消):" key_word
[[ -z "${key_word}" ]] && echo "已取消..." && View_ALL && exit 0
}
ENTER_Ban_KEY_WORDS_file(){
echo -e "请输入欲封禁/解封的 关键词本地文件(请使用绝对路径)" && echo
stty erase '^H' && read -p "(默认 读取脚本同目录下的 key_word.txt ):" key_word
read -e -p "(默认 读取脚本同目录下的 key_word.txt ):" key_word
[[ -z "${key_word}" ]] && key_word="key_word.txt"
if [[ -e "${key_word}" ]]; then
key_word=$(cat "${key_word}")
Expand All @@ -315,20 +315,20 @@ ENTER_Ban_KEY_WORDS_file(){
}
ENTER_Ban_KEY_WORDS_url(){
echo -e "请输入欲封禁/解封的 关键词网络文件地址(例如 http://xxx.xx/key_word.txt)" && echo
stty erase '^H' && read -p "(回车默认取消):" key_word
read -e -p "(回车默认取消):" key_word
[[ -z "${key_word}" ]] && echo "已取消..." && View_ALL && exit 0
key_word=$(wget --no-check-certificate -t3 -T5 -qO- "${key_word}")
[[ -z ${key_word} ]] && echo -e "${Error} 网络文件内容为空或访问超时 !" && View_ALL && exit 0
}
ENTER_UnBan_KEY_WORDS(){
View_KEY_WORDS
echo -e "请输入欲解封的 关键词(根据上面的列表输入完整准确的 关键词)" && echo
stty erase '^H' && read -p "(回车默认取消):" key_word
read -e -p "(回车默认取消):" key_word
[[ -z "${key_word}" ]] && echo "已取消..." && View_ALL && exit 0
}
ENTER_UnBan_PORT(){
echo -e "请输入欲解封的 端口(根据上面的列表输入完整准确的 端口,包括逗号、冒号)" && echo
stty erase '^H' && read -p "(回车默认取消):" PORT
read -e -p "(回车默认取消):" PORT
[[ -z "${PORT}" ]] && echo "已取消..." && View_ALL && exit 0
}
Ban_PORT(){
Expand Down Expand Up @@ -463,7 +463,7 @@ echo && echo -e " iptables防火墙 封禁管理脚本 ${Red_font_prefix}[v${sh_
————————————
${Green_font_prefix}12.${Font_color_suffix} 升级脚本
" && echo
stty erase '^H' && read -p " 请输入数字 [0-12]:" num
read -e -p " 请输入数字 [0-12]:" num
case "$num" in
0)
View_ALL
Expand Down
43 changes: 43 additions & 0 deletions base64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

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}" && Error="${Red_font_prefix}[错误]${Font_color_suffix}" && Tip="${Green_font_prefix}[注意]${Font_color_suffix}"

urlsafe_base64(){
date=$(echo -n "$1"|base64|sed ':a;N;s/\n/ /g;ta'|sed 's/ //g;s/=//g;s/+/-/g;s/\//_/g')
echo -e "${date}"
}
urlsafe_base64_d(){
date=$(echo -n "$1"|sed 's/-/+/g;s/_/\//g'|base64 -d)
echo -e "${date}"
}
set_type(){
echo -e "你要干什么呢?
${Green_font_prefix}1.${Font_color_suffix} URL_Safe_Base64 加密文本
${Green_font_prefix}2.${Font_color_suffix} URL_Safe_Base64 解密文本"
read -e -p "(默认:1):" enter_type
[[ -z "${enter_type}" ]] && enter_type="1"
if [[ ${enter_type} == "1" ]]; then
set_text "1"
elif [[ ${enter_type} == "2" ]]; then
set_text "2"
else
set_text "1"
fi
}
set_text(){
echo "请输入要 URL_Safe_Base64 加密/解密 的文本"
read -e -p "(默认回车取消):" text
[[ -z "${text}" ]] && echo "已取消..." && exit 1
[[ -z "${enter_type}" ]] && enter_type="1"
if [[ $1 == "1" ]]; then
echo && urlsafe_base64 "${text}" && echo
elif [[ $1 == "2" ]]; then
echo && urlsafe_base64_d "${text}" && echo
else
echo && urlsafe_base64 "${text}" && echo
fi
}
set_type
6 changes: 3 additions & 3 deletions bbr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Set_latest_new_version(){
echo -e "请输入 要下载安装的Linux内核版本(BBR) ${Green_font_prefix}[ 格式: x.xx.xx ,例如: 4.9.96 ]${Font_color_suffix}
${Tip} 内核版本列表请去这里获取:${Green_font_prefix}[ http://kernel.ubuntu.com/~kernel-ppa/mainline/ ]${Font_color_suffix}
建议使用${Green_font_prefix}稳定版本:4.9.XX ${Font_color_suffix},4.9 以上版本属于测试版,稳定版与测试版同步更新,BBR 加速效果无区别。"
stty erase '^H' && read -p "(直接回车,自动获取最新稳定版本):" latest_version
read -e -p "(直接回车,自动获取最新稳定版本):" latest_version
[[ -z "${latest_version}" ]] && get_latest_new_version
echo
}
Expand Down Expand Up @@ -111,7 +111,7 @@ del_deb_over(){
update-grub
addsysctl
echo -e "${Tip} 重启VPS后,请运行脚本查看 BBR 是否正常加载,运行命令: ${Green_background_prefix} bash ${file}/bbr.sh status ${Font_color_suffix}"
stty erase '^H' && read -p "需要重启VPS后,才能开启BBR,是否现在重启 ? [Y/n] :" yn
read -e -p "需要重启VPS后,才能开启BBR,是否现在重启 ? [Y/n] :" yn
[[ -z "${yn}" ]] && yn="y"
if [[ $yn == [Yy] ]]; then
echo -e "${Info} VPS 重启中..."
Expand Down Expand Up @@ -208,7 +208,7 @@ stopbbr(){
sysctl -p
sleep 1s

stty erase '^H' && read -p "需要重启VPS后,才能彻底停止BBR,是否现在重启 ? [Y/n] :" yn
read -e -p "需要重启VPS后,才能彻底停止BBR,是否现在重启 ? [Y/n] :" yn
[[ -z "${yn}" ]] && yn="y"
if [[ $yn == [Yy] ]]; then
echo -e "${Info} VPS 重启中..."
Expand Down
Loading

0 comments on commit f48eac4

Please sign in to comment.