2002-04-30 22:22:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
define("VERSION", "1");
|
2002-05-24 04:29:10 +00:00
|
|
|
define("CORE_CLIENT", "boinc_".VERSION."_$BOINC_PLATFORM");
|
2002-05-17 22:33:57 +00:00
|
|
|
define("PROJECTS", "localhost.localdomain zoot");
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
function clear_db() {
|
|
|
|
PassThru("cd ../db; init_db");
|
|
|
|
}
|
|
|
|
|
2002-05-24 04:29:10 +00:00
|
|
|
$BOINC_DOWNLOAD_DIR = null;
|
|
|
|
$BOINC_UPLOAD_DIR = null;
|
|
|
|
$BOINC_PLATFORM = null;
|
|
|
|
$BOINC_EMAIL = null;
|
2002-08-14 20:31:27 +00:00
|
|
|
$BOINC_DOWNLOAD_URL = null;
|
2002-07-05 05:33:40 +00:00
|
|
|
$BOINC_KEY_DIR = null;
|
2002-07-15 07:19:44 +00:00
|
|
|
$BOINC_MASTER_URL = null;
|
2002-08-26 22:57:17 +00:00
|
|
|
$BOINC_DB_NAME = null;
|
|
|
|
|
|
|
|
function open_db() {
|
|
|
|
global $BOINC_DB_NAME;
|
|
|
|
|
|
|
|
$retval = mysql_connect();
|
|
|
|
if (!$retval) {
|
|
|
|
echo "mysql_connect() failed\n";
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
$retval = mysql_select_db($BOINC_DB_NAME);
|
|
|
|
if (!$retval) {
|
|
|
|
echo "mysql_select_db() failed\n";
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
}
|
2002-05-24 04:29:10 +00:00
|
|
|
|
|
|
|
function check_env_vars() {
|
|
|
|
global $BOINC_DOWNLOAD_DIR;
|
|
|
|
global $BOINC_UPLOAD_DIR;
|
|
|
|
global $BOINC_PLATFORM;
|
|
|
|
global $BOINC_EMAIL;
|
2002-08-14 20:31:27 +00:00
|
|
|
global $BOINC_DOWNLOAD_URL;
|
2002-07-05 05:33:40 +00:00
|
|
|
global $BOINC_KEY_DIR;
|
2002-07-15 07:19:44 +00:00
|
|
|
global $BOINC_MASTER_URL;
|
2002-08-26 22:57:17 +00:00
|
|
|
global $BOINC_DB_NAME;
|
2002-05-24 04:29:10 +00:00
|
|
|
|
|
|
|
$bad = false;
|
|
|
|
$BOINC_DOWNLOAD_DIR = getenv("BOINC_DOWNLOAD_DIR");
|
|
|
|
if ($BOINC_DOWNLOAD_DIR == null) {
|
|
|
|
echo "Must define BOINC_DOWNLOAD_DIR\n";
|
|
|
|
$bad = true;
|
|
|
|
}
|
|
|
|
$BOINC_UPLOAD_DIR = getenv("BOINC_UPLOAD_DIR");
|
|
|
|
if ($BOINC_UPLOAD_DIR == null) {
|
|
|
|
echo "Must define BOINC_UPLOAD_DIR\n";
|
|
|
|
$bad = true;
|
|
|
|
}
|
|
|
|
$BOINC_PLATFORM = getenv("BOINC_PLATFORM");
|
|
|
|
if ($BOINC_PLATFORM == null) {
|
|
|
|
echo "Must define BOINC_PLATFORM\n";
|
|
|
|
$bad = true;
|
|
|
|
}
|
|
|
|
$BOINC_EMAIL = getenv("BOINC_EMAIL");
|
|
|
|
if ($BOINC_EMAIL == null) {
|
|
|
|
echo "Must define BOINC_EMAIL\n";
|
|
|
|
$bad = true;
|
|
|
|
}
|
2002-08-14 20:31:27 +00:00
|
|
|
$BOINC_DOWNLOAD_URL = getenv("BOINC_DOWNLOAD_URL");
|
|
|
|
if ($BOINC_DOWNLOAD_URL == null) {
|
|
|
|
echo "Must define BOINC_DOWNLOAD_URL\n";
|
2002-05-24 04:29:10 +00:00
|
|
|
$bad = true;
|
|
|
|
}
|
2002-07-05 05:33:40 +00:00
|
|
|
$BOINC_KEY_DIR = getenv("BOINC_KEY_DIR");
|
|
|
|
if ($BOINC_KEY_DIR == null) {
|
|
|
|
echo "Must define BOINC_KEY_DIR\n";
|
|
|
|
$bad = true;
|
|
|
|
}
|
2002-07-15 07:19:44 +00:00
|
|
|
$BOINC_MASTER_URL = getenv("BOINC_MASTER_URL");
|
|
|
|
if ($BOINC_MASTER_URL == null) {
|
|
|
|
echo "Must define BOINC_MASTER_URL\n";
|
|
|
|
$bad = true;
|
|
|
|
}
|
2002-08-26 22:57:17 +00:00
|
|
|
$BOINC_DB_NAME = getenv("BOINC_DB_NAME");
|
|
|
|
if ($BOINC_DB_NAME == null) {
|
|
|
|
echo "Must define BOINC_DB_NAME\n";
|
|
|
|
$bad = true;
|
|
|
|
}
|
2002-05-24 04:29:10 +00:00
|
|
|
if ($bad) exit();
|
|
|
|
}
|
2002-07-05 05:33:40 +00:00
|
|
|
|
2002-08-26 22:57:17 +00:00
|
|
|
function clear_server_dirs($clear_key_dir) {
|
2002-05-24 04:29:10 +00:00
|
|
|
global $BOINC_DOWNLOAD_DIR;
|
|
|
|
global $BOINC_UPLOAD_DIR;
|
2002-08-26 22:57:17 +00:00
|
|
|
global $BOINC_KEY_DIR;
|
2002-05-24 04:29:10 +00:00
|
|
|
|
2002-05-30 16:54:06 +00:00
|
|
|
if ($BOINC_DOWNLOAD_DIR == null) {
|
|
|
|
echo "Must define BOINC_DOWNLOAD_DIR\n";
|
|
|
|
$bad = true;
|
|
|
|
}
|
|
|
|
if ($BOINC_UPLOAD_DIR == null) {
|
|
|
|
echo "Must define BOINC_UPLOAD_DIR\n";
|
|
|
|
$bad = true;
|
|
|
|
}
|
2002-07-05 05:33:40 +00:00
|
|
|
if ($BOINC_KEY_DIR == null) {
|
|
|
|
echo "Must define BOINC_KEY_DIR\n";
|
|
|
|
$bad = true;
|
|
|
|
}
|
2002-08-26 22:57:17 +00:00
|
|
|
if ($bad) exit();
|
|
|
|
|
|
|
|
PassThru("rm -f $BOINC_DOWNLOAD_DIR/*");
|
|
|
|
PassThru("rm -f $BOINC_UPLOAD_DIR/*");
|
|
|
|
if ($clear_key_dir) {
|
|
|
|
PassThru("rm -f $BOINC_KEY_DIR/*");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function clear_client_dirs() {
|
2002-08-21 23:01:12 +00:00
|
|
|
$MASTER_URL = urlencode(stripslashes(stripslashes(getenv("BOINC_MASTER_URL"))));
|
|
|
|
if ($MASTER_URL == null) {
|
|
|
|
echo "Must define BOINC_MASTER_URL\n";
|
|
|
|
$bad = true;
|
|
|
|
}
|
2002-05-30 16:54:06 +00:00
|
|
|
if ($bad) exit();
|
2002-08-21 23:01:12 +00:00
|
|
|
PassThru("rm -f $MASTER_URL/*" );
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-06-21 06:52:47 +00:00
|
|
|
function init_client_dirs($prefs_file) {
|
2002-07-15 07:19:44 +00:00
|
|
|
global $BOINC_MASTER_URL;
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
PassThru("rm -f client_state.xml");
|
|
|
|
PassThru("rm -rf ".PROJECTS);
|
|
|
|
PassThru("rm -rf slots");
|
2002-07-29 00:39:45 +00:00
|
|
|
PassThru("sed -e s/BOINC_MASTER_URL/$BOINC_MASTER_URL/ $prefs_file > prefs.xml");
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function copy_to_download_dir($f) {
|
2002-05-24 04:29:10 +00:00
|
|
|
global $BOINC_DOWNLOAD_DIR;
|
|
|
|
|
|
|
|
PassThru("cp $f $BOINC_DOWNLOAD_DIR");
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-05-29 23:25:21 +00:00
|
|
|
function add_user($prefs_file) {
|
2002-05-24 04:29:10 +00:00
|
|
|
global $BOINC_EMAIL;
|
2002-07-29 00:39:45 +00:00
|
|
|
global $BOINC_MASTER_URL;
|
|
|
|
|
2002-05-29 23:25:21 +00:00
|
|
|
$cmd = "../tools/add user -email_addr $BOINC_EMAIL -user_name David -web_password foobar -authenticator 3f7b90793a0175ad0bda68684e8bd136 ";
|
|
|
|
if ($prefs_file) {
|
2002-07-29 00:39:45 +00:00
|
|
|
PassThru("sed -e s/BOINC_MASTER_URL/$BOINC_MASTER_URL/ $prefs_file > prefs_temp.xml");
|
2002-07-15 07:19:44 +00:00
|
|
|
$cmd = $cmd." -prefs_file prefs_temp.xml";
|
2002-05-29 23:25:21 +00:00
|
|
|
}
|
|
|
|
PassThru($cmd);
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function add_prefs($file) {
|
2002-05-24 04:29:10 +00:00
|
|
|
global $BOINC_EMAIL;
|
|
|
|
|
|
|
|
PassThru("../tools/add prefs -email_addr $BOINC_EMAIL -prefs_file $file");
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-08-25 07:54:33 +00:00
|
|
|
function add_project($name) {
|
|
|
|
PassThru("../tools/add project -project_name '$name'");
|
|
|
|
}
|
|
|
|
|
2002-06-20 23:27:37 +00:00
|
|
|
function add_platform($platform) {
|
2002-05-24 04:29:10 +00:00
|
|
|
global $BOINC_PLATFORM;
|
|
|
|
|
2002-06-20 23:27:37 +00:00
|
|
|
if( $platform ) {
|
|
|
|
PassThru("../tools/add platform -platform_name $platform");
|
|
|
|
} else {
|
|
|
|
PassThru("../tools/add platform -platform_name $BOINC_PLATFORM");
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-07-05 22:04:16 +00:00
|
|
|
function add_core_client_message($message, $priority, $platform) {
|
2002-05-24 04:29:10 +00:00
|
|
|
global $BOINC_DOWNLOAD_DIR;
|
|
|
|
global $BOINC_UPLOAD_DIR;
|
|
|
|
global $BOINC_PLATFORM;
|
2002-07-07 20:39:24 +00:00
|
|
|
global $BOINC_KEY_DIR;
|
2002-05-24 04:29:10 +00:00
|
|
|
|
2002-07-05 22:04:16 +00:00
|
|
|
if( $platform == null ) {
|
|
|
|
$plat = $BOINC_PLATFORM;
|
|
|
|
} else {
|
|
|
|
$plat = $platform;
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
PassThru("../tools/add app -app_name core_client -version ".VERSION);
|
2002-08-14 20:31:27 +00:00
|
|
|
$cmd = "../tools/add app_version -app_name core_client -platform_name $plat -version ".VERSION." -download_dir $BOINC_DOWNLOAD_DIR -download_url $BOINC_DOWNLOAD_URL -message '$message' -message_priority '$priority' -code_sign_keyfile $BOINC_KEY_DIR/code_sign_private -exec_dir ../client -exec_files ".CORE_CLIENT;
|
2002-07-29 00:39:45 +00:00
|
|
|
//echo "$cmd\n";
|
|
|
|
PassThru($cmd);
|
2002-05-24 04:29:10 +00:00
|
|
|
PassThru("cp ../client/".CORE_CLIENT." $BOINC_DOWNLOAD_DIR");
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-07-05 22:04:16 +00:00
|
|
|
function add_core_client($platform) {
|
|
|
|
add_core_client_message("", "", $platform);
|
|
|
|
}
|
|
|
|
|
2002-07-07 20:39:24 +00:00
|
|
|
function add_app($name, $platform, $exec_name) {
|
2002-07-05 22:04:16 +00:00
|
|
|
PassThru("../tools/add app -app_name $name -version ".VERSION);
|
|
|
|
add_app_version( $name, $platform, $exec_name );
|
2002-05-17 22:33:57 +00:00
|
|
|
}
|
|
|
|
|
2002-07-07 20:39:24 +00:00
|
|
|
function add_app_version($name, $platform, $exec_name) {
|
2002-05-24 04:29:10 +00:00
|
|
|
global $BOINC_DOWNLOAD_DIR;
|
|
|
|
global $BOINC_PLATFORM;
|
2002-08-14 20:31:27 +00:00
|
|
|
global $BOINC_DOWNLOAD_URL;
|
2002-07-07 20:39:24 +00:00
|
|
|
global $BOINC_KEY_DIR;
|
2002-05-24 04:29:10 +00:00
|
|
|
|
2002-07-05 22:04:16 +00:00
|
|
|
if( $exec_name == null ) {
|
|
|
|
$exec_name = $name;
|
|
|
|
}
|
|
|
|
if( $platform == null ) {
|
|
|
|
$plat = $BOINC_PLATFORM;
|
|
|
|
} else {
|
|
|
|
$plat = $platform;
|
|
|
|
}
|
|
|
|
|
2002-08-14 20:31:27 +00:00
|
|
|
$cmd = "../tools/add app_version -app_name $name -platform_name $plat -version ".VERSION." -download_dir $BOINC_DOWNLOAD_DIR -download_url $BOINC_DOWNLOAD_URL -code_sign_keyfile $BOINC_KEY_DIR/code_sign_private -exec_dir ../apps -exec_files $exec_name";
|
2002-07-29 00:39:45 +00:00
|
|
|
//echo "$cmd\n";
|
|
|
|
PassThru($cmd);
|
2002-07-05 22:04:16 +00:00
|
|
|
PassThru("cp ../apps/$exec_name $BOINC_DOWNLOAD_DIR");
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function create_work($x) {
|
2002-07-05 05:33:40 +00:00
|
|
|
global $BOINC_KEY_DIR;
|
|
|
|
PassThru("../tools/create_work -keyfile $BOINC_KEY_DIR/upload_private $x");
|
|
|
|
}
|
|
|
|
|
|
|
|
function create_keys() {
|
|
|
|
global $BOINC_KEY_DIR;
|
|
|
|
PassThru("../lib/crypt_prog -genkey 1024 $BOINC_KEY_DIR/upload_private $BOINC_KEY_DIR/upload_public");
|
2002-07-07 20:39:24 +00:00
|
|
|
PassThru("../lib/crypt_prog -genkey 1024 $BOINC_KEY_DIR/code_sign_private $BOINC_KEY_DIR/code_sign_public");
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-07-01 22:41:09 +00:00
|
|
|
function run_client($args) {
|
|
|
|
PassThru("../client/".CORE_CLIENT." $args");
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-05-24 04:29:10 +00:00
|
|
|
function start_feeder() {
|
2002-06-01 20:26:21 +00:00
|
|
|
PassThru("cd ../sched; feeder -asynch > feeder_out");
|
|
|
|
}
|
|
|
|
|
|
|
|
function stop_feeder() {
|
|
|
|
$f = fopen("../sched/feeder_trigger", "w");
|
|
|
|
fputs($f, "<quit/>\n");
|
|
|
|
fclose($f);
|
2002-05-24 04:29:10 +00:00
|
|
|
}
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
function compare_file($out, $correct) {
|
2002-05-24 04:29:10 +00:00
|
|
|
global $BOINC_UPLOAD_DIR;
|
|
|
|
|
|
|
|
PassThru("diff $BOINC_UPLOAD_DIR/$out $correct", $retval);
|
2002-04-30 22:22:54 +00:00
|
|
|
if ($retval) {
|
|
|
|
echo "File mismatch: $out $correct\n";
|
|
|
|
} else {
|
|
|
|
echo "Files match: $out $correct\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_results_done() {
|
2002-08-26 22:57:17 +00:00
|
|
|
open_db();
|
2002-04-30 22:22:54 +00:00
|
|
|
$result = mysql_query("select * from result where state<>4");
|
|
|
|
while ($x = mysql_fetch_object($result)) {
|
|
|
|
echo "result $x->id is not done\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-01 19:29:40 +00:00
|
|
|
function num_wus_left() {
|
2002-08-26 22:57:17 +00:00
|
|
|
open_db();
|
2002-07-01 19:29:40 +00:00
|
|
|
$numwus = mysql_query("select count(*) as nres from result where state<>4");
|
|
|
|
$result = mysql_fetch_object($numwus);
|
|
|
|
return $result->nres;
|
|
|
|
}
|
|
|
|
|
2002-06-24 02:29:51 +00:00
|
|
|
function compare_files($out, $correct) {
|
|
|
|
PassThru("diff $out $correct", $retval);
|
|
|
|
if ($retval) {
|
|
|
|
echo "File mismatch: $out $correct\n";
|
|
|
|
} else {
|
|
|
|
echo "Files match: $out $correct\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function run_api_test() {
|
|
|
|
PassThru("../api/api_test");
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-07-03 20:48:01 +00:00
|
|
|
function clean_api() {
|
|
|
|
PassThru("rm -f counter app_to_core.xml core_to_app.xml foobar");
|
|
|
|
}
|
|
|
|
|
2002-07-31 19:05:15 +00:00
|
|
|
function get_time($file_name) {
|
|
|
|
$time_file = fopen($file_name, "r");
|
|
|
|
if($time_file == NULL) return 0;
|
|
|
|
fscanf($time_file, "%f", $app_time);
|
|
|
|
PassThru("rm -f ".$file_name);
|
|
|
|
return $app_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
function compare_time($app_time) {
|
2002-07-25 00:09:43 +00:00
|
|
|
$epsilon = 0.0001;
|
2002-08-26 22:57:17 +00:00
|
|
|
open_db();
|
2002-07-25 00:09:43 +00:00
|
|
|
$data = mysql_query("select cpu_time from result where name = 'uccpu_wu_0'");
|
|
|
|
$result = mysql_fetch_object($data);
|
|
|
|
$db_time = $result->cpu_time;
|
2002-07-31 19:05:15 +00:00
|
|
|
$client_time = get_time("client_time");
|
|
|
|
if(abs($app_time - $client_time) > $epsilon) {
|
|
|
|
printf("Time mismatch: app %f client %f\n", $app_time, $client_time);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("Client time %f matches app time %f\n", $client_time, $app_time)
|
|
|
|
;
|
|
|
|
}
|
2002-07-25 00:09:43 +00:00
|
|
|
if(abs($db_time - $app_time) > $epsilon) {
|
2002-07-31 19:05:15 +00:00
|
|
|
printf("Time mismatch: client %f server %f\n", $client_time, $db_time);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("Reported time %f matches client time %f\n", $db_time, $client_time);
|
2002-07-24 19:47:36 +00:00
|
|
|
}
|
2002-07-31 19:05:15 +00:00
|
|
|
PassThru("rm -f client_time app_time");
|
2002-07-24 19:47:36 +00:00
|
|
|
}
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
?>
|