Skip to content

Commit 159b2a0

Browse files
committed
code refactoring
1 parent b13a085 commit 159b2a0

12 files changed

+69
-146
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Kindle越狱插件FileBrowser使用说明:
2+
3+
=======================================================
4+
5+
开始以下步骤前需确保你的Kindle已经成功越狱,并安装了KUAL插件。
6+
7+
1. 下载插件压缩包,解压得到filebrowser文件夹,将其拷贝到Kindle根目录下的extensions目录中。
8+
2. 插件安装完成后,进入Kindle界面,打开KUAL,可以在菜单中找到【FileBrowser】,可进行如下操作:
9+
* 【Start】可开启免登录的WEB服务
10+
* 【Start(Auth)】可开启带登录验证的WEB服务(默认用户名密码均为:admin)
11+
* 【Kill】强行中止后台的WEB服务(用于debug),勿用于正常退出。
12+
* 【Reset】删除包含配置信息的数据文件filebrowser.db。谨慎点击。
13+
14+
3. 如果服务开启时设备WiFi处于关闭状态,WiFi会被自动打开并在服务关闭后恢复原来状态。
15+
4. 开启WEB服务后,可以在Kindle界面的顶部看到IP地址,在同一局域网下即可通过浏览器访问此地址。
16+
5. 服务开启后Kindle会保持屏幕常亮且不会休眠,使用完成后请按电源键关闭本服务以恢复到正常状态,此时再按电源键即可正常锁屏休眠。
17+
6. 如果有IP显示残留则意味着服务未正常退出,这提醒用户此时设备可能依然处在屏幕常亮状态。正常情况下按一次电源键后IP会消失,否则请尝试点击【Kill】或重启设备。相反,IP显示消失则意味着服务已经完全关闭,保证了不会有后台任务耗电。
18+
7. 如果IP及其它提示的显示位置不居中,可以自行在电脑上修改文件`filebrowser_wrapper.sh``kill.sh``show_status.sh`开头的`col=30`。例如改为`col=20`可以使显示更靠左。
19+
20+
=======================================================
21+
* 可前往 https://github.com/filebrowser/filebrowser 下载linux-armv7版本的release,用以更新插件的二进制文件`extensions/filebrowser/filebrowser`
22+
* 详细说明及问题反馈:https://bookfere.com/post/823.html

filebrowser/config.xml renamed to config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<extension>
33
<information>
44
<name>File Browser</name>
5-
<version>1.3</version>
5+
<version>1.4</version>
66
<author>Sparkle</author>
77
<author>guoyongzhi</author>
88
<id>filebrowser</id>
File renamed without changes.

filebrowser/README.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

filebrowser/filebrowser_start.sh

Lines changed: 0 additions & 50 deletions
This file was deleted.

filebrowser/filebrowser_start_auth.sh

Lines changed: 0 additions & 48 deletions
This file was deleted.

filebrowser_start.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
workdir=$1
2+
if [ "$workdir" == "" ]; then workdir="/mnt/us"; fi
3+
if [ ! -f ./filebrowser.db ]
4+
then
5+
./filebrowser --noauth -a 0.0.0.0 -p 80 -r "$workdir" > /dev/null
6+
else
7+
METHOD=$(./filebrowser config cat | grep 'Auth method' | awk '{print $3}')
8+
if [ 'noauth' != "$METHOD" ];
9+
then
10+
./filebrowser config set --auth.method=noauth > /dev/null
11+
fi
12+
./filebrowser -a 0.0.0.0 -p 80 -r "$workdir" > /dev/null
13+
fi

filebrowser_start_auth.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
workdir=$1
2+
if [ "$workdir" == "" ]; then workdir="/mnt/us"; fi
3+
if [ -f ./filebrowser.db ]
4+
then
5+
METHOD=$(./filebrowser config cat | grep 'Auth method' | awk '{print $3}')
6+
if [ 'json' != "$METHOD" ]
7+
then
8+
./filebrowser config set --auth.method=json > /dev/null
9+
fi
10+
fi
11+
./filebrowser -a 0.0.0.0 -p 80 -r "$workdir" > /dev/null
Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
#!/bin/sh
2+
col=30
23
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
3-
44
# enable wireless if it is currently off
55
WIFI_IS_OFF=0
66
if [ 0 -eq `lipc-get-prop com.lab126.cmd wirelessEnable` ]; then
7-
eips 30 3 "WiFi is off, turning it on now"
7+
eips $col 3 "WiFi is off, turning it on now"
88
lipc-set-prop com.lab126.cmd wirelessEnable 1
99
WIFI_IS_OFF=1
1010
fi
1111

