forked from davidpanderson/science_united
-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_init.php
133 lines (123 loc) · 4.65 KB
/
project_init.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2018 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// initialize or update the project DB table
// run this from html/ops
// RUN WHENEVER BOINC PROJECT LIST HAS CHANGED
//
// input: html/ops/projects.xml
// get this from https://boinc.berkeley.edu/project_list.php
//
// IF ANYTHING HAS CHANGED:
// run project_digest.php as well (to update projects.ser)
require_once("../inc/keywords.inc");
require_once("../inc/project_ids.inc");
require_once("../inc/su_db.inc");
// remove projects and everything that refers to them
// THINK TWICE BEFORE DOING THIS
//
//function clean() {
// die();
// foreach (SUProject::enum() as $p) {
// $p->delete();
// }
// SUAccount::delete_all();
// SUHostProject::delete_all();
// SUAccountingProject::delete_all();
//}
function update_project($p) {
$name = (string)$p->name;
$url = (string)$p->url;
$web_url = (string)$p->web_url;
$web_rpc_url_base = (string)$p->web_rpc_url_base;
if (!$web_rpc_url_base) {
$web_rpc_url_base = $url;
}
$project_id = (string)$p->id;
$now = time();
$cmd = "~/boinc/lib/crypt_prog -sign_string $url ~/science_united/code_sign_private";
$out = array();
$retval = 0;
exec($cmd, $out, $retval);
if ($retval) {
die("$cmd failed\n");
}
$url_signature = implode("\n", $out);
$project = SUProject::lookup_id($project_id);
if ($project) {
if ($project->status != PROJECT_STATUS_AUTO) {
echo "Project $project->name was not enabled\n";
}
if ($url_signature != $project->url_signature) {
echo "updating $project->name URL signature\n";
$ret = $project->update("url_signature='$url_signature'");
if (!$ret) echo "update failed\n";
}
if ($url != $project->url) {
echo "updating $project->name URL\n";
$ret = $project->update("url='$url'");
if (!$ret) echo "update failed\n";
}
if ($web_url != $project->web_url) {
echo "updating $project->name web URL\n";
$ret = $project->update("web_url='$web_url'");
if (!$ret) echo "update failed\n";
}
if ($web_rpc_url_base != $project->web_rpc_url_base) {
echo "updating $project->name RPC URL base\n";
$ret = $project->update("web_rpc_url_base='$web_rpc_url_base'");
if (!$ret) echo "update failed\n";
}
if (!$project->authenticator) {
echo "Project $project->name has no authenticator: create an account\n";
}
} else {
SUProject::insert("(id, create_time, name, url, web_rpc_url_base, url_signature, share, status) values ($project_id, $now, '$name', '$url', '$web_rpc_url_base', '$url_signature', 10, ".PROJECT_STATUS_HIDE.")");
if (!SUAccountingProject::insert("(project_id, create_time) values ($project_id, $now)")) {
die("su_accounting_project insert failed\n");
}
echo "Added project $name; give it a (weak) authenticator, then set status to 2 (AUTO)\n";
}
}
// create or update projects based on projects.xml
// If a project is not there, flag as deprecated
// Skip certain projects.
//
function update_projects() {
$projs = SUProject::enum();
foreach ($projs as $p) {
$p->update("status = ".PROJECT_STATUS_HIDE);
}
$x = simplexml_load_file("projects.xml");
$projects = $x->project;
foreach ($projects as $p) {
if ((int)$p->id == PROJ_QCN) continue;
if ((int)$p->id == PROJ_RADIOACTIVE) continue;
if ((int)$p->id == PROJ_LEIDEN) continue;
if ((int)$p->id == PROJ_MOO) continue;
if ((int)$p->id == PROJ_YOYO) continue;
if ((int)$p->id == PROJ_MINECRAFT) continue;
// the following require invitation code; skip
//
if ((int)$p->id == PROJ_COLLATZ) continue;
if ((int)$p->id == PROJ_PRIMABOINCA) continue;
if ((int)$p->id == PROJ_SRBASE) continue;
update_project($p);
}
}
update_projects();
?>