creation
[nodeconfig.git] / PlanetLabConf / ntptickers.php
1 <?php
2
3 require_once('setup_plconf.php');
4
5 /* Look for config file */
6
7 $config_directory= "/var/www/html/PlanetLabConf/ntp/";
8 $file_prefix= "ntp.conf.";
9 $hostname_bits = explode('.', $hostname);
10 $chunk_counter = sizeof ($hostname_bits);
11 $compare_chunk = $hostname ;
12 $found_file = 0;
13 $default_name = "default";
14
15 /* look for the host specific overrides */
16 $file_name = $config_directory . "host/". $file_prefix . $compare_chunk ;
17 if (is_file($file_name)) {
18         $chunk_counter = 0;
19         $found_file = 1;
20 }
21
22 /* look for the domain specific overrides */
23 while ($chunk_counter > 0) {
24         $file_name = $config_directory . $file_prefix . $compare_chunk ;
25         if (is_file($file_name)) {
26                 $chunk_counter = 0;
27                 $found_file = 1;
28         }
29         else {
30                 array_shift($hostname_bits);
31                 $compare_chunk = implode('.',$hostname_bits);
32                 $chunk_counter--;
33         }
34 }
35
36 if ($found_file and is_readable($file_name)) {
37         $lines=file($file_name);
38
39 else {
40         $file_name = $config_directory . $file_prefix . $default_name ;
41         $lines=file($file_name);
42
43
44 foreach ($lines as $line_num => $line) {
45         $line=rtrim($line);
46         $elements=explode(' ',$line);
47         if ($elements[0] == "server") {
48                 print ("$elements[1]\n");
49         }
50 }
51
52 ?>
53