aboutsummaryrefslogtreecommitdiff
blob: 1b68d030dd5f219251d4ca811d5ca75d8d829e71 (plain)
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
<?php

	$build_id = uniqid();
	$boot_megabytes = intval($_POST["boot_size"]);
	$swap_megabytes = intval($_POST["swap_size"]);
	$root_megabytes = intval($_POST["root_size"]);
	$timezone = escapeshellarg($_POST["timezone"]);
	$hostname = escapeshellarg($_POST["hostname"]);
	$username =  escapeshellarg($_POST["username"]);
	$password = escapeshellarg($_POST["password"]);
	$root_password = escapeshellarg($_POST["rootpassword"]);
	$packages_list = escapeshellarg($_POST["packages"]);
	$output_format = escapeshellarg($_POST["format"]);

	$packages_list = str_replace("\r\n", " ", $packages_list);
	$packages_list = str_replace("\n", " ", $packages_list);

$ini_string = "[vmconfig]

BUILD_ID='$build_id'
BOOT_MEGABYTES='$boot_megabytes'
SWAP_MEGABYTES='$swap_megabytes'
ROOT_MEGABYTES='$root_megabytes'
TIMEZONE=$timezone
HOSTNAME=$hostname
ROOT_PASSWORD=$root_password
DEFAULT_USERNAME=$username
DEFAULT_PASSWORD=$password
USE_FLAGS=''
PACKAGE_USE=''
FEATURES='parallel-fetch userfetch userpriv getbinpkg'
PACKAGE_ACCEPT_KEYWORDS=''
PACKAGES_LIST=$packages_list
OUTPUT_FORMAT=$output_format";

	$client = new GearmanClient();
	$client->addServer();
	$handle = $client->doBackground("invoke_image_build", $ini_string);

	$db = mysql_connect("localhost","gentoaster","");
	if(!$db) die("Could not connect to database ".mysql_error());
	mysql_select_db("gentoaster");
	mysql_query("INSERT INTO builds (id, handle) VALUES('".$build_id."','".$handle."')");

	header("Location: finished.php?uuid=".$build_id);
?>