#!/bin/sh

APP_NAME=rftd
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
$sudoprefix chmod 755 ./${APP_NAME}
$sudoprefix chmod 755 ./smartctl 2>/dev/null

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

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

    line=$(./$APP_NAME -q -p | grep ftpd_passive_begin_port)
    ftpd_passive_begin_port="${line#*=}"
    line=$(./$APP_NAME -q -p | grep ftpd_passive_end_port)
    ftpd_passive_end_port="${line#*=}"
    #set_firewall_port_range $ftpd_passive_begin_port $ftpd_passive_end_port
}

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

