由于BE6500PRO开机会重置文件,因此使用脚本实现Overlay挂载和软件源更换
一、挂载Overlay
- 在/data/scripts文件夹下创建脚本
vi /data/scripts/auto_overlay.sh
粘贴以下内容
#!/bin/sh
script_dir="/data/scripts"
overlay_dir="/data/other/overlay"
overlay_mount_point="/overlay"
mount_overlay() {
# Check and create overlay directory and its subdirectories
[ -e overlay_dir ] || mkdir -poverlay_dir
[ -e overlay_dir/upper ] || mkdir -poverlay_dir/upper
[ -e overlay_dir/work ] || mkdir -poverlay_dir/work
# Bind the overlay directory to the mount point
mount --bind overlay_diroverlay_mount_point
# Source functions from the preinit script
. /lib/functions/preinit.sh
# Use fopivot to combine upper and work directories with /rom
fopivot overlay_mount_point/upperoverlay_mount_point/work /rom 1
# Move and mount various directories to new locations
/bin/mount -o noatime,move /rom/data /data 2>&-
/bin/mount -o noatime,move /rom/etc /etc 2>&-
/bin/mount -o noatime,move /rom/ini /ini 2>&-
/bin/mount -o noatime,move /rom/userdisk /userdisk 2>&-
echo -e "\033[32m Overlay mount complete. \033[0m"
}
install() {
# Install overlay mount
mount_overlay
# Set firewall rules to include the auto mount script
uci set firewall.auto_overlay=include
uci set firewall.auto_overlay.type='script'
uci set firewall.auto_overlay.path="{script_dir}/auto_overlay.sh"
uci set firewall.auto_overlay.enabled='1'
uci commit firewall
echo -e "\033[32m Overlay auto-mount installed. \033[0m"
}
uninstall() {
# Delete the auto mount firewall rule
uci delete firewall.auto_overlay
uci commit firewall
echo -e "\033[33m Overlay auto-mount uninstalled. \033[0m"
}
main() {
# If no parameter is provided, mount the overlay
[ -z "1" ] && mount_overlay && return
case "1" in
install)
install
;;
uninstall)
uninstall
;;
*)
# Handle unknown parameters
echo -e "\033[31m Unknown parameter:1 \033[0m"
return 1
;;
esac
}
main "$@"
:wq
保存退出
BE6500PRO的/data/other_vol和/data/other分区较大,此处选择了/data/other作为/overlay的挂载点
- 添加脚本运行权限
chmod +x /data/scripts/auto_overlay.sh
3.安装自动挂载服务
/data/scripts/auto_overlay.sh install
如果要卸载服务:
/data/scripts/auto_overlay.sh uninstall
二、更换软件源
小米官方固件内的软件源并不存在,我们需要更换他
同样使用脚本实现自动更换
1、在/data/scripts文件夹下创建脚本
vi /data/scripts/change_opkg_sources.sh
右键粘贴以下内容
#!/bin/sh
script_dir="/data/scripts"
change_sources() {
# Modify Architecture Arguments
cp /etc/opkg.conf /etc/opkg.conf.bak
echo -e "arch all 100\narch aarch64_cortex-a53_neon-vfpv4 200\narch aarch64_cortex-a53 300" >> /etc/opkg.conf
# Change opkg sources
mv /etc/opkg/distfeeds.conf /etc/opkg/distfeeds.conf.bak
echo -e "src/gz openwrt_base http://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base" >> /etc/opkg/distfeeds.conf
echo -e "src/gz openwrt_luci http://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/luci" >> /etc/opkg/distfeeds.conf
echo -e "src/gz openwrt_packages http://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/packages" >> /etc/opkg/distfeeds.conf
echo -e "src/gz openwrt_routing http://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/routing" >> /etc/opkg/distfeeds.conf
echo -e "src/gz openwrt_telephony http://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/telephony" >> /etc/opkg/distfeeds.conf
}
install() {
change_sources
#Auto Start Using Firewall
uci set firewall.change_opkg_sources=include
uci set firewall.change_opkg_sources.type='script'
uci set firewall.change_opkg_sources.path="{script_dir}/change_opkg_sources.sh"
uci set firewall.change_opkg_sources.enabled='1'
uci commit firewall
echo -e "\033[32m Auto Opkg Source Change installed. \033[0m"
}
uninstall() {
# Remove firewall rules
uci delete change_opkg_sources
uci commit firewall
mv /etc/opkg/distfeeds.conf.bak /etc/opkg/distfeeds.conf
mv /etc/opkg.conf.bak /etc/opkg.conf
echo -e "\033[33m Auto Opkg Source Change uninstalled. \033[0m"
}
main() {
[ -z "1" ] && change_sources && return
case "1" in
install)
install
;;
uninstall)
uninstall
;;
*)
echo -e "\033[31m Unknown parameter:1 \033[0m"
return 1
;;
esac
}
main "$@"
:wq
保存退出
- 添加脚本运行权限
chmod +x /data/scripts/change_opkg_sources.sh
3.安装自动挂载服务
/data/scripts/change_opkg_sources.sh install
如果要卸载服务:
/data/scripts/change_opkg_sources.sh uninstall
4、更新软件包列表
opkg update
然后就可以安装一些openwrt软件了,比如要按安装sftp
opkg install openssh-sftp-server
文章有(9)条网友点评
博主在解锁SSH之后有遇到指示灯橙色常亮和无法绑定米家的问题吗,从草东日记来的()
@ Shanwer 没有遇到过诶,指示灯橙色常亮?是否正常开机,如果用脚本解锁ssh的话照理不会影响到米家的绑定,我这边一切正常
@ moonlight 正常开机,甚至正常挂shellclash做旁路由上网,就是指示灯不对和米家上不了()
@ Shanwer 不行的话就重置试试,反正telnet开着
@ moonlight 重置过几次了,没啥用,因为能上网啥的就摆了()
@ Shanwer 那就没办法了,可能是哪边搞坏了,下个官网固件覆盖升级下试试
@ moonlight 这个也不行(
@ Shanwer 走售后吧
@ moonlight 昨天在走售后前打算把telnet和ssh都关掉,删掉clash,跑了一下
nvram set ssh_en=0
nvram set telnet_en=0
nvram set uart_en=0
nvram commit
reboot
然后恢复出厂设置,没想到指示灯闪了,我再重新绑定居然绑定上了,然后取消售后申请,真奇怪