diff --git a/README.md b/README.md new file mode 100644 index 0000000..705a27d --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +Kindle越狱插件FileBrowser使用说明: + +======================================================= + +开始以下步骤前需确保你的Kindle已经成功越狱,并安装了KUAL插件。 + +1. 下载插件压缩包,解压得到filebrowser文件夹,将其拷贝到Kindle根目录下的extensions目录中。 +2. 插件安装完成后,进入Kindle界面,打开KUAL,可以在菜单中找到【FileBrowser】,可进行如下操作: + * 【Start】可开启免登录的WEB服务 + * 【Start(Auth)】可开启带登录验证的WEB服务(默认用户名密码均为:admin) + * 【Kill】强行中止后台的WEB服务(用于debug),勿用于正常退出。 + * 【Reset】删除包含配置信息的数据文件filebrowser.db。谨慎点击。 + +3. 如果服务开启时设备WiFi处于关闭状态,WiFi会被自动打开并在服务关闭后恢复原来状态。 +4. 开启WEB服务后,可以在Kindle界面的顶部看到IP地址,在同一局域网下即可通过浏览器访问此地址。 +5. 服务开启后Kindle会保持屏幕常亮且不会休眠,使用完成后请按电源键关闭本服务以恢复到正常状态,此时再按电源键即可正常锁屏休眠。 +6. 如果有IP显示残留则意味着服务未正常退出,这提醒用户此时设备可能依然处在屏幕常亮状态。正常情况下按一次电源键后IP会消失,否则请尝试点击【Kill】或重启设备。相反,IP显示消失则意味着服务已经完全关闭,保证了不会有后台任务耗电。 +7. 如果IP及其它提示的显示位置不居中,可以自行在电脑上修改文件`filebrowser_wrapper.sh`、`kill.sh`和`show_status.sh`开头的`col=30`。例如改为`col=20`可以使显示更靠左。 + +======================================================= +* 可前往 https://github.com/filebrowser/filebrowser 下载linux-armv7版本的release,用以更新插件的二进制文件`extensions/filebrowser/filebrowser` +* 详细说明及问题反馈:https://bookfere.com/post/823.html diff --git a/filebrowser/config.xml b/config.xml similarity index 91% rename from filebrowser/config.xml rename to config.xml index b0524f9..c8dda6d 100644 --- a/filebrowser/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ File Browser - 1.3 + 1.4 Sparkle guoyongzhi filebrowser diff --git a/filebrowser/filebrowser b/filebrowser similarity index 100% rename from filebrowser/filebrowser rename to filebrowser diff --git a/filebrowser/README.md b/filebrowser/README.md deleted file mode 100644 index 863e658..0000000 --- a/filebrowser/README.md +++ /dev/null @@ -1,20 +0,0 @@ -Kindle 越狱插件 File Browser 使用说明: - -======================================================= - -开始以下步骤前需确保你的 Kindle 已经成功越狱,并安装了 KUAL 插件。 - -1. 下载插件压缩包,解压得到 filebrowser 文件夹,将其拷贝到 Kindle 根目录下的 extensions 目录中。 -2. 插件安装完成后,进入 Kindle 界面,打开 KUAL,可以在菜单中找到【File Browser】,可进行如下操作: - -【 Start 】可开启免登录的 WEB 服务 - -【 Start (Auth) 】可开启带登录验证的 WEB 服务(默认用户名密码均为:admin) - -【 Reset 】删除包含配置信息的数据文件 filebrowser.db。谨慎点击。 - -【 Kill 】强行中止后台的 WEB 服务(用于debug),请勿用于正常退出。谨慎点击。 -3. 如果服务开启时设备 WiFi 处于关闭状态,WiFi 会被自动打开并在服务关闭后恢复原来状态。 -4. 开启 WEB 服务后,可以在 Kindle 界面的顶部看到 IP 地址,在同一局域网下即可通过浏览器访问此地址。 -5. 服务开启后会阻止屏幕自动关闭,请使用电源键关闭filebrowser服务,再按电源键即可正常锁屏休眠。 -6. 顶部残留 IP 显示意味着服务未完全关闭,提醒用户该设备将不会熄屏和休眠。按一次电源键后 IP 会消失,否则请重启设备。 - -======================================================= -可前往 https://github.com/filebrowser/filebrowser 下载linux-armv7版本的release,用以更新插件的二进制文件`extensions/filebrowser/filebrowser` -详细说明及问题反馈:https://bookfere.com/post/823.html diff --git a/filebrowser/filebrowser_start.sh b/filebrowser/filebrowser_start.sh deleted file mode 100644 index 5a663ba..0000000 --- a/filebrowser/filebrowser_start.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -iptables -I INPUT -p tcp --dport 80 -j ACCEPT - -# 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 ] -then - ./filebrowser --noauth -a 0.0.0.0 -p 80 -r /mnt/us > /dev/null -else - METHOD=$(./filebrowser config cat | grep 'Auth method' | awk '{print $3}') - if [ 'noauth' != "$METHOD" ]; - then - ./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 " " diff --git a/filebrowser/filebrowser_start_auth.sh b/filebrowser/filebrowser_start_auth.sh deleted file mode 100644 index 8ccaa73..0000000 --- a/filebrowser/filebrowser_start_auth.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -iptables -I INPUT -p tcp --dport 80 -j ACCEPT - -# 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 ] -then - METHOD=$(./filebrowser config cat | grep 'Auth method' | awk '{print $3}') - if [ 'json' != "$METHOD" ] - then - ./filebrowser config set --auth.method=json > /dev/null - fi -fi -./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 " " diff --git a/filebrowser_start.sh b/filebrowser_start.sh new file mode 100644 index 0000000..a2f2568 --- /dev/null +++ b/filebrowser_start.sh @@ -0,0 +1,13 @@ +workdir=$1 +if [ "$workdir" == "" ]; then workdir="/mnt/us"; fi +if [ ! -f ./filebrowser.db ] +then + ./filebrowser --noauth -a 0.0.0.0 -p 80 -r "$workdir" > /dev/null +else + METHOD=$(./filebrowser config cat | grep 'Auth method' | awk '{print $3}') + if [ 'noauth' != "$METHOD" ]; + then + ./filebrowser config set --auth.method=noauth > /dev/null + fi + ./filebrowser -a 0.0.0.0 -p 80 -r "$workdir" > /dev/null +fi \ No newline at end of file diff --git a/filebrowser_start_auth.sh b/filebrowser_start_auth.sh new file mode 100644 index 0000000..4eb50ad --- /dev/null +++ b/filebrowser_start_auth.sh @@ -0,0 +1,11 @@ +workdir=$1 +if [ "$workdir" == "" ]; then workdir="/mnt/us"; fi +if [ -f ./filebrowser.db ] +then + METHOD=$(./filebrowser config cat | grep 'Auth method' | awk '{print $3}') + if [ 'json' != "$METHOD" ] + then + ./filebrowser config set --auth.method=json > /dev/null + fi +fi +./filebrowser -a 0.0.0.0 -p 80 -r "$workdir" > /dev/null \ No newline at end of file diff --git a/filebrowser/filebrowser_start_auth_root.sh b/filebrowser_wrapper.sh similarity index 58% rename from filebrowser/filebrowser_start_auth_root.sh rename to filebrowser_wrapper.sh index e97f45e..2e79e73 100644 --- a/filebrowser/filebrowser_start_auth_root.sh +++ b/filebrowser_wrapper.sh @@ -1,30 +1,21 @@ #!/bin/sh +col=30 iptables -I INPUT -p tcp --dport 80 -j ACCEPT - # 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" + eips $col 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 ] -then - METHOD=$(./filebrowser config cat | grep 'Auth method' | awk '{print $3}') - if [ 'json' != "$METHOD" ] - then - ./filebrowser config set --auth.method=json > /dev/null - fi -fi -./filebrowser -a 0.0.0.0 -p 80 -r / > /dev/null & +"$@" & # refresh IP display in the background while :; do - eips 30 1 "== `ifconfig wlan0 | grep 'inet addr' | awk -F '[ :]' '{print $13}'` ==" + eips $col 1 "== `ifconfig wlan0 | grep 'inet addr' | awk -F '[ :]' '{print $13}'` ==" sleep 5 done > /dev/null & @@ -33,16 +24,16 @@ 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. " +eips $col 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 " + eips $col 3 "Turning off WiFi " fi # Clear screen sleep 1 -eips 30 1 " " -eips 30 3 " " +eips $col 1 " " +eips $col 3 " " diff --git a/filebrowser/filebrowser_kill.sh b/kill.sh similarity index 59% rename from filebrowser/filebrowser_kill.sh rename to kill.sh index 7f1be47..b08d7ae 100644 --- a/filebrowser/filebrowser_kill.sh +++ b/kill.sh @@ -1,6 +1,8 @@ +col=30 +eips $col 3 "killing... " lipc-send-event com.lab126.hal powerButtonPressed sleep 5 ps aux | grep [f]ilebrowser | awk '{print $2}' | xargs -i kill {} > /dev/null lipc-set-prop -i com.lab126.powerd preventScreenSaver 0 -eips 30 1 " " -eips 30 3 " " \ No newline at end of file +eips $col 1 " " +eips $col 3 " " \ No newline at end of file diff --git a/filebrowser/menu.json b/menu.json similarity index 65% rename from filebrowser/menu.json rename to menu.json index 3909944..8e557c7 100644 --- a/filebrowser/menu.json +++ b/menu.json @@ -7,19 +7,19 @@ { "name": "Start", "priority": 1, - "action": "./filebrowser_start.sh", + "action": "./filebrowser_wrapper.sh sh ./filebrowser_start.sh", "param": "" }, { "name": "Start (Auth)", "priority": 2, - "action": "./filebrowser_start_auth.sh", + "action": "./filebrowser_wrapper.sh sh ./filebrowser_start_auth.sh", "param": "" }, { "name": "Start (root path)", "priority": 3, - "action": "./filebrowser_start_auth_root.sh", + "action": "./filebrowser_wrapper.sh sh ./filebrowser_start_auth.sh /", "param": "" }, { @@ -32,14 +32,16 @@ { "name": "Kill", "priority": 5, - "action": "./filebrowser_kill.sh", - "param": "" + "action": "./kill.sh", + "param": "", + "exitmenu": false }, { "name": "Reset", "priority": 6, "action": "rm ./filebrowser.db", - "param": "" + "param": "", + "exitmenu": false } ] } diff --git a/filebrowser/show_status.sh b/show_status.sh similarity index 86% rename from filebrowser/show_status.sh rename to show_status.sh index 3dc3a17..71af43e 100644 --- a/filebrowser/show_status.sh +++ b/show_status.sh @@ -1,5 +1,5 @@ #!/bin/sh - +col=30 test_process=$(ps aux | grep "[f]ilebrowser") if [ -n "$test_process" ] then @@ -7,4 +7,4 @@ then else result="File Browser is not running " fi -eips 30 3 "$result" +eips $col 3 "$result"