#!/bin/sh

APP_NAME=rfsd
if dirname "$0" 1>/dev/null 2>/dev/null; then
    SH_DIR="$(cd "$(dirname "$0")";pwd)"
    cd $SH_DIR
fi
. ./$APP_NAME-inc.sh
init_env
set_sys_env
$sudoprefix chmod 755 ./${APP_NAME}
$sudoprefix chmod 755 ./smartctl 2>/dev/null

set_firewall()
{
    line=$(./$APP_NAME -q -p | grep rfp_server_port)
    set_firewall_port "${line#*=}"

    line=$(./$APP_NAME -q -p | grep rfps_server_port)
    set_firewall_port "${line#*=}"

    #line=$(./$APP_NAME -q -p | grep http_server_port)
    #set_firewall_port "${line#*=}"
}

$sudoprefix ./$APP_NAME-stop.sh
set_firewall
$sudoprefix ./$APP_NAME -d
$sudoprefix ./$APP_NAME-daemon.sh &

