scaffolding multi-fcdistro yum config
Thierry Parmentelat [Thu, 1 Apr 2010 14:51:04 +0000 (14:51 +0000)]
bootstrapfs.spec
db-config.d/030-conf_files_node_update
nodeconfig/yum/stock.repo.php [new file with mode: 0644]

index b7f4611..44ae655 100644 (file)
@@ -113,12 +113,16 @@ popd
 # and let the php scripts do the right thing
 pushd BootstrapFS
 echo "* Installing MyPLC-side nodes yum config utilities"
-# expose (fixed) myplc.repo.php as                                         https://<plc>/yum/myplc.repo.php
-install -D -m 644 ./nodeconfig/yum/myplc.repo.php                          $RPM_BUILD_ROOT/var/www/html/yum/myplc.repo.php
-# expose the fcdistro-dependant yum.conf as                                https://<plc>/yum/yum.conf
-install -D -m 644 ./nodeconfig/yum/%{distroname}/yum.conf                  $RPM_BUILD_ROOT/var/www/html/yum/yum.conf
-# expose the (fcdistro-dependant) stock.repo as                                    https://<plc>/yum/stock.repo
-install -D -m 644 ./nodeconfig/yum/%{distroname}/yum.myplc.d/stock.repo            $RPM_BUILD_ROOT/var/www/html/yum/stock.repo
+echo "* Multi-fcdistro yum stuff"
+mkdir -p $RPM_BUILD_ROOT/var/www/html/yum/
+rsync -av ./nodeconfig/yum/                                                $RPM_BUILD_ROOT/var/www/html/yum/
+echo "* Legacy (single fcdistro) yum stuff"
+# expose (fixed) myplc.repo.php as                                         https://<plc>/yum.legacy/myplc.repo.php
+install -D -m 644 ./nodeconfig/yum/myplc.repo.php                          $RPM_BUILD_ROOT/var/www/html/yum.legacy/myplc.repo.php
+# expose the fcdistro-dependant yum.conf as                                https://<plc>/yum.legacy/yum.conf
+install -D -m 644 ./nodeconfig/yum/%{distroname}/yum.conf                  $RPM_BUILD_ROOT/var/www/html/yum.legacy/yum.conf
+# expose the (fcdistro-dependant) stock.repo as                                    https://<plc>/yum.legacy/stock.repo
+install -D -m 644 ./nodeconfig/yum/%{distroname}/yum.myplc.d/stock.repo            $RPM_BUILD_ROOT/var/www/html/yum.legacy/stock.repo
 
 # Install initscripts
 echo "* Installing plc.d initscripts"
index d3d9434..fc3c5a6 100644 (file)
@@ -8,21 +8,21 @@ conf_files = [
 # myplc/noderepo
     # YUM configuration
     {'enabled': True,
-     'source': 'yum/myplc.repo.php?gpgcheck=1',
+     'source': 'yum.legacy/myplc.repo.php?gpgcheck=1',
      'dest': '/etc/yum.myplc.d/myplc.repo',
      'file_permissions': '644', 'file_owner': 'root', 'file_group': 'root',
      'preinstall_cmd': '', 'postinstall_cmd': '', 'error_cmd': '',
      'ignore_cmd_errors': False,
      'always_update': False},
     {'enabled': True,
-     'source': 'yum/yum.conf',
+     'source': 'yum.legacy/yum.conf',
      'dest': '/etc/yum.conf',
      'file_permissions': '644', 'file_owner': 'root', 'file_group': 'root',
      'preinstall_cmd': '', 'postinstall_cmd': '', 'error_cmd': '',
      'ignore_cmd_errors': False,
      'always_update': False},
     {'enabled': True,
-     'source': 'yum/stock.repo',
+     'source': 'yum.legacy/stock.repo',
      'dest': '/etc/yum.myplc.d/stock.repo',
      'file_permissions': '644', 'file_owner': 'root', 'file_group': 'root',
      'preinstall_cmd': '', 'postinstall_cmd': '', 'error_cmd': '',
diff --git a/nodeconfig/yum/stock.repo.php b/nodeconfig/yum/stock.repo.php
new file mode 100644 (file)
index 0000000..fa73cad
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+//
+// part of yum config on nodes
+//
+// Thierry Parmentelat 
+// Copyright (C) 2008 INRIA
+//
+// $Id$
+// $URL$
+//
+
+// For PLC_NAME and PLC_BOOT_HOST
+include('plc_config.php');
+
+$PLC_NAME = PLC_NAME;
+$PLC_BOOT_HOST = PLC_BOOT_HOST;
+
+// Get admin API handle
+require_once 'plc_api.php';
+global $adm;
+
+if (isset($_REQUEST['gpgcheck'])) {
+  $gpgcheck = $_REQUEST['gpgcheck'];
+} else {
+  $gpgcheck = 0;
+}
+
+echo "# Generated by stock.repo.php\n";
+echo '# $Id$' . "\n";
+echo '# $URL$' . "\n";
+# we assume the node is not so old that it would not send node_id
+# get node family
+if ( ! isset($_REQUEST['node_id'])) {
+  echo "# node_id is needed\n";
+  echo "# looks like you're running a very old NodeManager...\n";
+  echo "# bailing out..\n";
+  exit;
+ }
+
+$node_id = intval($_REQUEST['node_id']);
+$nodeflavour=$adm->GetNodeFlavour($node_id);
+$nodefcdistro=$nodeflavour['fcdistro'];
+
+# try to open /var/www/html/yum/<fcdistro>/yum.myplc.d/stock.repo
+# otherwise use the static version in 
+# /var/www/html/yum.legacy/stock.repo
+$fc_name="/var/www/html/yum/" . $fcdistro . "/yum.myplc.d/stock.repo";
+$fb_name="/var/www/html/yum.legacy/stock.repo";
+
+$fc_contents=file_get_contents($fc_name);
+if ($fc_contents) {
+  echo "# retrieved " . $fc_name . "\n";
+  print $fc_contents;
+  exit;
+ }
+$fb_contents=file_get_contents($fb_name);
+if ($fb_contents) {
+  echo "# retrieved fallback (fcdistro " . $fcdistro " unknown) " . $fb_name . "\n";
+  print $fb_contents;
+  exit;
+ }
+echo "# Could not find any of the following\n";
+echo "# " . $fc_name . "\n";
+echo "# " . $fb_name . "\n";
+echo "# bailing out";
+
+
+
+