c15ea7891bac280eeffd970b00f5f984e1291403
[nodeconfig.git] / PlanetLabConf / yum.conf.php
1 <?php
2 //
3 // /etc/yum.conf for production nodes
4 //
5 // Mark Huang <mlhuang@cs.princeton.edu>
6 // Copyright (C) 2004-2006 The Trustees of Princeton University
7 //
8 // $Id$
9 //
10
11 // For PLC_NAME and PLC_BOOT_HOST
12 include('plc_config.php');
13
14 $PLC_NAME = PLC_NAME;
15 $PLC_BOOT_HOST = PLC_BOOT_HOST;
16
17 ////////////////////////////// mirror list
18
19 // Requesting a mirror list. Yum bombs out completely if a repository
20 // is (even temporarily) unavailable, so if CoBlitz is down, provide a
21 // few more options. Make sure that gpgcheck remains enabled.  Last
22 // chance option is ourselves so that yum never fails.
23 if (isset($_REQUEST['mirrorlist']) &&
24     isset($_REQUEST['repo']) &&
25     isset($_REQUEST['releasever'])) {
26   $mirrors = array("http://coblitz.codeen.org/coblitz.planet-lab.org/pub/fedora/linux",
27                    "http://fedora.gtlib.cc.gatech.edu/pub/fedora.redhat/linux",
28                    "http://download.fedoraproject.org/pub/fedora/linux",
29                    "http://mirrors.kernel.org/fedora");
30                    #"ftp://rpmfind.net/linux/fedora",  still uses the old style of directory hierarchy
31   $releasever = $_REQUEST['releasever'];
32   switch ($_REQUEST['repo']) {
33   case "base":
34         if ( intval($releasever) >= 7 )
35         {
36                 foreach ($mirrors as $mirror) {
37                   echo "$mirror/releases/$releasever/Everything/\$ARCH/os/\n";
38                 }
39
40         } else {
41                 foreach ($mirrors as $mirror) {
42                   echo "$mirror/core/$releasever/\$ARCH/os/\n";
43                 }
44         }
45     break;
46   case "updates":
47         if ( intval($releasever) >= 7 )
48         {
49                 foreach ($mirrors as $mirror) {
50                   echo "$mirror/updates/$releasever/\$ARCH/\n";
51                 }
52
53         } else {
54                 foreach ($mirrors as $mirror) {
55                   echo "$mirror/core/updates/$releasever/\$ARCH/\n";
56                 }
57         }
58     break;
59   }
60
61   // Always list ourselves last
62   echo "https://$PLC_BOOT_HOST/install-rpms/planetlab/\n";
63   exit;
64 }
65
66 ////////////////////////////// plain yum.conf 
67
68 // Get admin API handle
69 require_once 'plc_api.php';
70 global $adm;
71
72 // Requesting yum.conf. See above for the mirrorlist definition.
73
74 #$oldrepos = array(array('FedoraCore2Base', 'Fedora Core 2 Base', 'stock-fc2'),
75 #              array('FedoraCore2Updates', 'Fedora Core 2 Updates', 'updates-fc2'),
76 #              array('ThirdParty', 'Third Party RPMS', '3rdparty'));
77
78 $repos = array(array('ThirdParty', 'Third Party RPMS', '3rdparty'));
79
80
81 if (isset($_REQUEST['alpha'])) {
82   $repos[] = array('PlanetLabAlpha', 'PlanetLab Alpha RPMS', 'planetlab-alpha');
83 } elseif (isset($_REQUEST['beta'])) {
84   $repos[] = array('PlanetLabBeta', 'PlanetLab Beta RPMS', 'planetlab-beta');
85 } elseif (isset($_REQUEST['rollout'])) {
86   $repos[] = array('PlanetLab', 'PlanetLab RPMS', 'planetlab-rollout');
87 } else {
88   $repos[] = array('PlanetLab', 'PlanetLab RPMS', 'planetlab');
89 }
90
91 if (isset($_REQUEST['gpgcheck'])) {
92   $gpgcheck = $_REQUEST['gpgcheck'];
93 } else {
94   $gpgcheck = 0;
95 }
96
97
98 echo <<<EOF
99 [main]
100 # Do not scan /etc/yum.repos.d/
101 reposdir=/dev/null
102 cachedir=/var/cache/yum
103 debuglevel=2
104 logfile=/var/log/yum.log
105 pkgpolicy=newest
106 gpgcheck=$gpgcheck
107
108 [base]
109 name=Fedora Core \$releasever - \$basearch - Base
110 mirrorlist=https://$PLC_BOOT_HOST/PlanetLabConf/yum.conf.php?mirrorlist&repo=base&releasever=\$releasever
111 gpgcheck=$gpgcheck
112 # PlanetLab builds its own versions of these tools
113 exclude=iptables kernel kernel kernel-devel kernel-smp kernel-smp-devel kernel-xen0 kernel-xen0-devel kernel-xenU kernel-xenU-devel mysql ulogd
114
115 [updates]
116 name=Fedora Core \$releasever - \$basearch - Released Updates
117 mirrorlist=https://$PLC_BOOT_HOST/PlanetLabConf/yum.conf.php?mirrorlist&repo=updates&releasever=\$releasever
118 gpgcheck=$gpgcheck
119 # PlanetLab builds its own versions of these tools
120 exclude=iptables kernel kernel kernel-devel kernel-smp kernel-smp-devel kernel-xen0 kernel-xen0-devel kernel-xenU kernel-xenU-devel mysql ulogd
121
122 EOF;
123
124 // Figure out which repositories we actually have on this
125 // machine. MyPLC installations, for instance, generally only have
126 // PlanetLab RPMS installed.
127 foreach ($repos as $repo) {
128   $id = $repo[0];
129   $name = $repo[1] . " -- " . "$PLC_NAME Central";
130   $dir = "/install-rpms/" . $repo[2];
131   $baseurl = "https://$PLC_BOOT_HOST" . $dir . "/";
132
133   if (is_dir(realpath($_SERVER['DOCUMENT_ROOT'] . $dir))) {
134     echo <<<EOF
135 [$id]
136 name=$name
137 baseurl=$baseurl
138 gpgcheck=$gpgcheck
139
140
141 EOF;
142   }
143 }
144
145 if (isset($_REQUEST['node_id'])) {
146   $node_id=intval($_REQUEST['node_id']);
147   echo "# node_id = " . $node_id . "\n";
148   # compute nodegroups
149   $nodes = $adm->GetNodes(array('node_id'=>$node_id));
150   $nodegroup_ids = $nodes[0]['nodegroup_ids'];
151   $nodegroups = $adm->GetNodeGroups($nodegroup_ids);
152   foreach ($nodegroups as $nodegroup) {
153     echo "# in nodegroup " . $nodegroup['name'] . "\n" ;
154   }
155  }
156
157 ?>