更新 bin/ZeroWrt
Signed-off-by: zhao <zhao@noreply.localhost>
This commit is contained in:
parent
8e19ee4cf8
commit
2a6617db2f
125
bin/ZeroWrt
125
bin/ZeroWrt
@ -46,11 +46,12 @@ show_menu() {
|
|||||||
color_output "\e[36m┃\e[0m 4. 恢复出厂设置 \e[36m┃\e[0m"
|
color_output "\e[36m┃\e[0m 4. 恢复出厂设置 \e[36m┃\e[0m"
|
||||||
color_output "\e[36m┃\e[0m 5. 一键换源 \e[36m┃\e[0m"
|
color_output "\e[36m┃\e[0m 5. 一键换源 \e[36m┃\e[0m"
|
||||||
color_output "\e[36m┃\e[0m 6. 一键部署 \e[36m┃\e[0m"
|
color_output "\e[36m┃\e[0m 6. 一键部署 \e[36m┃\e[0m"
|
||||||
color_output "\e[36m┃\e[0m 7. 检测更新 \e[36m┃\e[0m"
|
color_output "\e[36m┃\e[0m 7. IPv6 开关 \e[36m┃\e[0m"
|
||||||
|
color_output "\e[36m┃\e[0m 8. 检测更新 \e[36m┃\e[0m"
|
||||||
color_output "\e[36m┃\e[0m 0. 退出 \e[36m┃\e[0m"
|
color_output "\e[36m┃\e[0m 0. 退出 \e[36m┃\e[0m"
|
||||||
color_output "\e[36m┃ ┃\e[0m"
|
color_output "\e[36m┃ ┃\e[0m"
|
||||||
color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m"
|
color_output "\e[36m┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\e[0m"
|
||||||
read -p "$(color_output "\e[33m请输入您的选择 [0-7]: \e[0m")" choice
|
read -p "$(color_output "\e[33m请输入您的选择 [0-8]: \e[0m")" choice
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
1) change_ip ;;
|
1) change_ip ;;
|
||||||
2) change_password ;;
|
2) change_password ;;
|
||||||
@ -58,7 +59,8 @@ show_menu() {
|
|||||||
4) reset_config ;;
|
4) reset_config ;;
|
||||||
5) change_source ;;
|
5) change_source ;;
|
||||||
6) install_apps ;;
|
6) install_apps ;;
|
||||||
7) check_update ;;
|
7) configure_ipv6 ;;
|
||||||
|
8) check_update ;;
|
||||||
0) exit 0 ;;
|
0) exit 0 ;;
|
||||||
*) echo "无效选项,请重新输入"; show_menu ;;
|
*) echo "无效选项,请重新输入"; show_menu ;;
|
||||||
esac
|
esac
|
||||||
@ -85,7 +87,21 @@ change_password() {
|
|||||||
color_output "\e[34m[更改管理员密码]\e[0m"
|
color_output "\e[34m[更改管理员密码]\e[0m"
|
||||||
read -p "请输入新的管理员密码: " new_password
|
read -p "请输入新的管理员密码: " new_password
|
||||||
if [[ -n "$new_password" ]]; then
|
if [[ -n "$new_password" ]]; then
|
||||||
echo -e "$new_password\n$new_password" | passwd root
|
# 使用 openssl 生成密码哈希,使用 -1 参数生成 MD5 格式的密码哈希
|
||||||
|
password_hash=$(openssl passwd -1 "$new_password")
|
||||||
|
|
||||||
|
# 获取当前 shadow 文件的其他行
|
||||||
|
tail -n +2 /etc/shadow > /tmp/shadow.tmp
|
||||||
|
|
||||||
|
# 创建新的 root 行
|
||||||
|
echo "root:$password_hash:0:0:99999:7:::" > /etc/shadow
|
||||||
|
|
||||||
|
# 添加其他行
|
||||||
|
cat /tmp/shadow.tmp >> /etc/shadow
|
||||||
|
|
||||||
|
# 清理临时文件
|
||||||
|
rm -f /tmp/shadow.tmp
|
||||||
|
|
||||||
color_output "\e[32m管理员密码已成功更改。\e[0m"
|
color_output "\e[32m管理员密码已成功更改。\e[0m"
|
||||||
else
|
else
|
||||||
color_output "\e[31m无效的密码,操作取消。\e[0m"
|
color_output "\e[31m无效的密码,操作取消。\e[0m"
|
||||||
@ -320,7 +336,106 @@ install_apps() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# 7. 检测更新
|
# 7. IPv6 开关
|
||||||
|
configure_ipv6() {
|
||||||
|
color_output "\e[34m[IPv6 设置]\e[0m"
|
||||||
|
|
||||||
|
# 检查是否为 PPPoE 模式
|
||||||
|
local wan_proto=$(uci -q get network.wan.proto)
|
||||||
|
if [ "$wan_proto" != "pppoe" ]; then
|
||||||
|
color_output "\e[31m错误: 无法开启 IPv6\e[0m"
|
||||||
|
color_output "\e[31m当前上网方式为: $wan_proto\e[0m"
|
||||||
|
color_output "\e[31m请先切换为 PPPoE 模式\e[0m"
|
||||||
|
read -p "按 Enter 键返回菜单..."
|
||||||
|
show_menu
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 检查当前状态
|
||||||
|
local current_ra=$(uci -q get dhcp.lan.ra)
|
||||||
|
local current_dhcpv6=$(uci -q get dhcp.lan.dhcpv6)
|
||||||
|
local current_ndp=$(uci -q get dhcp.lan.ndp)
|
||||||
|
local current_filter_aaaa=$(uci -q get dhcp.@dnsmasq[0].filter_aaaa)
|
||||||
|
|
||||||
|
if [ "$current_ra" = "server" ] && [ "$current_dhcpv6" = "server" ]; then
|
||||||
|
status_text="已开启"
|
||||||
|
else
|
||||||
|
status_text="已关闭"
|
||||||
|
fi
|
||||||
|
|
||||||
|
color_output "\e[36m当前 IPv6 状态: $status_text\e[0m"
|
||||||
|
color_output "\e[36m请选择操作:\e[0m"
|
||||||
|
color_output "1. 开启 IPv6"
|
||||||
|
color_output "2. 关闭 IPv6"
|
||||||
|
color_output "0. 返回主菜单"
|
||||||
|
|
||||||
|
read -p "请输入选择 [0-2]: " ipv6_choice
|
||||||
|
|
||||||
|
case "$ipv6_choice" in
|
||||||
|
1)
|
||||||
|
# 开启 IPv6
|
||||||
|
# RA 服务设置为服务模式
|
||||||
|
uci set dhcp.lan.ra='server'
|
||||||
|
# DHCPv6 服务设置为服务模式
|
||||||
|
uci set dhcp.lan.dhcpv6='server'
|
||||||
|
# IPv6 分配长度设置为64
|
||||||
|
uci set dhcp.lan.ndp='64'
|
||||||
|
# 取消过滤 IPv6 AAAA 记录
|
||||||
|
uci set dhcp.@dnsmasq[0].filter_aaaa='0'
|
||||||
|
# 保存设置
|
||||||
|
uci commit dhcp
|
||||||
|
|
||||||
|
# 重启相关服务(重定向输出)
|
||||||
|
/etc/init.d/odhcpd restart >/dev/null 2>&1
|
||||||
|
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||||
|
|
||||||
|
color_output "\e[32mIPv6 已开启!\e[0m"
|
||||||
|
color_output "\e[32m- RA 服务: 服务模式\e[0m"
|
||||||
|
color_output "\e[32m- DHCPv6 服务: 服务模式\e[0m"
|
||||||
|
color_output "\e[32m- IPv6 分配长度: 64\e[0m"
|
||||||
|
color_output "\e[32m- IPv6 AAAA 记录过滤: 已关闭\e[0m"
|
||||||
|
;;
|
||||||
|
|
||||||
|
2)
|
||||||
|
# 关闭 IPv6
|
||||||
|
# RA 服务设置为已禁用
|
||||||
|
uci set dhcp.lan.ra='disabled'
|
||||||
|
# DHCPv6 服务设置为已禁用
|
||||||
|
uci set dhcp.lan.dhcpv6='disabled'
|
||||||
|
# IPv6 分配长度设置为已禁用
|
||||||
|
uci set dhcp.lan.ndp='disabled'
|
||||||
|
# 开启过滤 IPv6 AAAA 记录
|
||||||
|
uci set dhcp.@dnsmasq[0].filter_aaaa='1'
|
||||||
|
# 保存设置
|
||||||
|
uci commit dhcp
|
||||||
|
|
||||||
|
# 重启相关服务(重定向输出)
|
||||||
|
/etc/init.d/odhcpd restart >/dev/null 2>&1
|
||||||
|
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||||
|
|
||||||
|
color_output "\e[32mIPv6 已关闭!\e[0m"
|
||||||
|
color_output "\e[32m- RA 服务: 已禁用\e[0m"
|
||||||
|
color_output "\e[32m- DHCPv6 服务: 已禁用\e[0m"
|
||||||
|
color_output "\e[32m- IPv6 分配长度: 已禁用\e[0m"
|
||||||
|
color_output "\e[32m- IPv6 AAAA 记录过滤: 已开启\e[0m"
|
||||||
|
;;
|
||||||
|
|
||||||
|
0)
|
||||||
|
show_menu
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
color_output "\e[31m无效选择\e[0m"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
sleep 2
|
||||||
|
read -p "按 Enter 键返回菜单..."
|
||||||
|
show_menu
|
||||||
|
}
|
||||||
|
|
||||||
|
# 8. 检测更新
|
||||||
check_update() {
|
check_update() {
|
||||||
color_output "\e[34m[检测更新]\e[0m"
|
color_output "\e[34m[检测更新]\e[0m"
|
||||||
color_output "正在检查更新..."
|
color_output "正在检查更新..."
|
||||||
|
Loading…
Reference in New Issue
Block a user