环境:Android 盒子

问题:Android 盒子 旧手机 做下载机

解法:Android 环境 root 后安装 entware 后安装 qbittorrent

步骤:

  1. 先把 Android root 掉,打开调试模式

2.adb 连接到 Android

1
2
3
adb connect IP

adb shell

系统目录挂载读写

1
2
3
mount -o remount,rw /system

mount -o remount,rw /
  1. 安装 busybox,确认 CPU 架构,基本上是 ARMV7 的
1
2
3
4
5
6
7
8
9
adb push busybox-armv7l /system/xbin

cd /system/xbin

mv busybox-armv7l busybox

chmod 755 busybox

busybox --install .

下载 busybox 文件

https://busybox.net/downloads/binaries/1.21.1/busybox-armv7l

adb push busybox-armv7l /system/xbin

busybox 运行一下

wget 确认命名是没安装的

wget

进入 / system/xbin 目录,授权一下

cd /system/xbin

mv busybox-armv7l busybox

chmod 755 busybox

busybox 安装一下,安装到当前目录

busybox –install .

wget 试一下

wget

整体命令

1
2
3
4
5
6
7
8
9
10
11
12
13
/system/bin/mount -o rw,remount /

mkdir /opt

mkdir /bin

ln -s /system/bin/sh /bin/sh

/system/bin/mount -o ro,remount /

mkdir /data/entware.arm

mount -o bind /data/entware.arm /opt

3)、安装 entware:

1
2
3
/opt/bin/opkg install dropbear

/opt/sbin/dropbear -p 22 -a

wget -O - http://bin.entware.net/armv7sf-k3.2/installer/alternative.sh 

我的环境下 wget 报错 提示无法解析,直接修改 host 文件 加入 IP 和域名

vi /etc/hosts

104.21.91.83 bin.entware.net

1
2
3
opkg install openssh-server

opkg install openssh-sftp-server

提示修改环境变量,这样就算安装完成了

Info: If there are no errors above then Entware was successfully initialized.

Info: Add /opt/bin & /opt/sbin to $PATH variable

Info: Add “/opt/etc/init.d/rc.unslung start” to startup script for Entware services to start

Info: Use ssh server from Entware for better compatibility.

Info: Found a Bug? Please report at https://github.com/Entware/Entware/issues

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/system/bin/sh

unset LD_PRELOAD

unset LD_LIBRARY_PATH

sleep 3

/system/bin/mount -o rw,remount /

sleep 1

/system/bin/chmod 0777 /data/entware.arm

/system/bin/mkdir /opt

/system/bin/mkdir /bin

ln -s /system/bin/sh /bin/sh

/system/bin/mount -o ro,remount /

sleep 3

/system/bin/mount -o bind /data/entware.arm /opt

/system/bin/mount -o bind /data/entware.arm/root /system/etc/dropbear

sleep 2

/opt/etc/init.d/rc.unslung start

软链接到 DNS 解析的文件 ln -s /system/etc/resolv.conf /opt/etc/resolv.conf

4)、安装 ssh,如果 dropbear 配置不了就换 openssh

1
2
3
sleep 1

/data/entware.arm/init.sh &

换别台电脑测试一下 ssh admin@ip 密码 12345

如果 dropbear 有问题,卡在配置界面就换 openssh

1
2
3
opkg install qbittorrent

/opt/etc/init.d/S89qbittorrent start

生成密钥,修改下 sshd 配置文件,允许 root 登陆

可能会报个错,修改 / etc/passwd 补充下面内容

sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin 

4)、创建开机脚本,自动启动 entware 环境

创建开机初始化的脚本,内容如下

1
2
3
opkg install  samba4-server samba4-admin samba4-libs samba4-utils

vi /opt/etc/init.d/S91smb
1
2
3
4
5
6
7
8
9
[skytv]

       comment = Share for you

       path = /storage/28400B5B400B2F5E/ROOM

       valid users = root

       write list = root

编辑 /system/bin/lazy-start.sh,在 exit 0 前加入

1
sh /data/entware.arm/init.sh
1
2
3
sleep 1

/data/entware.arm/init.sh &

如果找不到这个文件,那就修改 recovery 文件,比如

vi /system/etc/install-recovery-2.sh

找不到可以查找一下是哪个

1
find / -name *recovery*

此时 Entware 就安装完成了

5)、安装 qbittorrent

1
2
3
opkg install qbittorrent

/opt/etc/init.d/S89qbittorrent start

访问 http://IP:8083 就可以进入 QB 下载了

6)、安装 samba 配置共享

1
2
3
opkg install  samba4-server samba4-admin samba4-libs samba4-utils

vi /opt/etc/init.d/S91smb

增加下列内容,创建独立 samba 用户,

1
2
3
4
5
6
7
8
9
[skytv]

       comment = Share for you

       path = /storage/28400B5B400B2F5E/ROOM

       valid users = root

       write list = root

启动服务

1
/opt/etc/init.d/S91smb start

补充:

多次启动后发现有时候 QB 无法自动启动,使用 crontab 解决

在开机文件中加入 crond

配置 crotab -e

1
* * * * * /opt/etc/init.d/S89qbittorrent start