#! /usr/bin/env php id; } else { $now = time(); $app_id = BoincApp::insert("(create_time, name, user_friendly_name) values ($now, '$app_name','Jobs for $platform')"); if (!$app_id) { error("Couldn't add application"); } } } // create apps/appname // function add_apps_dir() { global $app_name; $app_dir = "apps/$app_name"; if (!is_dir($app_dir)) { if (!mkdir($app_dir)) { error("Couldn't make app dir"); } } } // check for apps/appname/appname_platform_N, // find the largest such N; see if have new wrapper // If needed, create new version, copy wrapper // function create_app_dir() { global $app_name, $app_id, $platform, $wrapper_filename; global $wrapper_md5; $i = 0; $latest_i = -1; $have_latest_wrapper = false; while (1) { $app_dir = "apps/$app_name/".$app_name."_1.".$i."_$platform"; if (!file_exists($app_dir)) break; $latest_i = $i; $i++; } if ($latest_i >= 0) { $i = $latest_i; $app_dir = "apps/$app_name/".$app_name."_1.".$i."_$platform"; $file = "$app_dir/".$app_name."_1.".$i."_$platform"; $latest_md5 = md5_file($file); if ($latest_md5 == $wrapper_md5) { $have_latest_wrapper = true; echo "App version is current.\n"; } else { echo "$latest_md5 != $wrapper_md5\n"; } } if ($have_latest_wrapper) { echo "Current wrapper already installed.\n"; // make sure they ran update_versions // $av = BoincAppVersion::lookup("appid=$app_id and version_num=$i"); if (!$av) { echo "- type 'bin/update_versions', and answer 'y' to all questions.\n"; } } else { echo "Installing current wrapper.\n"; $i = $latest_i + 1; $app_dir = "apps/$app_name/".$app_name."_1.".$i."_$platform"; $file = "$app_dir/".$app_name."_1.".$i."_$platform"; if (!mkdir($app_dir)) { error("Couldn't created dir: $app_dir"); } if (!copy($wrapper_filename, $file)) { error("Couldn't copy $wrapper_filename to $file"); } chmod($file, 0750); echo "- type 'bin/update_versions', and answer 'y' to all questions.\n"; } } // make sure daemons are in the config file // function check_config_file() { global $app_name, $platform; $config = file_get_contents('config.xml'); if (!strstr($config, "single_job_assimilator")) { echo "- Add the following to the section of config.xml:\n single_job_assimilator -app $app_name single_job_assimilator_$platform.out single_job_assimilator_$platform.pid sample_trivial_validator -app $app_name sample_trivial_validator_$platform.out sample_trivial_validator_$platform.pid Then restart your project by typing bin/stop bin/start "; } } if ($argc != 2) usage(); $boinc_samples_dir = $argv[1]; check_wrapper_exists(); get_includes(); add_application(); add_apps_dir(); create_app_dir(); check_config_file(); ?>