aboutsummaryrefslogtreecommitdiff
blob: e2284b4be9c7550e24966f8af197552c579646ef (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
<?php

    // Gentoaster build daemon client
    // Licensed under GPL v3, see COPYING file

    require_once "config.php";

    if (!isset($argv[1])) {
        die("No config file provided\n");
    }

    $client= new GearmanClient();
    $client->addServer();

    echo "Sending job\n";

    $iniString = file_get_contents($argv[1]);

    $handle = $client->doBackground("invoke_image_build", $iniString);
    $handlehash = md5($handle);

    echo "Job sent, handle was ".$handle." - hash ".$handlehash."\n";

    $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
    if (!$db) {
        die("Could not connect to database ".mysql_error());
    }
    mysql_select_db(MYSQL_DATABASE);
    $query = "INSERT INTO builds (id, handle)".
            ." VALUES('".$handlehash."','".$handle."')";
    mysql_query($query);
    echo "Job handle mapping added to database\n";