diff --git a/filebrowser/config.xml b/filebrowser/config.xml index bf22853..b0524f9 100644 --- a/filebrowser/config.xml +++ b/filebrowser/config.xml @@ -2,8 +2,9 @@ File Browser - 1.2 + 1.3 Sparkle + guoyongzhi filebrowser diff --git a/filebrowser/filebrowser b/filebrowser/filebrowser index abf17d6..4a088cb 100644 Binary files a/filebrowser/filebrowser and b/filebrowser/filebrowser differ diff --git a/filebrowser/filebrowser_kill.sh b/filebrowser/filebrowser_kill.sh new file mode 100644 index 0000000..7f1be47 --- /dev/null +++ b/filebrowser/filebrowser_kill.sh @@ -0,0 +1,6 @@ +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 diff --git a/filebrowser/start.sh b/filebrowser/filebrowser_start.sh similarity index 100% rename from filebrowser/start.sh rename to filebrowser/filebrowser_start.sh diff --git a/filebrowser/start_auth.sh b/filebrowser/filebrowser_start_auth.sh similarity index 100% rename from filebrowser/start_auth.sh rename to filebrowser/filebrowser_start_auth.sh diff --git a/filebrowser/filebrowser_start_auth_root.sh b/filebrowser/filebrowser_start_auth_root.sh new file mode 100644 index 0000000..e97f45e --- /dev/null +++ b/filebrowser/filebrowser_start_auth_root.sh @@ -0,0 +1,48 @@ +#!/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 / > /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/menu.json b/filebrowser/menu.json index f3420f9..3909944 100644 --- a/filebrowser/menu.json +++ b/filebrowser/menu.json @@ -7,31 +7,37 @@ { "name": "Start", "priority": 1, - "action": "./start.sh", + "action": "./filebrowser_start.sh", "param": "" }, { "name": "Start (Auth)", "priority": 2, - "action": "./start_auth.sh", + "action": "./filebrowser_start_auth.sh", "param": "" }, { - "name": "Show Status", + "name": "Start (root path)", "priority": 3, + "action": "./filebrowser_start_auth_root.sh", + "param": "" + }, + { + "name": "Show Status", + "priority": 4, "action": "./show_status.sh", "param": "", "exitmenu": false }, { "name": "Kill", - "priority": 4, - "action": "killall filebrowser", + "priority": 5, + "action": "./filebrowser_kill.sh", "param": "" }, { "name": "Reset", - "priority": 5, + "priority": 6, "action": "rm ./filebrowser.db", "param": "" } diff --git a/filebrowser/show_status.sh b/filebrowser/show_status.sh index 671112f..3dc3a17 100644 --- a/filebrowser/show_status.sh +++ b/filebrowser/show_status.sh @@ -7,4 +7,4 @@ then else result="File Browser is not running " fi -eips 29 3 "$result" +eips 30 3 "$result"