-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcheck.php
More file actions
240 lines (204 loc) · 6.13 KB
/
check.php
File metadata and controls
240 lines (204 loc) · 6.13 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?php
function check_error($level = 255) {
?>
<p>
There is something off with your setup.
Please post these results
</p>
<?php
exit($level);
}
// --- data dir ----------------------------------
$data_dir = __DIR__ . "/../data";
echo "[info] data_dir is {$data_dir}<br>\n";
$username_output = [];
exec('whoami', $username_output);
$user = $username_output[0];
echo "[info] username running the web server is {$user}<br>\n";
if (file_exists($data_dir) === false) {
if (mkdir($data_dir, 0777) === false) {
echo "[error] cannot create data dir {$data_dir}<br>\n";
exit(1);
}
} else {
if (is_dir($data_dir) === false) {
echo "[error] data dir exists but is not a directory<br>\n";
exit(2);
}
}
if (is_writable($data_dir)) {
echo "[good] {$data_dir} is writable by user {$user}<br>\n";
} else {
echo "[error] {$data_dir} is not writable by user {$user}<br>\n";
exit(3);
}
// --- bin dir ----------------
$bin_dir = __DIR__ . "/../bin";
echo "[info] bin_dir is {$bin_dir}<br>\n";
if (file_exists($bin_dir) && is_dir($bin_dir)) {
echo "[good] {$bin_dir} exists<br>\n";
} else {
echo "[error] {$bin_dir} does not exist<br>\n";
exit(4);
}
// --- logging ----------------------------------
include(__DIR__ . "/common.php");
$username = "root";
$err = suncae_log("running check.php script");
if ($err == 0) {
echo "[good] logging works<br>\n";
} else {
echo "[error] cannot create a log entry<br>\n";
exit(5);
}
// conf
include(__DIR__ . "/../conf.php");
// --- auth ----------------------------------
if (file_exists(__DIR__ . "/../auths/{$auth}/auth.php")) {
echo "[good] auth {$auth} exists<br>\n";
} else {
echo "[error] auth {$auth} does not exist<br>\n";
exit(6);
}
// --- ux ----------------------------------
if (file_exists(__DIR__ . "/../uxs/{$ux}/index.php")) {
echo "[good] ux {$ux} exists<br>\n";
} else {
echo "[error] ux {$ux} does not exist<br>\n";
exit(7);
}
if ($ux == "faster-than-quick") {
foreach (['css/bootstrap.min.css', 'css/katex.min.css', 'css/x3dom.css'] as $i) {
if (file_exists(__DIR__ . "/../uxs/{$ux}/{$i}")) {
echo "[good] {$i} exists<br>\n";
} else {
echo "[error] {$i} does not exist<br>\n";
exit(8);
}
}
// pandoc
if (file_exists("{$bin_dir}/pandoc")) {
echo "[good] pandoc binary exists<br>\n";
echo "[info] " . shell_exec("ls -la {$bin_dir}/pandoc") . "<br>\n";
} else {
echo "[error] pandoc binary does not exist<br>\n";
exit(9);
}
$exec_output = [];
exec("{$bin_dir}/pandoc --version 2>&1", $exec_output, $err);
// TODO: check version is good enough
if ($err == 0) {
echo "[good] pandoc version is {$exec_output[0]}<br>\n";
} else {
echo "[error] pandoc binary does not work<br>\n";
for ($i = 0; $i < count($exec_output); $i++) {
echo "[info] {$exec_output[$i]}<br>\n";
}
exit(10);
}
}
// --- cadimporter ----------------------------------
if (file_exists(__DIR__ . "/../cadimporters/{$cadimporter}/import_cad.php")) {
echo "[good] cadimporter {$cadimporter} exists<br>\n";
} else {
echo "[error] cadimporters {$cadimporter} does not exist<br>\n";
exit(11);
}
// --- cadprocessor ----------------------------------
if (file_exists(__DIR__ . "/../cadprocessors/{$cadprocessor}/process.php")) {
echo "[good] cadprocessor {$cadprocessor} exists<br>\n";
} else {
echo "[error] cadprocessor {$cadprocessor} does not exist<br>\n";
exit(12);
}
if ($cadprocessor == "gmsh") {
foreach (['css/bootstrap.min.css', 'css/katex.min.css', 'css/x3dom.css'] as $i) {
if (file_exists(__DIR__ . "/../uxs/{$ux}/{$i}")) {
echo "[good] {$i} exists<br>\n";
} else {
echo "[error] {$i} does not exist<br>\n";
exit(13);
}
}
// gmsh
if (file_exists("{$bin_dir}/gmsh")) {
echo "[good] gmsh binary exists<br>\n";
echo "[info] " . shell_exec("ls -la {$bin_dir}/gmsh") . "<br>\n";
} else {
echo "[error] gmsh binary does not exist<br>\n";
exit(14);
}
$exec_output = [];
exec("{$bin_dir}/gmsh -version 2>&1", $exec_output, $err);
// TODO: check version is good enough
if ($err == 0) {
echo "[good] gmsh version is {$exec_output[0]}<br>\n";
} else {
echo "[error] gmsh binary does not work<br>\n";
for ($i = 0; $i < count($exec_output); $i++) {
echo "[info] {$exec_output[$i]}<br>\n";
}
exit(15);
}
// python
$exec_output = [];
exec("which python", $exec_output, $err);
if ($err == 0) {
echo "[good] python binary exists at {$exec_output[0]}<br>\n";
} else {
echo "[error] python binary does not exist<br>\n";
exit(16);
}
$exec_output = [];
exec("python --version 2>&1", $exec_output, $err);
// TODO: check version is good enough
if ($err == 0) {
echo "[good] python version is {$exec_output[0]}<br>\n";
} else {
echo "[error] python binary does not work<br>\n";
for ($i = 0; $i < count($exec_output); $i++) {
echo "[info] {$exec_output[$i]}<br>\n";
}
exit(17);
}
// gmsh python wrapper
$exec_output = [];
exec("python " . __DIR__ . "/../cadprocessors/gmsh/gmshcheck.py 2>&1", $exec_output, $err);
// TODO: check version is good enough
if ($err == 0) {
echo "[good] python gmsh wrapper version is {$exec_output[0]}<br>\n";
} else {
echo "[error] python gmsh wrapper does not work<br>\n";
for ($i = 0; $i < count($exec_output); $i++) {
echo "[info] {$exec_output[$i]}<br>\n";
}
exit(18);
}
// TODO: check python and binary versions match
}
// feenox
if (file_exists("{$bin_dir}/feenox")) {
echo "[good] feenox binary exists<br>\n";
echo "[info] " . shell_exec("ls -la {$bin_dir}/feenox") . "<br>\n";
} else {
echo "[error] feenox binary does not exist<br>\n";
exit(19);
}
$exec_output = [];
exec("{$bin_dir}/feenox --version 2>&1", $exec_output, $err);
// TODO: check version is good enough
if ($err == 0) {
echo "[good] feenox version is {$exec_output[0]}<br>\n";
} else {
echo "[error] feenox binary does not work<br>\n";
for ($i = 0; $i < count($exec_output); $i++) {
echo "[info] {$exec_output[$i]}<br>\n";
}
exit(20);
}
// great!
touch("{$data_dir}/check-ok");
?>
<p>
[good] all set! <a href="<?=$_SERVER['HTTP_REFERER']?>">Proceed to SunCAE</a>
</p>