needed to resurrect that one
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 14 Jan 2010 15:39:14 +0000 (15:39 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 14 Jan 2010 15:39:14 +0000 (15:39 +0000)
bootmanager.spec
nodeconfig/boot/getnodeid.php [new file with mode: 0755]

index 65575f8..58efc5d 100644 (file)
@@ -59,6 +59,7 @@ install -m 644 README  $RPM_BUILD_ROOT/%{_datadir}/%{name}/README
 # formerly in the nodeconfig module
 install -D -m 755 nodeconfig/boot/index.php $RPM_BUILD_ROOT/var/www/html/boot/index.php
 install -D -m 755 nodeconfig/boot/upload-bmlog.php $RPM_BUILD_ROOT/var/www/html/boot/upload-bmlog.php
+install -D -m 755 nodeconfig/boot/getnodeid.php $RPM_BUILD_ROOT/var/www/html/boot/getnodeid.php
 
 # formerly in the MyPLC module
 install -D -m 755 plc.d/bootmanager $RPM_BUILD_ROOT/etc/plc.d/bootmanager
@@ -80,6 +81,7 @@ chkconfig --del monitor-runlevelagent
 %{_datadir}/%{name}
 /var/www/html/boot/index.php
 /var/www/html/boot/upload-bmlog.php
+/var/www/html/boot/getnodeid.php
 /etc/plc.d/bootmanager
 
 %changelog
diff --git a/nodeconfig/boot/getnodeid.php b/nodeconfig/boot/getnodeid.php
new file mode 100755 (executable)
index 0000000..d097b35
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+//
+// Returns node ID of requestor
+//
+// Mark Huang <mlhuang@cs.princeton.edu>
+// Copyright (C) 2006 The Trustees of Princeton University
+//
+// $Id: getnodeid.php 9469 2008-05-26 14:13:19Z thierry $ $
+//
+
+// Get admin API handle
+require_once 'plc_api.php';
+global $adm;
+
+if (!empty($_REQUEST['mac_addr'])) {
+  $mac_lower = strtolower(trim($_REQUEST['mac_addr']));
+  $mac_upper = strtoupper(trim($_REQUEST['mac_addr']));
+  $interfaces = $adm->GetInterfaces(array('mac' => array($mac_lower, $mac_upper)));
+} else {
+  $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
+}
+
+if (!empty($interfaces)) {
+  print $interfaces[0]['node_id'];
+} else {
+  print "-1";
+}
+
+?>