1diff --git a/tools/cli/main.js b/tools/cli/main.js
2index 84f94bc..4fbda17 100644
3--- a/tools/cli/main.js
4+++ b/tools/cli/main.js
5@@ -484,6 +484,45 @@ var springboard = function (rel, options) {
6 process.exit(ret.wait());
7 }
8
9+ // BEGIN HACK
10+ // patch shebang:
11+ var fs = require('fs');
12+ var path = require("path")
13+ var Future = require("fibers/future")
14+ var srcOld = fs.readFileSync(executable, 'utf8');
15+ srcNew = srcOld.replace(/^#!\/bin\/bash/, '#!/bin/sh');
16+ if (srcOld !== srcNew) {
17+ fs.writeFileSync(executable, srcNew, 'utf8');
18+ }
19+ // patch elfs:
20+ var dir = path.dirname(executable);
21+ var interpreter = "@INTERPRETER@";
22+ var rpath = "@RPATH@";
23+ function spawnSync(/*...*/) {
24+ var args = Array.prototype.slice.call(arguments);
25+ var proc = require("child_process").spawn.apply(null, args);
26+ var future = new Future();
27+ proc.on('close', function (code) {
28+ future.return();
29+ });
30+ return future.wait();
31+ }
32+ function patchelf(/*...*/) {
33+ var pathParts = Array.prototype.slice.call(arguments);
34+ var p = path.join.apply(null, [dir, "dev_bundle"].concat(pathParts));
35+ spawnSync('@PATCHELF@', [
36+ "--set-interpreter",
37+ interpreter,
38+ "--set-rpath",
39+ rpath,
40+ p
41+ ], {stdio: 'inherit'});
42+ }
43+ patchelf("bin", "node");
44+ patchelf("mongodb", "bin", "mongo");
45+ patchelf("mongodb", "bin", "mongod");
46+ // END HACK
47+
48 // Now exec; we're not coming back.
49 require('kexec')(executable, newArgv);
50 throw Error('exec failed?');