Compare commits

..

No commits in common. "master" and "20231116" have entirely different histories.

17 changed files with 120 additions and 879 deletions

2
.gitignore vendored
View File

@ -31,5 +31,3 @@
*.out *.out
*.app *.app
.DS_Store .DS_Store
udisk/create-img.sh
udisk/onescript.sh

178
README.md
View File

@ -1,158 +1,70 @@
# GL-iNet 系列路由器 一键iStoreOS风格化脚本
[![GitHub](https://img.shields.io/github/license/wukongdaily/gl-inet-onescript.svg?label=LICENSE&logo=github&logoColor=%20)](https://github.com/wukongdaily/gl-inet-onescript/blob/master/LICENSE) [![GitHub](https://img.shields.io/github/license/wukongdaily/gl-inet-onescript.svg?label=LICENSE&logo=github&logoColor=%20)](https://github.com/wukongdaily/gl-inet-onescript/blob/master/LICENSE)
![GitHub Stars](https://img.shields.io/github/stars/wukongdaily/gl-inet-onescript.svg?style=flat&logo=appveyor&label=Stars&logo=github) ![GitHub Stars](https://img.shields.io/github/stars/wukongdaily/gl-inet-onescript.svg?style=flat&logo=appveyor&label=Stars&logo=github)
![GitHub Forks](https://img.shields.io/github/forks/wukongdaily/gl-inet-onescript.svg?style=flat&logo=appveyor&label=Forks&logo=github) ![GitHub Forks](https://img.shields.io/github/forks/wukongdaily/gl-inet-onescript.svg?style=flat&logo=appveyor&label=Forks&logo=github)
***
# gl-inet-onescript
This script is specifically designed for GL-iNet routers to quickly install essential system software. Even if the user resets the system, there is no need to worry because this script can complete complex and tedious tasks with a single click.<br>
[切换到中文使用指南](https://github.com/wukongdaily/gl-inet-onescript/wiki/%E4%B8%AD%E6%96%87%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97)
# TipsHow to Use SSH
https://github.com/wukongdaily/HowToUseSSH
# one scripthas Menu
<img alt="Static Badge" src="https://img.shields.io/badge/MT3000-E70D0D?style=for-the-badge&label=MT2500A&labelColor=8A2BE2">
## 🤔 这是什么?
该项目可以让MT2500/MT3000/MT6000路由器在不刷机情况下,一键变成iStoreOS风格。<br><br>
<img alt="Static Badge" src="https://img.shields.io/badge/MT6000-0?style=flat-square&logoColor=8A2BE2&label=%E5%9E%8B%E5%8F%B7&labelColor=000000&color=336666">
<img alt="Static Badge" src="https://img.shields.io/badge/MT2500A-0?style=flat-square&logoColor=8A2BE2&label=%E5%9E%8B%E5%8F%B7&labelColor=000000&color=D94600">
<img alt="Static Badge" src="https://img.shields.io/badge/MT3000-0?style=flat-square&logoColor=8A2BE2&label=%E5%9E%8B%E5%8F%B7&labelColor=000000&color=2828FF">
## 💡 特色功能
- 💻 支持`一键安装iStoreOS风格`
- 💻 支持`一键安装紫色的Argon主题`
- 💻 支持`一键安装文件管理器`
- 🔑 支持`一键设置MT-3000风扇开始工作的温度`
- 🌏 支持`一键部署Docker运行环境`
- 🌏 支持`一键安装docker-compose`
- 🐋 支持`一键安装GL原厂adguardhome`
- 📕 支持`一键恢复原厂的OPKG软件源`
- 🔑 支持`MT-3000 一键更换分区到U盘`
- 💡 使用条件GL-iNet 原厂固件(非测试版、预览版)
- GL-inet MT-6000✅
- GL-inet MT-3000 ✅
- GL-inet MT-2500 ✅ 固件版本4.5.0(最好降级到此版本)
- OrangePi Zero3(官方Openwrt镜像)
## 🚀 快速上手
### 1. SSH连接到路由器,或者在路由器终端执行如下命令
```bash
wget -O gl-inet.sh https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/gl-inet.sh && chmod +x gl-inet.sh && ./gl-inet.sh
``` ```
wget -O /tmp/gl-inet.sh https://raw.githubusercontent.com/wukongdaily/gl-inet-onescript/master/gl-inet.sh && chmod +x /tmp/gl-inet.sh && /tmp/gl-inet.sh
### 下次如何调用? 输入快捷键 g 即可
```bash
g
```
### 2.单独安装Docker
```bash
wget -O do_docker.sh https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/docker/do_docker.sh && chmod +x do_docker.sh && ./do_docker.sh
```
### 3.单独安装iStore商店
```bash
wget -O /tmp/reinstall_istore.sh https://gitee.com/wukongdaily/gl_onescript/raw/master/reinstall_istore.sh && chmod +x /tmp/reinstall_istore.sh && /tmp/reinstall_istore.sh
``` ```
### 4.单独安装文件管理器 ***
```bash
wget -O /tmp/reinstall_istore.sh https://gitee.com/wukongdaily/gl_onescript/raw/master/reinstall_istore.sh && chmod +x /tmp/reinstall_istore.sh && /tmp/reinstall_istore.sh # onekey for iStore
```
wget -O /tmp/reinstall_istore.sh https://raw.githubusercontent.com/wukongdaily/gl-inet-onescript/master/reinstall_istore.sh && chmod +x /tmp/reinstall_istore.sh && /tmp/reinstall_istore.sh
```
# Install iStore offline by using a USB flash drive
https://telegra.ph/install-istore-for-mt3000-11-03 <br>
# onekey for File Manager
```
wget -O /tmp/reinstall_istore.sh https://raw.githubusercontent.com/wukongdaily/gl-inet-onescript/master/reinstall_istore.sh && chmod +x /tmp/reinstall_istore.sh && /tmp/reinstall_istore.sh
/tmp/is-opkg install app-meta-linkease /tmp/is-opkg install app-meta-linkease
``` ```
# Important Note:↓
### After the menu appears, press H to return to the old version of the video
### 5.新手ssh连接注意事项
https://github.com/wukongdaily/HowToUseSSH
### 6.使用独立版docker-compose
```bash
docker-compose version
```
```bash
# 注意上述代码中使用的是独立版docker-compose并非标准安装的docker compose
# 区别就是中间没有空格是一个独立的可执行文件。当然这个叫做docker-compose的可执行文件
# 你可以任意命名不过就是习惯这样写还有的人重命名为docker_compose之类的都可以。
```
### 辅助视频教程⬇️
https://www.bilibili.com/video/BV1YJ4m1L7A3/
# Docker面板的选择
## 🔑 安装1panel 面板 来管理Docker 容器
### 可以使用 docker离线包加载 # Features
```bash * At present, it is only compatible with GL-iNet MT2500 and MT-3000.
国内地址 https://pan.baidu.com/s/1Zh913sP6rZWXmhC_rKjWQA?pwd=1111 * Change the starting temperature for the MT3000 smart temperature-controlled fan to 45 degrees.
* One-click implementation of the iStoreOS homepage style and installation of the iStore store.
* Set up custom domain hijacking (hostname mapping)<br>
to prevent the issue of Android native TV not connecting to Wi-Fi for the first time.
* Other GL models and functions are under development; adaptations will be made based on audience feedback in the future.
* This script is only for my audience, and I'm not an expert. It's a free tool made for the convenience of viewers.
* press H/h to return to the old version of the video
* If you encounter problems, you can raise an issue, provide screenshots, or attach logs.
#
备选地址 https://drive.google.com/drive/folders/15HL-lHxW9J74Fwwebrg0lMjRsenScWnO
```
### 上传到U盘其他空间(这里注意是/mnt/upan_data)
```bash
docker load < /mnt/upan_data/1panel-arm64.tar.gz
```
```bash
docker run -d \
--name 1panel \
--restart always \
--network host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /www/data/1panel-data:/mnt/data_sda2/1panel_data \
-e TZ=Asia/Shanghai \
moelin/1panel:latest
```
`其中 /mnt/data_sda2/ 可以换成自己实际的路径,最好是空间大点的`
- 默认端口10086
- 默认账户1panel
- 默认密码1panel_password
- 默认入口entrance
## 访问地址
```bash
http://192.168.8.1:10086/entrance
```
## 🔑 安装Fast OS面板 来管理Docker 容器 # Acknowledgments
```bash
docker run -d \
--name fastos \
--restart always \
-p 8081:8081 \
-p 8082:8082 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/docker/:/etc/docker/ \
-v /root/data:/fast/data \
-e FAST_STORE=http://dockernb.com:8300 \
wangbinxingkong/fast:latest
```
### Fast OS 面板离线包
```bash
https://pan.baidu.com/s/1S5jxahCzE-HyIa-mUvOcZQ?pwd=1111
```
## 🗂️ 引用项目 1、Install 'iStore' offline by using a USB flash drive <br>
https://telegra.ph/install-istore-for-mt3000-11-03 <br>
2、Third-party software source<br>
https://dl.openwrt.ai/packages-23.05<br>
https://op.dllkids.xyz/packages<br>
3、iStore app store<br>
https://github.com/linkease/istore<br>
本项目的开发参照了以下项目,感谢这些开源项目的作者:
### istore
https://github.com/linkease/istore
![mt3000](https://github.com/wukongdaily/gl-inet-onescript/assets/143675923/0ff6cb12-0812-4198-b97b-30698da6a8c4)
# 其他docker举例 盒子助手docker版
```bash
docker run -d \
--restart unless-stopped \
--name tvhelper \
-p 2299:22 \
-p 2288:80 \
-v "/mnt/upan_data/tvhelper_data:/tvhelper/shells/data" \
-e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/android-sdk/platform-tools \
wukongdaily/box:latest
```
# 常见问题
- 1、如果你发现运行容器后,访问docker容器的web界面之后路由器的指示灯发生闪烁不用慌其实没有断网。
wan口网线拔了再插上就好了。其实不处理也无所谓的。闪烁也不代表没有网络。不准确的。
- 2、如果你发现运行容器后,访问不了docker容器的web界面。一般重启路由器就能解决。
- 3、请注意为了节省路由器空间,平时上传文件 最好是上传到 /mnt/upan_data 这个目录下。因为这是U盘空间比较大。
# 💰打赏作者💰
<img src="https://github.com/wukongdaily/tvhelper-docker/assets/143675923/1f92c5ba-1b6b-4967-a1ab-20697159badc" width="30%" />

View File

@ -1,220 +0,0 @@
#!/bin/sh
# 定义颜色输出函数
red() { echo -e "\033[31m\033[01m[WARNING] $1\033[0m"; }
green() { echo -e "\033[32m\033[01m[INFO] $1\033[0m"; }
yellow() { echo -e "\033[33m\033[01m[NOTICE] $1\033[0m"; }
blue() { echo -e "\033[34m\033[01m[MESSAGE] $1\033[0m"; }
light_magenta() { echo -e "\033[95m\033[01m[NOTICE] $1\033[0m"; }
light_yellow() { echo -e "\033[93m\033[01m[NOTICE] $1\033[0m"; }
# 获取路由器型号信息
get_router_name() {
cat /tmp/sysinfo/model
}
# 安装依赖应用
install_depends_apps() {
blue "正在安装部署环境的所需要的工具 lsblk 和 fdisk ..."
router_name=$(get_router_name)
case "$router_name" in
*2500* | *3000*)
opkg update >/dev/null 2>&1
if opkg install lsblk fdisk >/dev/null 2>&1; then
green "$router_name 的 lsblk fdisk 工具 安装成功。"
else
red "安装失败。"
exit 1
fi
;;
*6000*)
red "由于 mt6000 的软件源中没有找到 lsblk 和 fdisk ..."
yellow "因此先借用 mt3000 的软件源来安装 lsblk 和 fdisk 工具"
# 备份 /etc/opkg/distfeeds.conf
cp /etc/opkg/distfeeds.conf /etc/opkg/distfeeds.conf.backup
# 先替换为 mt3000 的软件源来安装 lsblk 和 fdisk 工具
mt3000_opkg="https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/mt-3000/distfeeds.conf"
wget -O /etc/opkg/distfeeds.conf ${mt3000_opkg}
green "正在更新为 mt3000 的软件源"
cat /etc/opkg/distfeeds.conf
opkg update
green "再次尝试安装 lsblk 和 fdisk 工具"
if opkg install fdisk lsblk; then
green "$router_name 的 lsblk fdisk 工具 安装成功。"
# 还原软件源
cp /etc/opkg/distfeeds.conf.backup /etc/opkg/distfeeds.conf
else
red "安装失败。"
# 还原软件源
cp /etc/opkg/distfeeds.conf.backup /etc/opkg/distfeeds.conf
exit 1
fi
;;
*)
echo "Router name does not contain '3000', '6000', or '2500'."
;;
esac
}
# 准备USB设备
prepare_usb_device() {
green "现在开始查找USB设备分区请稍后......"
local usb_disk=$(lsblk -dn -o NAME,RM,TYPE | awk '$2=="1" && $3=="disk" {print "/dev/"$1; exit}')
if [ -z "$usb_disk" ]; then
red "未找到USB磁盘。"
exit 1
fi
yellow "找到USB磁盘$usb_disk"
# 清零磁盘开始部分以清除分区表和文件系统签名
dd if=/dev/zero of=$usb_disk bs=1M count=10
sync
# 卸载所有与该磁盘相关的挂载点
unmount_usb_device "$usb_disk"
red "正在重新分区并格式化$usb_disk..."
create_and_format_partition "$usb_disk"
}
# 卸载USB设备
unmount_usb_device() {
for mount in $(mount | grep "$1" | awk '{print $3}'); do
yellow "正在尝试卸载U盘挂载点$mount"
umount $mount || {
red "警告:无法卸载挂载点 $mount。可能有文件正在被访问或权限不足。"
exit 1
}
green "U盘挂载点 $mount 卸载成功。"
done
}
# 创建并格式化分区
create_and_format_partition() {
{
echo o # 创建一个新的空DOS分区表
echo n # 添加一个新分区
echo p # 主分区
echo 1 # 分区号1
echo # 第一个可用扇区(默认)
echo # 最后一个扇区(默认,使用剩余空间)
echo w # 写入并退出
} | fdisk $1 >/dev/null 2>&1
sleep 5
local new_partition="${1}1"
red "正在将U盘 $new_partition 格式化为EXT4文件系统..."
mkfs.ext4 -F $new_partition >/dev/null 2>&1
green "$new_partition 已成功格式化为EXT4文件系统。"
configure_and_start_docker $new_partition
}
# 配置并启动Docker
configure_and_start_docker() {
local new_partition="$1"
local usb_mount_point="/mnt/upan_data"
local docker_root="$usb_mount_point/docker"
mkdir -p $docker_root
green "将U盘 挂载到 $usb_mount_point..."
mount -t ext4 $new_partition $usb_mount_point
if [ $? -ne 0 ]; then
red "挂载失败,脚本退出。"
exit 1
fi
green "U盘挂载成功啦\n"
green "正在创建 Docker 配置文件 /etc/docker/daemon.json"
mkdir -p /etc/docker
echo '{
"bridge": "docker0",
"storage-driver": "overlay2",
"data-root": "'$docker_root'"
}' >/etc/docker/daemon.json
install_docker
configure_docker_to_start_on_boot "$new_partition" "$usb_mount_point"
}
# 安装 Docker 和 dockerd
install_docker() {
green "正在更新 OPKG 软件包..."
opkg update >/dev/null 2>&1
green "正在安装 Docker 及相关服务...请耐心等待一会...大约需要1分钟\n"
opkg install luci-app-dockerman >/dev/null 2>&1
opkg install luci-i18n-dockerman-zh-cn >/dev/null 2>&1
opkg install dockerd --force-depends >/dev/null 2>&1
# 修改 /etc/config/dockerd 文件中的 data_root 配置
sed -i "/option data_root/c\ option data_root '/mnt/upan_data/docker/'" /etc/config/dockerd
}
# 配置 Docker 开机启动
configure_docker_to_start_on_boot() {
local new_partition="$1"
local usb_mount_point="$2"
# 创建并配置启动脚本
green "正在设置 Docker 跟随系统启动的文件:/etc/init.d/docker"
cat <<EOF >/etc/init.d/docker
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
PROG="/usr/bin/dockerd"
start_service() {
procd_open_instance
procd_set_param command \$PROG --config-file /etc/docker/daemon.json
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
stop_service() {
killall dockerd
}
restart() {
stop
start
}
EOF
chmod +x /etc/init.d/docker
/etc/init.d/docker enable
green "正在设置开机启动顺序的配置\n\n先挂载U盘,再启动Docker 修改/etc/rc.local后如下\n"
# 首先,备份 /etc/rc.local
cp /etc/rc.local /etc/rc.local.backup
# glinet系统重启后的 USB自动挂载点
SYSTEM_USB_AUTO_MOUNTPOINT="/tmp/mountd/disk1_part1"
# 卸载USB自动挂载点 挂载自定义挂载点 /mnt/upan_data
if ! grep -q "umount $SYSTEM_USB_AUTO_MOUNTPOINT" /etc/rc.local; then
sed -i '/exit 0/d' /etc/rc.local
# 将新的命令添加到 /etc/rc.local然后再加上 exit 0
{
echo "umount $SYSTEM_USB_AUTO_MOUNTPOINT || true"
echo "mount $new_partition $usb_mount_point || true"
echo "/etc/init.d/docker start || true"
echo "exit 0"
} >>/etc/rc.local
fi
cat /etc/rc.local
green "Docker 运行环境部署完成 重启后生效\n"
red "是否立即重启?(y/n)"
read -r answer
if [ "$answer" = "y" ] || [ -z "$answer" ]; then
red "正在重启..."
reboot
else
yellow "您选择了不重启"
fi
}
# START
install_depends_apps
prepare_usb_device

View File

@ -1,18 +1,5 @@
#!/bin/sh #!/bin/sh
# 定义颜色输出函数 third_party_source="https://op.dllkids.xyz/packages/aarch64_cortex-a53"
red() { echo -e "\033[31m\033[01m$1\033[0m"; }
green() { echo -e "\033[32m\033[01m$1\033[0m"; }
yellow() { echo -e "\033[33m\033[01m$1\033[0m"; }
blue() { echo -e "\033[34m\033[01m$1\033[0m"; }
light_magenta() { echo -e "\033[95m\033[01m$1\033[0m"; }
light_yellow() { echo -e "\033[93m\033[01m$1\033[0m"; }
cyan() { echo -e "\033[38;2;0;255;255m$1\033[0m"; }
third_party_source="https://istore.linkease.com/repo/all/nas_luci"
# 设置全局命令 g
cp -f "$0" /usr/bin/g
chmod +x /usr/bin/g
setup_base_init() { setup_base_init() {
#添加出处信息 #添加出处信息
@ -28,28 +15,23 @@ setup_base_init() {
## 设置防火墙wan 打开,方便主路由访问 ## 设置防火墙wan 打开,方便主路由访问
uci set firewall.@zone[1].input='ACCEPT' uci set firewall.@zone[1].input='ACCEPT'
uci commit firewall uci commit firewall
} }
## 安装应用商店和主题 ## 安装应用商店和主题
install_istore_os_style() { install_istore_os_style() {
##设置Argon 紫色主题 ##设置Argon 紫色主题
do_install_argon_skin do_install_argon_skin
#增加首页终端图标 #安装首页风格
opkg install ttyd is-opkg install luci-app-quickstart
#默认使用体积很小的文件传输:系统——文件传输
do_install_filetransfer
#默认安装必备工具SFTP 方便下载文件 比如finalshell等工具可以直接浏览路由器文件
is-opkg install app-meta-sftp
is-opkg install 'app-meta-ddnsto' is-opkg install 'app-meta-ddnsto'
#安装首页需要的文件管理功能
is-opkg install 'app-meta-linkease'
# 安装磁盘管理 # 安装磁盘管理
is-opkg install 'app-meta-diskman' is-opkg install 'app-meta-diskman'
FILE_PATH="/etc/openwrt_release" # 若已安装iStore商店则在概览中追加iStore字样
NEW_DESCRIPTION="Openwrt like iStoreOS Style by wukongdaily" if ! grep -q " like iStoreOS" /tmp/sysinfo/model; then
CONTENT=$(cat $FILE_PATH) sed -i '1s/$/ like iStoreOS/' /tmp/sysinfo/model
UPDATED_CONTENT=$(echo "$CONTENT" | sed "s/DISTRIB_DESCRIPTION='[^']*'/DISTRIB_DESCRIPTION='$NEW_DESCRIPTION'/") fi
echo "$UPDATED_CONTENT" >$FILE_PATH
} }
# 安装iStore 参考 https://github.com/linkease/istore # 安装iStore 参考 https://github.com/linkease/istore
do_istore() { do_istore() {
@ -78,7 +60,6 @@ do_istore() {
/tmp/is-opkg opkg install --force-reinstall luci-app-store || exit $? /tmp/is-opkg opkg install --force-reinstall luci-app-store || exit $?
[ -s "/etc/init.d/tasks" ] || /tmp/is-opkg opkg install --force-reinstall taskd [ -s "/etc/init.d/tasks" ] || /tmp/is-opkg opkg install --force-reinstall taskd
[ -s "/usr/lib/lua/luci/cbi.lua" ] || /tmp/is-opkg opkg install luci-compat >/dev/null 2>&1 [ -s "/usr/lib/lua/luci/cbi.lua" ] || /tmp/is-opkg opkg install luci-compat >/dev/null 2>&1
} }
#设置风扇工作温度 #设置风扇工作温度
@ -154,16 +135,20 @@ add_dhcp_domain() {
uci set "dhcp.@domain[-1].name=$domain_name" uci set "dhcp.@domain[-1].name=$domain_name"
uci set "dhcp.@domain[-1].ip=$domain_ip" uci set "dhcp.@domain[-1].ip=$domain_ip"
uci commit dhcp uci commit dhcp
else
echo echo
echo "已添加新的域名记录"
else
echo "相同的域名记录已存在,无需重复添加"
fi fi
echo -e "\n"
echo -e "time.android.com 203.107.6.88 "
} }
#添加出处信息 #添加出处信息
add_author_info() { add_author_info() {
uci set system.@system[0].description='wukongdaily' uci set system.@system[0].description='wukongdaily'
uci set system.@system[0].notes='文档说明: uci set system.@system[0].notes='文档说明:
https://tvhelper.cpolar.top/' https://github.com/wukongdaily/gl-inet-onescript'
uci commit system uci commit system
} }
@ -275,6 +260,23 @@ set_glfan_temp() {
echo "错误: 请输入整数." echo "错误: 请输入整数."
fi fi
} }
check_bash_installed() {
if [ -x "/bin/bash" ]; then
echo "rollback_old_version ......"
else
setup_software_source 0
opkg install bash
fi
}
rollback_old_version() {
check_bash_installed
download_url="https://github.com/wukongdaily/gl-inet-onescript/raw/1f25c161512e9b416227f60656e8c2139c993f69/gl-inet.run"
local_file_path="/tmp/gl-inet.run"
wget -O "$local_file_path" "$download_url"
chmod +x "$local_file_path"
"$local_file_path"
}
recovery_opkg_settings() { recovery_opkg_settings() {
echo "# add your custom package feeds here" >/etc/opkg/customfeeds.conf echo "# add your custom package feeds here" >/etc/opkg/customfeeds.conf
@ -282,91 +284,51 @@ recovery_opkg_settings() {
case "$router_name" in case "$router_name" in
*3000*) *3000*)
echo "Router name contains '3000'." echo "Router name contains '3000'."
mt3000_opkg="https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/mt-3000/distfeeds.conf" mt3000_opkg="https://raw.githubusercontent.com/wukongdaily/gl-inet-onescript/master/mt-3000/distfeeds.conf"
wget -O /etc/opkg/distfeeds.conf ${mt3000_opkg} wget -O /etc/opkg/distfeeds.conf ${mt3000_opkg}
;; ;;
*2500*) *2500*)
echo "Router name contains '2500'." echo "Router name contains '2500'."
mt2500a_opkg="https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/mt-2500a/distfeeds.conf" mt2500a_opkg="https://raw.githubusercontent.com/wukongdaily/gl-inet-onescript/master/mt-2500a/distfeeds.conf"
wget -O /etc/opkg/distfeeds.conf ${mt2500a_opkg} wget -O /etc/opkg/distfeeds.conf ${mt2500a_opkg}
;; ;;
*6000*) *6000*)
update_opkg_config echo "Router name contains '6000'."
mt6000_opkg="https://raw.githubusercontent.com/wukongdaily/gl-inet-onescript/master/mt-6000/distfeeds.conf"
wget -O /etc/opkg/distfeeds.conf ${mt6000_opkg}
;; ;;
*) *)
echo "Router name does not contain '3000' 6000 or '2500'." echo "Router name does not contain '3000' 6000 or '2500'."
;; ;;
esac esac
echo "Tips: 重启路由器后才能完全生效"
} }
update_opkg_config() { do_luci_app_adguardhome() {
kernel_version=$(uname -r) setup_software_source 0
echo "MT-6000 kernel version: $kernel_version" opkg remove gl-sdk4-ui-adguardhome
case $kernel_version in opkg remove gl-sdk4-adguardhome
5.4*) opkg install adguardhome
mt6000_opkg="https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/mt-6000/distfeeds-5.4.conf" echo "请访问 http://192.168.8.1:3000 初始化设置adguardhome "
wget -O /etc/opkg/distfeeds.conf ${mt6000_opkg}
# 更换5.4.238 内核之后 缺少的依赖
mkdir -p /tmp/mt6000
wget -O /tmp/mt6000/script-utils.ipk "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/mt-6000/script-utils.ipk"
wget -O /tmp/mt6000/mdadm.ipk "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/mt-6000/mdadm.ipk"
wget -O /tmp/mt6000/lsblk.ipk "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/mt-6000/lsblk.ipk"
opkg update
if [ -f "/tmp/mt6000/lsblk.ipk" ]; then
# 先卸载之前安装过的lsblk,确保使用的是正确的lsblk
opkg remove lsblk
fi
opkg install /tmp/mt6000/*.ipk
;;
5.15*)
mt6000_opkg="https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/mt-6000/distfeeds.conf"
wget -O /etc/opkg/distfeeds.conf ${mt6000_opkg}
;;
*)
echo "Unsupported kernel version: $kernel_version"
return 1
;;
esac
} }
do_luci_app_wireguard() { do_luci_app_wireguard() {
setup_software_source 0 setup_software_source 0
opkg install luci-app-wireguard opkg install luci-app-wireguard
opkg install luci-i18n-wireguard-zh-cn opkg install luci-i18n-wireguard-zh-cn
echo "请访问 http://"$(uci get network.lan.ipaddr)"/cgi-bin/luci/admin/status/wireguard 查看状态 " echo "请访问 http://192.168.8.1/cgi-bin/luci/admin/status/wireguard 查看状态 "
echo "也可以去接口中 查看是否增加了新的wireguard 协议的选项 " echo "也可以去接口中 查看是否增加了新的wireguard 协议的选项 "
} }
update_luci_app_quickstart() { update_luci_app_quickstart() {
if [ -f "/bin/is-opkg" ]; then setup_software_source 1
# 如果 /bin/is-opkg 存在,则执行 is-opkg update opkg install luci-app-quickstart
is-opkg update setup_software_source 0
is-opkg install luci-i18n-quickstart-zh-cn --force-depends >/dev/null 2>&1 echo "首页样式已经更新,请强制刷新网页,检查是否为中文字体"
opkg install iptables-mod-tproxy
opkg install iptables-mod-socket
opkg install iptables-mod-iprange
hide_homepage_format_button
yellow "恭喜您!现在你的路由器已经变成iStoreOS风格啦!"
green "现在您可以访问8080端口 查看是否生效 http://192.168.8.1:8080"
green "更多up主项目和动态 请务必收藏我的导航站 https://tvhelper.cpolar.top "
green "赞助本项目作者 https://wkdaily.cpolar.top/01 "
addr_hostname=$(uci get system.@system[0].hostname)
else
red "请先执行第一项 一键iStoreOS风格化"
fi
} }
# 安装体积非常小的文件传输软件 默认上传位置/tmp/upload/
do_install_filetransfer() {
mkdir -p /tmp/luci-app-filetransfer/
cd /tmp/luci-app-filetransfer/
wget -O luci-app-filetransfer_all.ipk "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/luci-app-filetransfer/luci-app-filetransfer_all.ipk"
wget -O luci-lib-fs_1.0-14_all.ipk "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/luci-app-filetransfer/luci-lib-fs_1.0-14_all.ipk"
opkg install *.ipk --force-depends
}
do_install_depends_ipk() { do_install_depends_ipk() {
wget -O "/tmp/luci-lua-runtime_all.ipk" "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/theme/luci-lua-runtime_all.ipk" wget -O "/tmp/luci-lua-runtime_all.ipk" "https://raw.githubusercontent.com/wukongdaily/gl-inet-onescript/master/theme/luci-lua-runtime_all.ipk"
wget -O "/tmp/libopenssl3.ipk" "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/theme/libopenssl3.ipk" wget -O "/tmp/libopenssl3.ipk" "https://raw.githubusercontent.com/wukongdaily/gl-inet-onescript/master/theme/libopenssl3.ipk"
opkg install "/tmp/luci-lua-runtime_all.ipk" opkg install "/tmp/luci-lua-runtime_all.ipk"
opkg install "/tmp/libopenssl3.ipk" opkg install "/tmp/libopenssl3.ipk"
} }
@ -375,15 +337,8 @@ do_install_argon_skin() {
echo "正在尝试安装argon主题......." echo "正在尝试安装argon主题......."
#下载和安装argon的依赖 #下载和安装argon的依赖
do_install_depends_ipk do_install_depends_ipk
# bug fix 由于2.3.1 最新版的luci-argon-theme 登录按钮没有中文匹配,而2.3版本字体不对。 setup_software_source 1
# 所以这里安装上一个版本2.2.9,考虑到主题皮肤并不需要长期更新,因此固定版本没问题 opkg install luci-app-argon-config
opkg update
opkg install luci-lib-ipkg
wget -O "/tmp/luci-theme-argon.ipk" "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/theme/luci-theme-argon-master_2.2.9.4_all.ipk"
wget -O "/tmp/luci-app-argon-config.ipk" "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/theme/luci-app-argon-config_0.9_all.ipk"
wget -O "/tmp/luci-i18n-argon-config-zh-cn.ipk" "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/theme/luci-i18n-argon-config-zh-cn.ipk"
cd /tmp/
opkg install luci-theme-argon.ipk luci-app-argon-config.ipk luci-i18n-argon-config-zh-cn.ipk
# 检查上一个命令的返回值 # 检查上一个命令的返回值
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "argon主题 安装成功" echo "argon主题 安装成功"
@ -395,6 +350,7 @@ do_install_argon_skin() {
else else
echo "argon主题 安装失败! 建议再执行一次!再给我一个机会!事不过三!" echo "argon主题 安装失败! 建议再执行一次!再给我一个机会!事不过三!"
fi fi
setup_software_source 0
} }
#单独安装文件管理器 #单独安装文件管理器
@ -405,120 +361,6 @@ do_install_filemanager() {
is-opkg install 'app-meta-linkease' is-opkg install 'app-meta-linkease'
echo "重新登录web页面,然后您可以访问: http://192.168.8.1/cgi-bin/luci/admin/services/linkease/file/?path=/root" echo "重新登录web页面,然后您可以访问: http://192.168.8.1/cgi-bin/luci/admin/services/linkease/file/?path=/root"
} }
#更新脚本
update_myself() {
wget -O gl-inet.sh "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/gl-inet.sh" && chmod +x gl-inet.sh
echo "脚本已更新并保存在当前目录 gl-inet.sh,现在将执行新脚本。"
./gl-inet.sh
exit 0
}
#根据release地址和命名前缀获取apk地址
get_docker_compose_url() {
if [ $# -eq 0 ]; then
echo "需要提供GitHub releases页面的URL作为参数。"
return 1
fi
local releases_url=$1
# 使用curl获取重定向的URL
latest_url=$(curl -Ls -o /dev/null -w "%{url_effective}" "$releases_url")
# 使用sed从URL中提取tag值,并保留前导字符'v'
tag=$(echo $latest_url | sed 's|.*/v|v|')
# 检查是否成功获取到tag
if [ -z "$tag" ]; then
echo "未找到最新的release tag。"
return 1
fi
# 拼接docker-compose下载链接
local repo_path=$(echo "$releases_url" | sed -n 's|https://github.com/\(.*\)/releases/latest|\1|p')
docker_compose_download_url="https://github.com/${repo_path}/releases/download/${tag}/docker-compose-linux-aarch64"
echo "$docker_compose_download_url"
}
# 下载并安装Docker Compose
do_install_docker_compose() {
# https://github.com/docker/compose/releases/download/v2.26.0/docker-compose-linux-aarch64
# 检查/usr/bin/docker是否存在并且可执行
if [ -f "/usr/bin/docker" ] && [ -x "/usr/bin/docker" ]; then
echo "Docker is installed and has execute permissions."
else
red "警告 您还没有安装Docker"
exit 1
fi
if [[ "$gl_name" == *3000* ]]; then
red "警告 docker-compose 组件的大小将近60MB,请谨慎安装"
yellow "确定要继续安装吗(y|n)"
read -r answer
if [ "$answer" = "y" ] || [ -z "$answer" ]; then
green "正在获取最新版docker-compose下载地址"
else
yellow "已退出docker-compose安装流程"
exit 1
fi
fi
local github_releases_url="https://github.com/docker/compose/releases/latest"
local docker_compose_url=$(get_docker_compose_url "$github_releases_url")
echo "最新版docker-compose 地址:$docker_compose_url"
wget -O /usr/bin/docker-compose $docker_compose_url
if [ $? -eq 0 ]; then
green "docker-compose下载并安装成功,你可以使用啦"
chmod +x /usr/bin/docker-compose
else
red "安装失败,请检查网络连接.或者手动下载到 /usr/bin/docker-compose 记得赋予执行权限"
yellow "刚才使用的地址是:$docker_compose_url"
exit 1
fi
}
#mt3000更换分区
mt3000_overlay_changed() {
wget -O mt3000.sh "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/mt-3000/mt3000.sh" && chmod +x mt3000.sh
sh mt3000.sh
}
# 防止误操作 隐藏首页的格式化按钮
hide_homepage_format_button() {
TARGET="/www/luci-static/quickstart/style.css"
MARKER="/* hide quickstart disk button */"
# 如果没有追加过,就添加
if ! grep -q "$MARKER" "$TARGET"; then
cat <<EOF >>"$TARGET"
$MARKER
.value-data button {
display: none !important;
}
EOF
echo "✅ 格式化按钮已隐藏"
else
echo "⚠️ 无需重复操作"
fi
}
# 启用adguardhome
toggle_adguardhome() {
status=$(uci get adguardhome.config.enabled)
if [ "$status" -eq 1 ]; then
echo "Disabling AdGuardHome..."
uci set adguardhome.config.enabled='0' >/dev/null 2>&1
uci commit adguardhome >/dev/null 2>&1
/etc/init.d/adguardhome disable >/dev/null 2>&1
/etc/init.d/adguardhome stop >/dev/null 2>&1
green "AdGuardHome 已关闭"
else
echo "Enabling AdGuardHome..."
uci set adguardhome.config.enabled='1' >/dev/null 2>&1
uci commit adguardhome >/dev/null 2>&1
/etc/init.d/adguardhome enable >/dev/null 2>&1
/etc/init.d/adguardhome start >/dev/null 2>&1
green "AdGuardHome 已开启 访问 http://192.168.8.1:3000"
fi
}
while true; do while true; do
clear clear
@ -531,29 +373,25 @@ while true; do
echo "* 当前的路由器型号: "$gl_name | sed 's/ like iStoreOS//' echo "* 当前的路由器型号: "$gl_name | sed 's/ like iStoreOS//'
echo echo
echo "*******支持的机型列表***************************************************" echo "*******支持的机型列表***************************************************"
green "*******GL-iNet MT-2500A"
green "*******GL-iNet MT-3000 "
green "*******GL-iNet MT-6000 "
echo "******************下次调用 直接输入快捷键 g *****************************"
echo echo
light_magenta " 1. $result" echo "*******GL-iNet MT-2500A"
echo "*******GL-iNet MT-3000 "
echo "*******GL-iNet MT-6000 "
echo "**********************************************************************"
echo
echo " 1. $result"
echo echo
echo " 2. 设置自定义软件源" echo " 2. 设置自定义软件源"
echo " 3. 删除自定义软件源" echo " 3. 删除自定义软件源"
echo echo
echo " 4. 设置风扇开始工作的温度(仅限MT3000)" echo " 4. 设置风扇开始工作的温度(仅限MT3000)"
echo " 5. 恢复原厂OPKG配置软件包" echo " 5. (慎用)恢复原厂OPKG配置软件包(需要网络环境支持)"
echo echo
echo " 6. 启用/关闭原厂adguardhome" echo " 6. 安装GL原厂Adguardhome(10MB)"
echo " 7. 安装luci-app-wireguard" echo " 7. 安装luci-app-wireguard"
echo " 8. 更新luci-app-quickstart" echo " 8. 更新luci-app-quickstart"
echo " 9. 安装Argon紫色主题" echo " 9. 安装Argon紫色主题"
echo "10. 安装文件管理器" echo "10. 安装文件管理器"
light_magenta "11. 安装Docker"
light_magenta "12. 安装docker-compose"
light_magenta "13. 更新脚本"
cyan "14. MT3000一键更换分区"
light_magenta "15. 隐藏首页格式化按钮"
echo echo
echo " Q. 退出本程序" echo " Q. 退出本程序"
echo echo
@ -566,16 +404,14 @@ while true; do
# 设置风扇工作温度 # 设置风扇工作温度
setup_cpu_fans setup_cpu_fans
fi fi
# 解决首页“已联网”的UI问题
recovery_opkg_settings
#先安装istore商店 #先安装istore商店
do_istore do_istore
#安装iStore风格
install_istore_os_style
#安装iStore首页风格
update_luci_app_quickstart
#基础必备设置 #基础必备设置
setup_base_init setup_base_init
#安装iStore风格
install_istore_os_style
#再次更新 防止出现汉化不完整
update_luci_app_quickstart
;; ;;
2) 2)
add_custom_feed add_custom_feed
@ -584,21 +420,13 @@ while true; do
remove_custom_feed remove_custom_feed
;; ;;
4) 4)
case "$gl_name" in set_glfan_temp
*3000*)
set_glfan_temp
;;
*)
echo "* 当前的路由器型号: "$gl_name | sed 's/ like iStoreOS//'
echo "并非MT3000 它没有风扇 无需设置"
;;
esac
;; ;;
5) 5)
recovery_opkg_settings recovery_opkg_settings
;; ;;
6) 6)
toggle_adguardhome do_luci_app_adguardhome
;; ;;
7) 7)
do_luci_app_wireguard do_luci_app_wireguard
@ -612,28 +440,9 @@ while true; do
10) 10)
do_install_filemanager do_install_filemanager
;; ;;
11) h | H)
yellow "注意!插入U盘之前请确认U盘数据已备份" rollback_old_version
red "确定要继续吗(y|n)" exit 0
read -r answer
if [ "$answer" = "y" ] || [ -z "$answer" ]; then
wget -q -O do_docker.sh "https://cafe.cpolar.top/wkdaily/gl-inet-onescript/raw/branch/master/docker/do_docker.sh" && chmod +x do_docker.sh
./do_docker.sh
else
yellow "已退出Docker安装流程"
fi
;;
12)
do_install_docker_compose
;;
13)
update_myself
;;
14)
mt3000_overlay_changed
;;
15)
hide_homepage_format_button
;; ;;
q | Q) q | Q)
echo "退出" echo "退出"

