3 // /etc/ntp/step-tickers generator
5 // Marc Fiuczynski <mef@cs.princeton.edu>
6 // Copyright (C) 2006 The Trustees of Princeton University
9 // Get admin API handle
10 require_once 'plc_api.php';
13 $config_directory= "/var/www/html/PlanetLabConf/ntp/";
14 $file_prefix= "ntp.conf.";
15 $default_name = "default";
16 $file_name = $config_directory . $file_prefix . $default_name;
19 $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
20 if (!empty($interfaces)) {
21 $nodes = $adm->GetNodes(array($interfaces[0]['node_id']));
32 $hostname= trim($node['hostname']);
34 /* Look for config file */
36 $hostname_bits = explode('.', $hostname);
37 $chunk_counter = sizeof ($hostname_bits);
38 $compare_chunk = $hostname ;
41 /* look for the host specific overrides */
42 $file_name = $config_directory . "host/". $file_prefix . $compare_chunk ;
43 if (is_file($file_name)) {
48 /* look for the domain specific overrides */
49 while ($chunk_counter > 0) {
50 $file_name = $config_directory . $file_prefix . $compare_chunk ;
51 if (is_file($file_name)) {
56 array_shift($hostname_bits);
57 $compare_chunk = implode('.',$hostname_bits);
62 if ($found_file and is_readable($file_name)) {
63 $lines=file($file_name);
66 $file_name = $config_directory . $file_prefix . $default_name ;
67 $lines=file($file_name);
70 foreach ($lines as $line_num => $line) {
72 $elements=explode(' ',$line);
73 if ($elements[0] == "server") {
74 print ("$elements[1]\n");