propagate PLC_MONITOR_HOST to the node
[nodeconfig.git] / PlanetLabConf / get_plc_config.php
1 <?php
2 //
3 // Print a subset of the variables from the PLC configuration store in
4 // various formats (Perl, Python, PHP, sh)
5 //
6 // Mark Huang <mlhuang@cs.princeton.edu>
7 // Copyright (C) 2006 The Trustees of Princeton University
8 //
9 // $Id$
10 //
11
12 // Try the new plc_config.php file first
13 include 'plc_config.php';
14
15 if (isset($_REQUEST['perl'])) {
16   $shebang = '#!/usr/bin/perl';
17   $format = "our $%s=%s;\n";
18   $end = '';
19 } elseif (isset($_REQUEST['python'])) {
20   $shebang = '#!/usr/bin/python';
21   $format = "%s=%s\n";
22   $end = '';
23 } elseif (isset($_REQUEST['php'])) {
24   $shebang = '<?php';
25   $format = "define('%s', %s);\n";
26   $end = '?>';
27 } else {
28   $shebang = '#!/bin/sh';
29   $format = "%s=%s\n";
30   $end = '';
31 }
32
33 echo $shebang . "\n";
34
35 foreach (array('PLC_API_HOST', 'PLC_API_PATH', 'PLC_API_PORT',
36                'PLC_WWW_HOST', 'PLC_BOOT_HOST', 'PLC_PLANETFLOW_HOST',
37                'PLC_NAME', 'PLC_SLICE_PREFIX', 'PLC_MONITOR_HOST',
38                'PLC_MAIL_SUPPORT_ADDRESS',
39                'PLC_MAIL_MOM_LIST_ADDRESS',
40                'PLC_MAIL_SLICE_ADDRESS')
41          as $name) {
42   if (defined($name)) {
43     // Perl, PHP, Python, and sh all support strong single quoting
44     $value = "'" . str_replace("'", "\\'", constant($name)) . "'";
45     printf($format, $name, $value);
46   }
47 }
48
49 printf($format, 'PLC_API_CA_SSL_CRT', "'/usr/boot/cacert.pem'");
50 printf($format, 'PLC_ROOT_GPG_KEY_PUB', "'/usr/boot/pubring.gpg'");
51
52 echo $end . "\n";
53
54 ?>