View File

@ -1,4 +1,4 @@
# mt-2500a /etc/opkg/distfeeds.conf # mt-2500a /etc/opkg/distfeeds.conf
src/gz glinet_base https://fw.gl-inet.cn/releases/v21.02.3/kmod-4.2.1/aarch64_cortex-a53/mediatek/mt7981 src/gz glinet_kmod https://fw.gl-inet.cn/releases/v21.02.3/kmod-4.2.1/aarch64_cortex-a53/mediatek/mt7981
src/gz glinet_gli_pub https://fw.gl-inet.cn/releases/v21.02.3/packages-4.0/aarch64_cortex-a53/glinet src/gz glinet_gli_pub https://fw.gl-inet.cn/releases/v21.02.3/packages-4.0/aarch64_cortex-a53/glinet
src/gz glinet_gli_packages https://fw.gl-inet.cn/releases/v21.02.3/packages-4.0/aarch64_cortex-a53/packages src/gz glinet_gli_packages https://fw.gl-inet.cn/releases/v21.02.3/packages-4.0/aarch64_cortex-a53/packages

View File

@ -1,4 +1,4 @@
# mt-3000 /etc/opkg/distfeeds.conf # mt-3000 /etc/opkg/distfeeds.conf
src/gz glinet_base https://fw.gl-inet.cn/releases/v21.02.3/kmod-4.2.1/aarch64_cortex-a53/mediatek/mt7981 src/gz glinet_core https://fw.gl-inet.cn/releases/v21.02.3/kmod-4.2.1/aarch64_cortex-a53/mediatek/mt7981
src/gz glinet_gli_pub https://fw.gl-inet.cn/releases/v21.02.3/packages-4.0/aarch64_cortex-a53/glinet src/gz glinet_gli_pub https://fw.gl-inet.cn/releases/v21.02.3/packages-4.0/aarch64_cortex-a53/glinet
src/gz glinet_gli_packages https://fw.gl-inet.cn/releases/v21.02.3/packages-4.0/aarch64_cortex-a53/packages src/gz glinet_gli_packages https://fw.gl-inet.cn/releases/v21.02.3/packages-4.0/aarch64_cortex-a53/packages

