用香橙派lite2加脚本变成wifi-u盘,因为买了个香橙派,也实在毫无用处,大材小用了。也可以用tp703路由器(刷openwrt)。
----------------------------------------------------------------------------
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: wifi-usbdisk
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: usbdisk wifi.
### END INIT INFO
sh /home/sleep &
sh /home/wifi-usbdisk &
exit
------------------------------------------------------------------------------------
这个放在/etc/init.d文件夹用来开机自动启动,还得执行命令update-rc.d wifi-usbdisk defaults 90
下边是放在/home里边的sleep:
---------------------------------------------------------------------------
sleep 60s
echo 480000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 0 >/sys/devices/system/cpu/cpu1/online
echo 0 >/sys/devices/system/cpu/cpu2/online
echo 0 >/sys/devices/system/cpu/cpu3/online
#cpu烫手, 几分钟自动关机,降频不管用,关cpu核心管用
#cat /sys/class/thermal/thermal_zone0/temp
------------------------------------------------------------------------------------------
下边是放在/home里边的wifi-usbdisk
--------------------------------------------------------------------------------------
echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
#nmcli dev wifi connect OpenWrt5 password l
url="http://192.168.123.200/Download/"
modprobe g_mass_storage file=/home/4 stall=0 removeable=y
cat /sys/devices/platform/soc/usbc0/usb_device
if [ ! -e /tmp/tmp ]
then
mkdir /tmp/tmp
fi
if [ ! -e /tmp/fff ]
then
mkfifo /tmp/fff
fi
while true
do
nc -N -q 0 -w 5 -l -p 7800 > /tmp/fff &
read ddd < /tmp/fff
if [ $ddd = "delete" ]
then
cat /sys/devices/platform/soc/usbc0/usb_host
mount -o offset=1048576 /home/4 /mnt
rm -r /mnt/*
umount /mnt
cat /sys/devices/platform/soc/usbc0/usb_device
echo "xxxxxxxxxx"
else
if [ -e /tmp/tmp/* ]
then
rm /tmp/tmp/*
fi
wget -T 5 $url$ddd -O /tmp/tmp/$ddd
cat /sys/devices/platform/soc/usbc0/usb_host
mount -o offset=1048576 /home/4 /mnt
if [ -e /tmp/tmp/* ]
then
cp /tmp/tmp/* /mnt/
fi
umount /mnt
cat /sys/devices/platform/soc/usbc0/usb_device
echo "ok"
fi
done
-------------------------------------------------------------
下边是测试用的python程序
-------------------------------------------------------------
import socket
import time
addr = socket.getaddrinfo('192.168.123.171', 7800)[0][-1]
s = socket.socket()
s.connect(addr)
#s.send(b"dd")
#time.sleep(10)
s.send(b"nginx-1.19.3_Compiled.rar\n")
#s.send(b"delete\n")
s.close()