#!/bin/sh

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

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