View File

@ -1,254 +0,0 @@
#!/bin/sh
# 定义颜色输出函数
red() { echo -e "\033[31m\033[01m$1\033[0m"; }
green() { echo -e "\033[32m\033[01m$1\033[0m"; }
greeninfo() { echo -e "\033[32m\033[01m[INFO] $1\033[0m"; }
blueinfo() { echo -e "\033[32m\033[01m$1\033[0m"; }
yellow() { echo -e "\033[33m\033[01m$1\033[0m"; }
blue() { echo -e "\033[34m\033[01m$1\033[0m"; }
light_magenta() { echo -e "\033[95m\033[01m$1\033[0m"; }
light_yellow() { echo -e "\033[93m\033[01m$1\033[0m"; }
purple() { echo -e "\033[38;5;141m$1\033[0m"; }
cyan() { echo -e "\033[38;2;0;255;255m$1\033[0m"; }
install_depends_apps() {
cyan "正在安装必备工具...."
opkg update >/dev/null 2>&1
for pkg in lsblk fdisk; do
if opkg list-installed | grep -qw "$pkg"; then
cyan "$pkg 已安装。"
else
if opkg install "$pkg" >/dev/null 2>&1; then
green "$pkg 安装成功。"
else
red "$pkg 安装失败。"
exit 1
fi
fi
done
}
# 卸载USB设备
unmount_usb_device() {
for mount in $(mount | grep "$1" | awk '{print $3}'); do
yellow "正在尝试卸载U盘挂载点$mount"
umount $mount || {
red "警告:无法卸载挂载点 $mount。可能有文件正在被访问或权限不足。"
exit 1
}
blueinfo "U盘挂载点 $mount 卸载成功。"
done
}
create_and_format_partitions() {
local device=$1
# 使用fdisk -l获取设备的总容量以字节为单位并转换为GB
local total_bytes=$(fdisk -l $device | grep "Disk $device:" | awk '{print $5}')
local total_gb=$(echo "$total_bytes" | awk '{print int($1/(1024*1024*1024))}')
if [ -n "$CUSTOM_OPKG_SIZE" ]; then
part1_gb=$CUSTOM_OPKG_SIZE
yellow "U盘总容量约为 $total_gb GB,您设置的自定义软件包大小为 ${part1_gb}GB。"
else
# 计算10%的大小以GB为单位
part1_gb=$((total_gb / 10))
yellow "U盘总容量约为 $total_gb GB,第一分区大小设置为U盘容量的10% 即 ${part1_gb}GB。"
fi
green "计划将第一分区分配给软件包 其大小为 ${part1_gb}GB"
cyan "没错~你没有看错,让我们任性的告别 容 量 焦 虑!"
# 创建分区并分配空间
{
echo g # 创建一个新的空DOS分区表
echo n # 添加一个新分区
echo p # 主分区
echo 1 # 分区号1
echo # 第一个可用扇区(默认)
echo +${part1_gb}G # 为第一个分区分配计算出的GB数
echo n # 添加第二个新分区
echo p # 主分区
echo 2 # 分区号2
echo # 第一个可用扇区(默认,自动)
echo # 最后一个扇区(默认,使用剩余空间)
echo w # 写入并退出
} | fdisk $device >/dev/null 2>&1
# 给系统一点时间来识别新分区
sleep 5
# 格式化第一个分区为EXT4
local new_partition1="${device}1"
cyan "正在将 $new_partition1 格式化为EXT4文件系统..."
mkfs.ext4 -F $new_partition1 >/dev/null 2>&1
cyan "$new_partition1 已成功格式化为EXT4文件系统。"
green "第2分区 ${device}2 暂不格式化,未来您可分配给docker使用"
}
# 换区到U盘
change_overlay_usb() {
install_depends_apps
blueinfo "现在开始查找USB设备分区 请稍后......"
local USB_PARTITION=$(lsblk -dn -o NAME,TRAN | awk '$2=="usb" {print "/dev/"$1; exit}')
if [ -z "$USB_PARTITION" ]; then
red "未找到USB磁盘。"
exit 1
fi
yellow "找到USB磁盘 $USB_PARTITION"
# 清零磁盘开始部分以清除分区表和文件系统签名
dd if=/dev/zero of=$USB_PARTITION bs=1M count=10
sync
# 卸载所有与该磁盘相关的挂载点
unmount_usb_device "$USB_PARTITION"
red "正在将U盘${USB_PARTITION}分为2个区 ..."
create_and_format_partitions "$USB_PARTITION"
# U盘分区的挂载点
MOUNT_POINT="/mnt/usb_overlay"
# 临时目录用于复制数据
TMP_DIR="/tmp/overlay_backup"
# 创建挂载点目录
mkdir -p $MOUNT_POINT
# 挂载U盘分区
cyan "重新挂载第一分区 ${USB_PARTITION}1 到 $MOUNT_POINT"
mount ${USB_PARTITION}1 $MOUNT_POINT >/dev/null 2>&1
# 创建临时目录用于备份overlay数据
mkdir -p $TMP_DIR
# 复制当前overlay到临时目录
cp -a /overlay/. $TMP_DIR
# 将临时目录的数据复制到U盘
blueinfo "正在拷贝 当前系统文件到U盘"
cp -a $TMP_DIR/. $MOUNT_POINT
# 更新fstab配置以便在启动时自动挂载U盘为overlay
blueinfo "正在更新启动时的配置文件"
uci set fstab.overlay=mount
uci set fstab.overlay.uuid="$(blkid -o value -s UUID ${USB_PARTITION}1)"
uci set fstab.overlay.target="/overlay"
uci commit fstab
# 清理临时目录
rm -rf $TMP_DIR
cp /etc/config/fstab $MOUNT_POINT/fstab.bak
cyan "overlay更换分区完成 重启验证是否成功."
red "是否立即重启?(y/n)"
read -r answer
if [ "$answer" = "y" ] || [ -z "$answer" ]; then
red "正在重启..."
reboot
else
yellow "您选择了不重启"
fi
}
check_overlay_size() {
# 使用df命令获取/overlay分区的总大小以1K块为单位
OVERLAY_SIZE=$(df /overlay | awk '/\/overlay/{print $2}')
# 将1GB转换为1K块单位即1GB = 1*1024*1024 1K块
ONE_GB_IN_1K_BLOCKS=$((1024 * 1024))
# 比较/overlay分区的大小是否大于1GB
if [ "$OVERLAY_SIZE" -gt "$ONE_GB_IN_1K_BLOCKS" ]; then
yellow "检测到您已经换区到U盘啦,可以继续"
else
echo "您还没有换区到U盘,请先执行选项1."
exit 1
fi
}
# 安装 Docker 和 dockerd
install_docker() {
check_overlay_size
green "正在更新 OPKG 软件包..."
opkg update >/dev/null 2>&1
cyan "正在安装 Docker 及相关服务...请耐心等待一会...大约需要1-2分钟\n"
opkg install luci-app-dockerman >/dev/null 2>&1
opkg install luci-i18n-dockerman-zh-cn >/dev/null 2>&1
opkg install dockerd --force-depends >/dev/null 2>&1
cyan "Docker 运行环境部署完成 重启后生效\n"
red "正在重启..."
reboot
}
# 重新绑定
rebind_usb_overlay() {
cyan "正在重新绑定U盘设备...."
if opkg list-installed | grep -qw "lsblk"; then
echo
else
opkg update >/dev/null 2>&1
if opkg install "lsblk" >/dev/null 2>&1; then
echo
else
red "$pkg 安装失败。"
exit 1
fi
fi
local USB_DEVICE=$(lsblk -dn -o NAME,RM,TYPE | awk '$2=="1" && $3=="disk" {print "/dev/"$1; exit}')
if [ -z "$USB_DEVICE" ]; then
red "未找到USB磁盘。"
exit 1
fi
uci set fstab.overlay=mount
uci set fstab.overlay.uuid="$(blkid -o value -s UUID ${USB_DEVICE}1)"
uci set fstab.overlay.target="/overlay"
uci commit fstab
green "重新绑定成功! 重启后生效"
red "正在重启..."
reboot
}
#自定义软件包的大小
#默认为U盘容量的10%
custom_package_size() {
while :; do
echo "请输入想分配的软件包的大小(数字,单位:GB):"
read size
# 检查输入是否为数字
if [[ $size =~ ^[0-9]+$ ]]; then
CUSTOM_OPKG_SIZE=$size
yellow "已设置软件包大小为:$CUSTOM_OPKG_SIZE GB"
green "接下来,您可以执行第一项啦"
break # 跳出循环
else
red "错误: 请输入一个有效的数字。"
fi
done
}
while true; do
clear
echo "***********************************************************************"
green " MT-3000 软件包更换分区助手 "
echo "**********************************************************************"
echo
cyan " 1. MT-3000 一键更换overlay分区到U盘"
cyan " 2. MT-3000 安装Docker"
cyan " 3. 自定义设置软件包大小(GB)"
light_yellow " 4. 重新绑定U盘"
echo
echo " Q. 退出本程序"
echo
read -p "请选择一个选项: " choice
echo
case $choice in
1)
change_overlay_usb
;;
2)
install_docker
;;
3)
custom_package_size
;;
4)
rebind_usb_overlay
;;
q | Q)
echo "退出"
exit 0
;;
*)
echo "无效选项,请重新选择。"
;;
esac
read -p "按 Enter 键继续..."
done

