-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.php
59 lines (45 loc) · 1.88 KB
/
install.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
<?php
$root_password = $argv[1];
$root = "root";
//Download composer
$source = "https://getcomposer.org/download/1.0.0-alpha9/composer.phar";
$dest = "composer.phar";
echo "Downloading composer.phar from ".$source."\r";
copy($source, $dest);
//Install dependencies
passthru("php composer.phar install");
$ini_array = parse_ini_file("src/MyApp/iLab/public/config.php");
ini_set('display_errors',1);
error_reporting(-1);
$host = $ini_array['host'];
$db = $ini_array['database'];
$user = $ini_array['user'];
$pass = $ini_array['password'];
echo "Creating database.. \r";
$dbConn = new PDO('mysql:host='.$host, $root, $root_password);
//$query = file_get_contents("translator.sql");
$query = "CREATE DATABASE IF NOT EXISTS `$db` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `$db`;
CREATE TABLE IF NOT EXISTS `reservations` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(100) NOT NULL,
`couponId` varchar(45) NOT NULL,
`passkey` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`labserverId` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`duration` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`reservation_key` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`reservation_start` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) )
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE USER '$user'@'localhost' IDENTIFIED BY '$pass';
GRANT ALL ON `$db`.* TO '$user'@'localhost';
FLUSH PRIVILEGES;";
try{
$result = $dbConn->exec($query);
if ($result == true){
echo "Database created \r \r";
}
}
catch (PDOException $e) {
die("DB ERROR: ". $e->getMessage());
}