summaryrefslogtreecommitdiffstats
path: root/satellit_installer/static_files/slxadmin-init/slxadmin-init.php
blob: 7f72b429e59b11436ef5c69986b93f5ad72c45d9 (plain) (blame)
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
<?php

/*
 * Init script for slx-admin, filling in bwLehrpool specific data into DB.
 * This script should be idempotent and handle upgrades from earlier versions.
 */

$SCRIPTDIR = dirname(__FILE__);

/*
 * Most things should be configurable here
 */

// Where to get available Linux system information from
$MINILINUX_URL = 'https://bwlp-masterserver.ruf.uni-freiburg.de/minilinux/sat_07';
$MINILINUX_PUBKEY = file_get_contents($SCRIPTDIR . '/gpg-key.asc');
/*
 * Boilerplate
 */

chdir('/srv/openslx/www/slx-admin') || exit(1);

require_once 'config.php';

// Autoload classes from ./inc which adhere to naming scheme <lowercasename>.inc.php
spl_autoload_register(function ($class) {
	$file = 'inc/' . preg_replace('/[^a-z0-9]/', '', mb_strtolower($class)) . '.inc.php';
	if (!file_exists($file))
		return;
	require_once $file;
});

/*
 * Stuff starts here
 */

/*
 * Minilinux update source URL
 */

if ($MINILINUX_PUBKEY === false) {
	echo "Error reading GPG key from file\n";
	exit(1);
}

Database::exec("INSERT INTO minilinux_source (sourceid, title, url, pubkey)
	VALUES ('bwlp', 'bwLehrpool', :url, :pubkey)
	ON DUPLICATE KEY UPDATE title = VALUES(title), url = VALUES(url), pubkey = VALUES(pubkey)",
		['url' => $MINILINUX_URL, 'pubkey' => $MINILINUX_PUBKEY]);

exit(0);