View File

@ -1,4 +0,0 @@
# mt-6000-5.4.238 backup /etc/opkg/distfeeds.conf
src/gz glinet_base https://fw.gl-inet.cn/releases/mt798x/kmod-4.5.7/aarch64_cortex-a53/mediatek/mt7986
src/gz glinet_gli_pub https://fw.gl-inet.cn/releases/mt798x/packages-4.5/aarch64_cortex-a53/glinet
src/gz glinet_gli_packages https://fw.gl-inet.cn/releases/mt798x/packages-4.5/aarch64_cortex-a53/packages

View File

@ -1,4 +1,4 @@
# mt-6000 backup /etc/opkg/distfeeds.conf # mt-6000 backup /etc/opkg/distfeeds.conf
src/gz glinet_base https://fw.gl-inet.cn/releases/v23.05.0/kmod-4.5/aarch64_cortex-a53/mediatek/mt7986 src/gz glinet_core https://fw.gl-inet.cn/releases/v23.05.0/kmod-4.5/aarch64_cortex-a53/mediatek/mt7986
src/gz glinet_gli_pub https://fw.gl-inet.cn/releases/v23.05.0/packages-4.5/aarch64_cortex-a53/glinet src/gz glinet_gli_pub https://fw.gl-inet.cn/releases/v23.05.0/packages-4.5/aarch64_cortex-a53/glinet
src/gz glinet_packages https://fw.gl-inet.cn/releases/v23.05.0/packages-4.5/aarch64_cortex-a53/packages src/gz glinet_packages https://fw.gl-inet.cn/releases/v23.05.0/packages-4.5/aarch64_cortex-a53/packages

Binary file not shown.

Binary file not shown.

Binary file not shown.