Skip to content

Commit

Permalink
自动打开WiFi
Browse files Browse the repository at this point in the history
  • Loading branch information
guo-yong-zhi authored and guoyongzhi committed Sep 3, 2021
1 parent 536968c commit 8509d4f
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 31 deletions.
5 changes: 3 additions & 2 deletions filebrowser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Kindle 越狱插件 File Browser 使用说明:
-【 Start (Auth) 】可开启带登录验证的 WEB 服务(默认用户名密码均为:admin)
-【 Reset 】删除包含配置信息的数据文件 filebrowser.db
-【 Stop 】停止 WEB 服务
3. 开启 WEB 服务后,可以在 Kindle 界面的顶部看到 IP 地址,在同一局域网下即可通过浏览器访问此地址。
4. 服务开启后会阻止屏幕自动关闭,第一次按电源键会关闭filebrowser服务,再按即可正常锁屏休眠。
3. 如果服务开启时设备 WiFi 处于关闭状态,WiFi 会被自动打开并在服务关闭后恢复原来状态。
4. 开启 WEB 服务后,可以在 Kindle 界面的顶部看到 IP 地址,在同一局域网下即可通过浏览器访问此地址。
5. 服务开启后会阻止屏幕自动关闭,第一次按电源键会关闭filebrowser服务,再按即可正常锁屏休眠。

=======================================================

Expand Down
2 changes: 1 addition & 1 deletion filebrowser/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<extension>
<information>
<name>File Browser</name>
<version>1.1</version>
<version>1.2</version>
<author>Sparkle</author>
<id>filebrowser</id>
</information>
Expand Down
17 changes: 9 additions & 8 deletions filebrowser/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@
"param": ""
},
{
"name": "Reset",
"name": "Show Status",
"priority": 3,
"action": "rm ./filebrowser.db",
"param": ""
"action": "./show_status.sh",
"param": "",
"exitmenu": false
},
{
"name": "Stop",
"name": "Kill",
"priority": 4,
"action": "killall filebrowser",
"param": ""
},
{
"name": "Show Status",
"action": "./show_status.sh",
"param": "",
"exitmenu": false
"name": "Reset",
"priority": 5,
"action": "rm ./filebrowser.db",
"param": ""
}
]
}
Expand Down
6 changes: 3 additions & 3 deletions filebrowser/show_status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
test_process=$(ps aux | grep "[f]ilebrowser")
if [ -n "$test_process" ]
then
result="File Browser is Running....."
result="File Browser is Running..... "
else
result="File Browser is not running."
result="File Browser is not running "
fi
eips 25 2 "$result"
eips 29 3 "$result"
42 changes: 34 additions & 8 deletions filebrowser/start.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/sh
lipc-set-prop -i com.lab126.powerd preventScreenSaver 1
lipc-wait-event com.lab126.hal powerButtonPressed| if read event; then
lipc-set-prop -i com.lab126.powerd preventScreenSaver 0
killall filebrowser
eips 25 2 "File Browser is turned off. "
fi > /dev/null &

iptables -I INPUT -p tcp --dport 80 -j ACCEPT
eips 25 1 "IP: `ifconfig wlan0 | grep 'inet addr' | awk -F '[ :]' '{print $13}'`"

# enable wireless if it is currently off
WIFI_IS_OFF=0
if [ 0 -eq `lipc-get-prop com.lab126.cmd wirelessEnable` ]; then
eips 30 3 "WiFi is off, turning it on now"
lipc-set-prop com.lab126.cmd wirelessEnable 1
WIFI_IS_OFF=1
fi

# start filebrowser in the background
if [ "$(ps aux | grep '[f]ilebrowser')" ];then killall filebrowser;fi

if [ ! -f ./filebrowser.db ]
Expand All @@ -21,4 +22,29 @@ else
./filebrowser config set --auth.method=noauth > /dev/null
fi
./filebrowser -a 0.0.0.0 -p 80 -r /mnt/us > /dev/null
fi &

# refresh IP display in the background
while :; do
eips 30 1 "== `ifconfig wlan0 | grep 'inet addr' | awk -F '[ :]' '{print $13}'` =="
sleep 5
done > /dev/null &

# waiting for powerButtonPressed
lipc-set-prop -i com.lab126.powerd preventScreenSaver 1
lipc-wait-event com.lab126.hal powerButtonPressed | read event #it's blocking
lipc-set-prop -i com.lab126.powerd preventScreenSaver 0
kill $(jobs -p)
eips 30 3 "File Browser is turned off. "

# Restore WiFi status
if [ 1 -eq $WIFI_IS_OFF ]; then
lipc-set-prop com.lab126.cmd wirelessEnable 0
sleep 0.5
eips 30 3 "Turning off WiFi "
fi

# Clear screen
sleep 1
eips 30 1 " "
eips 30 3 " "
44 changes: 35 additions & 9 deletions filebrowser/start_auth.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/sh
lipc-set-prop -i com.lab126.powerd preventScreenSaver 1
lipc-wait-event com.lab126.hal powerButtonPressed| if read event; then
lipc-set-prop -i com.lab126.powerd preventScreenSaver 0
killall filebrowser
eips 25 2 "File Browser is turned off. "
fi > /dev/null &

iptables -I INPUT -p tcp --dport 80 -j ACCEPT
eips 25 1 "IP: `ifconfig wlan0 | grep 'inet addr' | awk -F '[ :]' '{print $13}'`"

# enable wireless if it is currently off
WIFI_IS_OFF=0
if [ 0 -eq `lipc-get-prop com.lab126.cmd wirelessEnable` ]; then
eips 30 3 "WiFi is off, turning it on now"
lipc-set-prop com.lab126.cmd wirelessEnable 1
WIFI_IS_OFF=1
fi

# start filebrowser in the background
if [ "$(ps aux | grep '[f]ilebrowser')" ];then killall filebrowser;fi

if [ -f ./filebrowser.db ]
Expand All @@ -19,4 +20,29 @@ then
./filebrowser config set --auth.method=json > /dev/null
fi
fi
./filebrowser -a 0.0.0.0 -p 80 -r /mnt/us > /dev/null
./filebrowser -a 0.0.0.0 -p 80 -r /mnt/us > /dev/null &

# refresh IP display in the background
while :; do
eips 30 1 "== `ifconfig wlan0 | grep 'inet addr' | awk -F '[ :]' '{print $13}'` =="
sleep 5
done > /dev/null &

# waiting for powerButtonPressed
lipc-set-prop -i com.lab126.powerd preventScreenSaver 1
lipc-wait-event com.lab126.hal powerButtonPressed | read event #it's blocking
lipc-set-prop -i com.lab126.powerd preventScreenSaver 0
kill $(jobs -p)
eips 30 3 "File Browser is turned off. "

# Restore WiFi status
if [ 1 -eq $WIFI_IS_OFF ]; then
lipc-set-prop com.lab126.cmd wirelessEnable 0
sleep 0.5
eips 30 3 "Turning off WiFi "
fi

# Clear screen
sleep 1
eips 30 1 " "
eips 30 3 " "

0 comments on commit 8509d4f

Please sign in to comment.