3 // /etc/ntp/step-tickers generator
5 // Marc Fiuczynski <mef@cs.princeton.edu>
6 // Copyright (C) 2006 The Trustees of Princeton University
11 // Get admin API handle
12 require_once 'plc_api.php';
15 $config_directory= "/var/www/html/PlanetLabConf/ntp/";
16 $file_prefix= "ntp.conf.";
17 $default_name = "default";
18 $file_name = $config_directory . $file_prefix . $default_name;
21 $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
22 if (!empty($interfaces)) {
23 $nodes = $adm->GetNodes(array($interfaces[0]['node_id']));
34 $hostname= trim($node['hostname']);
36 /* Look for config file */
38 $hostname_bits = explode('.', $hostname);
39 $chunk_counter = sizeof ($hostname_bits);
40 $compare_chunk = $hostname ;
43 /* look for the host specific overrides */
44 $file_name = $config_directory . "host/". $file_prefix . $compare_chunk ;
45 if (is_file($file_name)) {
50 /* look for the domain specific overrides */
51 while ($chunk_counter > 0) {
52 $file_name = $config_directory . $file_prefix . $compare_chunk ;
53 if (is_file($file_name)) {
58 array_shift($hostname_bits);
59 $compare_chunk = implode('.',$hostname_bits);
64 if ($found_file and is_readable($file_name)) {
65 $lines=file($file_name);
68 $file_name = $config_directory . $file_prefix . $default_name ;
69 $lines=file($file_name);
72 foreach ($lines as $line_num => $line) {
74 $elements=explode(' ',$line);
75 if ($elements[0] == "server") {
76 print ("$elements[1]\n");