forked from librenms/librenms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-base.php
41 lines (33 loc) · 920 Bytes
/
build-base.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
<?php
// MYSQL Check - FIXME
// 1 UNKNOWN
require 'config.php';
if (!isset($sql_file)) {
$sql_file = 'build.sql';
}
$sql_fh = fopen($sql_file, 'r');
if ($sql_fh === false) {
echo 'ERROR: Cannot open SQL build script '.$sql_file."\n";
exit(1);
}
$connection = mysql_connect($config['db_host'], $config['db_user'], $config['db_pass']);
if ($connection === false) {
echo 'ERROR: Cannot connect to database: '.mysql_error()."\n";
exit(1);
}
$select = mysql_select_db($config['db_name']);
if ($select === false) {
echo 'ERROR: Cannot select database: '.mysql_error()."\n";
exit(1);
}
while (!feof($sql_fh)) {
$line = fgetss($sql_fh);
if (!empty($line)) {
$creation = mysql_query($line);
if (!$creation) {
echo 'WARNING: Cannot execute query ('.$line.'): '.mysql_error()."\n";
}
}
}
fclose($sql_fh);
require 'includes/sql-schema/update.php';