예제 #1
0
function freeradius()
{
    if (!$GLOBALS["CLASS_USERS"]->FREERADIUS_INSTALLED) {
        if ($GLOBALS["VERBOSE"]) {
            echo __FUNCTION__ . " not installed\n";
        }
        return null;
    }
    $enabled = 1;
    $pid_path = "/var/run/freeradius/freeradius.pid";
    $master_pid = trim(@file_get_contents($pid_path));
    $freeradius = $GLOBALS["CLASS_UNIX"]->find_program("freeradius");
    $enabled = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableFreeRadius");
    if (!is_numeric($enabled)) {
        $enabled = 0;
    }
    $l[] = "[APP_FREERADIUS]";
    $l[] = "service_name=APP_FREERADIUS";
    $l[] = "master_version=" . freeradius_version();
    $l[] = "service_cmd=freeradius";
    $l[] = "service_disabled={$enabled}";
    $l[] = "pid_path={$pid_path}";
    $l[] = "watchdog_features=1";
    $l[] = "family=system";
    if ($enabled == 0) {
        return implode("\n", $l);
        return;
    }
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        $master_pid = $GLOBALS["CLASS_UNIX"]->PIDOF($freeradius);
    }
    if (!$GLOBALS["CLASS_UNIX"]->process_exists($master_pid)) {
        WATCHDOG("APP_FREERADIUS", "freeradius");
        $l[] = "running=0\ninstalled=1";
        $l[] = "";
        return implode("\n", $l);
        return;
    }
    $l[] = "running=1";
    $l[] = GetMemoriesOf($master_pid);
    $l[] = "";
    return implode("\n", $l);
    return;
}
예제 #2
0
function start()
{
    $unix = new unix();
    $sock = new sockets();
    $EnableFreeRadius = $sock->GET_INFO("EnableFreeRadius");
    $EnableChilli = $sock->GET_INFO("EnableChilli");
    if (!is_numeric($EnableFreeRadius)) {
        $EnableFreeRadius = 0;
    }
    if (!is_numeric($EnableChilli)) {
        $EnableChilli = 0;
    }
    if ($EnableChilli == 1) {
        $EnableFreeRadius = 1;
        $sock->SET_INFO("EnableFreeRadius", 1);
    }
    if ($EnableFreeRadius == 0) {
        echo "Starting FreeRadius.............: service is disabled\n";
        stop();
        return;
    }
    $pid = freeradius_pid();
    if ($unix->process_exists($pid)) {
        $pidtime = $unix->PROCCESS_TIME_MIN($pid);
        echo "Starting FreeRadius.............: Already running pid {$pid} since {$pidtime}mn\n";
        return;
    }
    $freeradius = $unix->find_program("freeradius");
    if (!is_file($freeradius)) {
        echo "Starting FreeRadius.............: failed, freeradius, no such binary...\n";
    }
    echo "Starting FreeRadius.............: Building configuration...\n";
    build();
    $freeradius_version = freeradius_version();
    echo "Starting FreeRadius.............: daemon version {$freeradius_version}\n";
    if (CoovaChilliADEnabled()) {
        $ChilliConf = CoovaChilliConf();
        if ($ChilliConf["RADIUS_IF"] != null) {
            $array = $unix->InterfaceToIP($ChilliConf["RADIUS_IF"]);
            $ip = $array["IP"];
            $f[] = "-i {$ip} -p 1812";
        }
    }
    $f[] = "-d /etc/freeradius -n radiusd";
    $cmdline = "{$freeradius} " . @implode(" ", $f);
    shell_exec($cmdline);
    for ($i = 1; $i < 11; $i++) {
        echo "Starting FreeRadius.............: waiting {$i}/10\n";
        sleep(1);
        $pid = freeradius_pid();
        if ($unix->process_exists($pid)) {
            echo "Starting FreeRadius.............: Success PID {$pid}\n";
            return;
        }
    }
    $pid = freeradius_pid();
    if ($unix->process_exists($pid)) {
        echo "Starting FreeRadius.............: Success PID {$pid}\n";
        return;
    } else {
        echo "Starting FreeRadius.............: Failed\n";
        echo "Starting FreeRadius.............: {$cmdline}\n";
    }
}