|
|
本帖最后由 wilywx 于 2026-9-16 13:22 编辑
找出来个老盒子,金亚致家2号3188的,遥控不见了。
以前刷过ubuntu,bug一堆,也刷了安卓4.4的,无线不能用。
内存这么大,可惜了,就想着有没有啥能玩玩的。
记录和分享一下。
- ######################################################################
- ## 1. 安装 ssh 服务端 (ssh文件夹里的一键包)
- ## 2. 安装 entware (entware文件夹里的一键包)
- ## 3. 安装 aria2 (可选)
- ######################################################################
- # 挂载可写的命令,备用
- mount -o remount,rw /system;mount -o remount,rw /data;mount -o remount,rw /
- # 改回只读
- mount -o ro,remount /
- # 查看大小
- du -sk * | sort -n
复制代码- ######################################################################
- ## 4. 安装配置 samba (盒子连接ssh 后执行)
- ######################################################################
- # A. 安装 samba4-server
- /opt/bin/opkg install samba4-server
- # B. 创建必要目录
- mkdir -p /opt/var/log/samba
- mkdir -p /opt/var/lib/samba/private
- mkdir -p /opt/var/cache/samba
- mkdir -p /opt/var/run/samba/ncalrpc
- # C. 修复启动脚本 shebang + PATH
- # 安卓没有 /bin/sh,必须改 /system/bin/sh
- # 开机自启时 PATH 里没有 /opt/sbin,S91smb 里的 smbd/nmbd 会 not found
- sed -i '1s|^#!/bin/sh|#!/system/bin/sh|' /opt/etc/init.d/S91smb
- sed -i '/^#!\/system\/bin\/sh/a export PATH=/opt/bin:/opt/sbin:$PATH' /opt/etc/init.d/S91smb
- sed -n '1,3p' /opt/etc/init.d/S91smb
- # D. 修复安卓 NSS 缺陷(Samba 靠 NSS 解析用户,安卓 libc 没标准 NSS,guest 报 NT_STATUS_NO_SUCH_USER)
- # 注意:这三个文件每次开机都会被清空,所以必须写进开机自启脚本里重建
- mkdir -p /sqlite_stmt_journals
- echo "root:x:0:0:root:/root:/opt/bin/sh" > /opt/etc/passwd
- echo "nobody:x:99:99:nobody:/:/opt/bin/sh" >> /opt/etc/passwd
- echo "root:x:0:" > /opt/etc/group
- echo "nobody:x:99:" >> /opt/etc/group
- echo "passwd: files" > /opt/etc/nsswitch.conf
- echo "shadow: files" >> /opt/etc/nsswitch.conf
- echo "group: files" >> /opt/etc/nsswitch.conf
- echo "hosts: files dns" >> /opt/etc/nsswitch.conf
- # E. 修复 /tmp 不存在(Samba 建 IPC$ 共享要访问 /tmp,安卓没有,报 canonicalize_connect_path failed)
- # 注意:busybox 的 ln 对 -f 有 bug,会报 link failed,所以不要加 -f
- mount -o remount,rw / 2>/dev/null
- ln -s /opt/tmp /tmp
- # F. 写 smb.conf(匿名可读写 /data)
- mkdir -p /opt/etc/samba
- echo '[global]' > /opt/etc/samba/smb.conf
- echo ' workgroup = WORKGROUP' >> /opt/etc/samba/smb.conf
- echo ' netbios name = AndroidBox' >> /opt/etc/samba/smb.conf
- echo ' server string = Entware Samba' >> /opt/etc/samba/smb.conf
- echo ' security = user' >> /opt/etc/samba/smb.conf
- echo ' map to guest = Bad User' >> /opt/etc/samba/smb.conf
- echo ' guest account = nobody' >> /opt/etc/samba/smb.conf
- echo ' tmpdir = /opt/tmp' >> /opt/etc/samba/smb.conf
- echo ' log file = /opt/var/log/samba/log.%m' >> /opt/etc/samba/smb.conf
- echo ' log level = 1' >> /opt/etc/samba/smb.conf
- echo ' max log size = 50' >> /opt/etc/samba/smb.conf
- echo ' load printers = no' >> /opt/etc/samba/smb.conf
- echo ' printcap name = /dev/null' >> /opt/etc/samba/smb.conf
- echo ' disable spoolss = yes' >> /opt/etc/samba/smb.conf
- echo ' socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE' >> /opt/etc/samba/smb.conf
- echo ' smb encrypt = disabled' >> /opt/etc/samba/smb.conf
- echo ' min protocol = SMB2' >> /opt/etc/samba/smb.conf
- echo ' max protocol = SMB3' >> /opt/etc/samba/smb.conf
- echo '' >> /opt/etc/samba/smb.conf
- echo '[data]' >> /opt/etc/samba/smb.conf
- echo ' comment = Data Share' >> /opt/etc/samba/smb.conf
- echo ' path = /data' >> /opt/etc/samba/smb.conf
- echo ' browseable = yes' >> /opt/etc/samba/smb.conf
- echo ' writable = yes' >> /opt/etc/samba/smb.conf
- echo ' guest ok = yes' >> /opt/etc/samba/smb.conf
- echo ' guest only = yes' >> /opt/etc/samba/smb.conf
- echo ' force user = root' >> /opt/etc/samba/smb.conf
- echo ' create mask = 0777' >> /opt/etc/samba/smb.conf
- echo ' directory mask = 0777' >> /opt/etc/samba/smb.conf
- # G. 启动
- /opt/etc/init.d/S91smb start
- sleep 2
- ps | grep smbd
- # H. 验证端口(应看到 139 和 445 都在 LISTEN)
- netstat -tlnp | grep -E "445|139"
- # I. 备份一份干净的 smb.conf,供开机自启时恢复
- cp /opt/etc/samba/smb.conf /data/dropbear/smb.conf.bak
- # J. 创建开机自动启动脚本(含 NSS 重建 + /tmp 软链 + smb.conf 恢复)
- rm -rf /data/dropbear/samba_start.sh
- echo '#!/system/bin/sh' > /data/dropbear/samba_start.sh
- echo 'while [ ! -x /opt/sbin/smbd ]; do sleep 1; done' >> /data/dropbear/samba_start.sh
- echo 'sleep 3' >> /data/dropbear/samba_start.sh
- echo 'mkdir -p /sqlite_stmt_journals' >> /data/dropbear/samba_start.sh
- echo 'echo "root:x:0:0:root:/root:/opt/bin/sh" > /opt/etc/passwd' >> /data/dropbear/samba_start.sh
- echo 'echo "nobody:x:99:99:nobody:/:/opt/bin/sh" >> /opt/etc/passwd' >> /data/dropbear/samba_start.sh
- echo 'echo "root:x:0:" > /opt/etc/group' >> /data/dropbear/samba_start.sh
- echo 'echo "nobody:x:99:" >> /opt/etc/group' >> /data/dropbear/samba_start.sh
- echo 'echo "passwd: files" > /opt/etc/nsswitch.conf' >> /data/dropbear/samba_start.sh
- echo 'echo "shadow: files" >> /opt/etc/nsswitch.conf' >> /data/dropbear/samba_start.sh
- echo 'echo "group: files" >> /opt/etc/nsswitch.conf' >> /data/dropbear/samba_start.sh
- echo 'echo "hosts: files dns" >> /opt/etc/nsswitch.conf' >> /data/dropbear/samba_start.sh
- echo 'mount -o remount,rw / 2>/dev/null' >> /data/dropbear/samba_start.sh
- echo 'ln -s /opt/tmp /tmp' >> /data/dropbear/samba_start.sh
- echo 'mkdir -p /opt/var/log/samba /opt/var/lib/samba/private /opt/var/cache/samba /opt/var/run/samba/ncalrpc' >> /data/dropbear/samba_start.sh
- echo 'mkdir -p /opt/etc/samba' >> /data/dropbear/samba_start.sh
- echo 'cp /data/dropbear/smb.conf.bak /opt/etc/samba/smb.conf' >> /data/dropbear/samba_start.sh
- echo 'killall smbd nmbd 2>/dev/null' >> /data/dropbear/samba_start.sh
- echo 'sleep 1' >> /data/dropbear/samba_start.sh
- echo '/opt/etc/init.d/S91smb start' >> /data/dropbear/samba_start.sh
- chmod 755 /data/dropbear/samba_start.sh
- cat /data/dropbear/samba_start.sh
- # K. 添加到开机启动
- mount -o remount,rw /system
- sed -i '/samba/d' /system/bin/chrome.sh
- echo '( /data/dropbear/samba_start.sh >>/opt/var/log/samba/boot.log 2>&1 ) &' >> /system/bin/chrome.sh
- mount -o remount,ro /system
- cat /system/bin/chrome.sh
- ######################################################################
- ## 5. 安装 qbittorrent 并开机自动启动
- ######################################################################
- # A. 提前创建临时目录,以免部署出错,以后加到开机自启动里
- mkdir -p /sqlite_stmt_journals
- # B. 安装
- /opt/bin/opkg install qbittorrent
- # C. 启动后访问 http://192.168.0.5:8080/ 即可
- /opt/bin/qbittorrent-nox -d --profile=/data/qb_config
- # D. 创建自动启动脚本
- rm -rf /data/dropbear/qbittorrent_start.sh;echo '#!/system/bin/sh' > /data/dropbear/qbittorrent_start.sh;echo 'while [ ! -x /opt/bin/qbittorrent-nox ]; do sleep 1; done' >> /data/dropbear/qbittorrent_start.sh;echo 'sleep 2' >> /data/dropbear/qbittorrent_start.sh;echo 'pkill qbittorrent >/dev/null 2>&1' >> /data/dropbear/qbittorrent_start.sh;echo '/opt/bin/qbittorrent-nox -d --profile=/data/qb_config' >> /data/dropbear/qbittorrent_start.sh;chmod 755 /data/dropbear/qbittorrent_start.sh;cat /data/dropbear/qbittorrent_start.sh
- # E. 添加到开机启动
- echo 'su -c /data/dropbear/qbittorrent_start.sh' >> /system/bin/chrome.sh;cat /system/bin/chrome.sh
- ######################################################################
- ## 6. PHP环境
- ######################################################################
- # 建空的必要目录
- mount -o remount,rw /system;mount -o remount,rw /data;mount -o remount,rw /
- mkdir -p /sqlite_stmt_journals/
- mkdir -p /opt/www /opt/tmp
- # 先下载
- BASE=http://bin.entware.net/armv7sf-k2.6/archive && for p in php7_7.4.26-1_armv7-2.6.ipk php7-cgi_7.4.26-1_armv7-2.6.ipk php7-cli_7.4.26-1_armv7-2.6.ipk php7-fastcgi_7.4.26-1_armv7-2.6.ipk php7-mod-{mysqli,pdo,pdo-mysql,mysqlnd,session,mbstring,curl,gd,iconv,zip,sockets,sqlite3,pdo-sqlite,xml,xmlreader,xmlwriter,dom,simplexml,fileinfo,ctype,tokenizer,phar}_7.4.26-1_armv7-2.6.ipk; do axel -n 4 "$BASE/$p"; done
- ## 安装
- echo "==== [1] lighttpd ===="
- opkg install lighttpd lighttpd-mod-fastcgi
- echo "==== [2] PHP7 核心 ===="
- opkg install php7_7.4.26-1_armv7-2.6.ipk
- opkg install php7-cli_7.4.26-1_armv7-2.6.ipk
- opkg install php7-cgi_7.4.26-1_armv7-2.6.ipk
- opkg install php7-fastcgi_7.4.26-1_armv7-2.6.ipk
- echo "==== [3] 依赖:openssl / pdo / mysqlnd ===="
- # opkg install php7-mod-openssl_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-pdo_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-mysqlnd_7.4.26-1_armv7-2.6.ipk
- echo "==== [4] 数据库 ===="
- opkg install php7-mod-mysqli_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-pdo-mysql_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-sqlite3_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-pdo-sqlite_7.4.26-1_armv7-2.6.ipk
- echo "==== [5] 常用扩展 ===="
- opkg install php7-mod-session_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-mbstring_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-iconv_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-curl_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-gd_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-zip_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-sockets_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-xml_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-xmlreader_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-xmlwriter_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-dom_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-simplexml_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-fileinfo_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-ctype_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-tokenizer_7.4.26-1_armv7-2.6.ipk
- opkg install php7-mod-phar_7.4.26-1_armv7-2.6.ipk
- echo "==== [6] 修 php.ini ===="
- sed -i 's|^doc_root =|;doc_root =|' /opt/etc/php.ini
- echo "==== [7] .so 列表(核对 extension 名) ===="
- ls -1 /opt/lib/php/*.so
- echo "==== [8] 写 lighttpd 配置 ===="
- mkdir -p /opt/etc/lighttpd
- cat > /opt/etc/lighttpd/lighttpd.conf << 'EOF'
- server.modules = (
- "mod_access",
- "mod_fastcgi"
- )
- server.network-backend = "write"
- server.document-root = "/opt/www"
- index-file.names = ( "index.html", "index.htm", "index.php" )
- static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
- server.port = 80
- server.pid-file = "/opt/var/run/lighttpd.pid"
- server.upload-dirs = ( "/opt/tmp" )
- fastcgi.server = ( ".php" =>
- ((
- "bin-path" => "/opt/bin/php-cgi",
- "socket" => "/opt/tmp/php-fastcgi.socket",
- "max-procs" => 1,
- "bin-environment" => (
- "PHP_FCGI_CHILDREN" => "1",
- "PHP_FCGI_MAX_REQUESTS" => "500"
- ),
- "broken-scriptfilename" => "enable"
- ))
- )
- EOF
- echo "==== [9] 建目录、测试文件、启动 ===="
- mkdir -p /opt/www /opt/tmp /opt/var/run /opt/var/log/lighttpd
- chmod 755 /opt/www
- echo "<?php phpinfo(); ?>" > /opt/www/info.php
- chmod 644 /opt/www/info.php
- killall lighttpd php-cgi 2>/dev/null
- sleep 1
- /opt/sbin/lighttpd -f /opt/etc/lighttpd/lighttpd.conf
- sleep 2
- wget -q -O - http://127.0.0.1/info.php | grep -i "php version" && echo "OK" || echo "FAIL"
- # E. 添加到开机启动
- mount -o remount,rw /system;mount -o remount,rw /data;mount -o remount,rw /
- echo '( while [ ! -x /opt/bin/php-cgi ]; do sleep 1; done; /opt/sbin/lighttpd -f /opt/etc/lighttpd/lighttpd.conf >>/opt/var/log/lighttpd/boot.log 2>&1 ) &' >> /system/bin/chrome.sh;cat /system/bin/chrome.sh
- # 如果需要超时记录改为 ( i=0; while [ ! -x /opt/bin/php-cgi ] && [ $i -lt 60 ]; do sleep 1; i=$((i+1)); done; [ -x /opt/bin/php-cgi ] && { mkdir -p /opt/var/log/lighttpd; /opt/sbin/lighttpd -f /opt/etc/lighttpd/lighttpd.conf >>/opt/var/log/lighttpd/boot.log 2>&1; } ) &
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|