Exemple #1
0
function moduleAddServer($url, $data)
{
    /** Attempt to determine default variables */
    $named_conf = findFile('named.conf');
    $data['server_run_as_predefined'] = 'named';
    if ($named_conf) {
        if (function_exists('posix_getgrgid')) {
            if ($run_as = posix_getgrgid(filegroup($named_conf))) {
                $data['server_run_as_predefined'] = $run_as['name'];
            }
        }
        $data['server_config_file'] = $named_conf;
        $server_root = getParameterValue('directory', $named_conf, '"');
        if ($server_root === false) {
            if (file_exists($named_conf . '.options')) {
                $server_root = getParameterValue('directory', $named_conf . '.options', '"');
            }
        }
        $data['server_root_dir'] = $server_root;
        $data['server_zones_dir'] = dirname($named_conf) == '/etc' ? null : dirname($named_conf) . '/zones';
    }
    $data['server_chroot_dir'] = detectChrootDir();
    /** Add the server to the account */
    $app = detectDaemonVersion(true);
    if ($app === null) {
        echo "failed\n\n";
        echo fM("Cannot find a supported DNS server - please check the README document for supported DNS servers.  Aborting.\n");
        exit(1);
    }
    $data['server_type'] = $app['server']['type'];
    $data['server_version'] = $app['app_version'];
    $raw_data = getPostData(str_replace('genserial', 'addserial', $url), $data);
    $raw_data = $data['compress'] ? @unserialize(gzuncompress($raw_data)) : @unserialize($raw_data);
    if (!is_array($raw_data)) {
        if (!$raw_data) {
            echo "An error occurred\n";
        } else {
            echo $raw_data;
        }
        exit(1);
    }
    return array('data' => $data, 'add_result' => "Success\n");
}
Exemple #2
0
    echo "The facileManager core client scripts are required, but not found.\n";
    exit(1);
}
/** Get domain_id */
for ($i = 0; $i < count($argv); $i++) {
    if (strncmp(strtolower($argv[$i]), 'id=', 3) == 0) {
        $data['domain_id'] = substr($argv[$i], 3);
    }
}
/** Check running user */
if (exec(findProgram('whoami')) != $whoami && !$dryrun) {
    echo fM("This script must run as {$whoami}.\n");
    exit(1);
}
/** Check if running supported version */
$data['server_version'] = detectDaemonVersion();
/** Build everything required via cron */
if ($cron) {
    $data['action'] = 'cron';
}
/** Build the server config */
if ($buildconf) {
    $data['action'] = 'buildconf';
}
/** Build the zone files */
if ($zones) {
    $data['action'] = 'zones';
}
/** Dump the cache */
if ($dump_cache) {
    manageCache('dumpdb -cache', 'Dumping cache');