1212
# start filebrowser in the background
1313
if [ "$(ps aux | grep '[f]ilebrowser')" ];then killall filebrowser;fi
14-
15-
if [ -f ./filebrowser.db ]
16-
then
17-
METHOD=$(./filebrowser config cat | grep 'Auth method' | awk '{print $3}')
18-
if [ 'json' != "$METHOD" ]
19-
then
20-
./filebrowser config set --auth.method=json > /dev/null
21-
fi
22-
fi
23-
./filebrowser -a 0.0.0.0 -p 80 -r / > /dev/null &
14+
"$@" &
2415

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

@@ -33,16 +24,16 @@ lipc-set-prop -i com.lab126.powerd preventScreenSaver 1
3324
lipc-wait-event com.lab126.hal powerButtonPressed | read event #it's blocking
3425
lipc-set-prop -i com.lab126.powerd preventScreenSaver 0
3526
kill $(jobs -p)
36-
eips 30 3 "File Browser is turned off. "
27+
eips $col 3 "File Browser is turned off. "
3728

3829
# Restore WiFi status
3930
if [ 1 -eq $WIFI_IS_OFF ]; then
4031
lipc-set-prop com.lab126.cmd wirelessEnable 0
4132
sleep 0.5
42-
eips 30 3 "Turning off WiFi "
33+
eips $col 3 "Turning off WiFi "
4334
fi
4435

4536
# Clear screen
4637
sleep 1
47-
eips 30 1 " "
48-
eips 30 3 " "
38+
eips $col 1 " "
39+
eips $col 3 " "
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
col=30
2+
eips $col 3 "killing... "
13
lipc-send-event com.lab126.hal powerButtonPressed
24
sleep 5
35
ps aux | grep [f]ilebrowser | awk '{print $2}' | xargs -i kill {} > /dev/null
46
lipc-set-prop -i com.lab126.powerd preventScreenSaver 0
5-
eips 30 1 " "
6-
eips 30 3 " "
7+
eips $col 1 " "
8+
eips $col 3 " "

filebrowser/menu.json renamed to menu.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
{
88
"name": "Start",
99
"priority": 1,
10-
"action": "./filebrowser_start.sh",
10+
"action": "./filebrowser_wrapper.sh sh ./filebrowser_start.sh",
1111
"param": ""
1212
},
1313
{
1414
"name": "Start (Auth)",
1515
"priority": 2,
16-
"action": "./filebrowser_start_auth.sh",
16+
"action": "./filebrowser_wrapper.sh sh ./filebrowser_start_auth.sh",
1717
"param": ""
1818
},
1919
{
2020
"name": "Start (root path)",
2121
"priority": 3,
22-
"action": "./filebrowser_start_auth_root.sh",
22+
"action": "./filebrowser_wrapper.sh sh ./filebrowser_start_auth.sh /",
2323
"param": ""
2424
},
2525
{
@@ -32,14 +32,16 @@
3232
{
3333
"name": "Kill",
3434
"priority": 5,
35-
"action": "./filebrowser_kill.sh",
36-
"param": ""
35+
"action": "./kill.sh",
36+
"param": "",
37+
"exitmenu": false
3738
},
3839
{
3940
"name": "Reset",
4041
"priority": 6,
4142
"action": "rm ./filebrowser.db",
42-
"param": ""
43+
"param": "",
44+
"exitmenu": false
4345
}
4446
]
4547
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/sh
2-
2+
col=30
33
test_process=$(ps aux | grep "[f]ilebrowser")
44
if [ -n "$test_process" ]
55
then
66
result="File Browser is Running..... "
77
else
88
result="File Browser is not running "
99
fi
10-
eips 30 3 "$result"
10+
eips $col 3 "$result"

0 commit comments

Comments
 (0)