-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.php
58 lines (52 loc) · 1.13 KB
/
build.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
if (trim(shell_exec("whoami")) !== "root") {
print "You need to run this script as root!\n";
exit(1);
}
$descriptorspec = [
0 => ["pipe", "w"], // STDIN
1 => ["file", "php://stdout", "w"], // STDOUT
2 => ["file", "php://stderr", "w"] // STDERR
];
$sh = function () {
$a = [
"/usr/lib/libphpcpp.a.2.1.1",
"/usr/lib/libphpcpp.a",
"/usr/lib/libphpcpp.so",
"/usr/lib/libphpcpp.so.2.1.1",
"/usr/lib/libphpcpp.so.2.1",
"/usr/include/phpcpp",
"/usr/include/phpcpp.h"
];
$c = true;
foreach ($a as $v) {
$c = $c && file_exists($v);
if (!$c) {
return true;
}
}
return false;
};
$commands = [
[
(!file_exists("/tmp/phpcpp")),
"wget https://api.github.com/repos/CopernicaMarketingSoftware/PHP-CPP/tarball/v2.1.2 -O /tmp/phpcpp"
],
[
($sh()),
"cd /tmp && sudo tar -xf phpcpp && cd *PHP* && make -j 5 && make install -j 5"
],
[
true,
"nice bash -c ".escapeshellarg("cd ".__DIR__."/ && make -j2 && make install")
]
];
foreach($commands as $command) {
if ($command[0]) {
$proc = proc_open($command[1], $descriptorspec, $pipes);
fclose($pipes[0]);
proc_close($proc);
}
}
print "OK!\n";
exit(0);