diff options
author | Simon Rettberg | 2019-10-25 16:28:11 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-10-25 16:28:11 +0200 |
commit | 554c63664f0545ddffbfded2daf7c7505933eb6b (patch) | |
tree | 0327c5ea51e99dc1d0bf2ade3e4318a5650c4031 /satellit_installer/static_files/slxadmin-init/slxadmin-init.php | |
parent | [SSPS] Fix check for rc-local; bail out on error; remove systemd check (diff) | |
download | setup-scripts-554c63664f0545ddffbfded2daf7c7505933eb6b.tar.gz setup-scripts-554c63664f0545ddffbfded2daf7c7505933eb6b.tar.xz setup-scripts-554c63664f0545ddffbfded2daf7c7505933eb6b.zip |
[SSPS] Move slx-admin db init to install stage, add predefined data
We now ship with some predefined table contents, which requires us to
set up the db scheme during installation. Probably a smart idea anyways
since any errors during that step would then happen right away and not
at the customer's site.
Diffstat (limited to 'satellit_installer/static_files/slxadmin-init/slxadmin-init.php')
-rw-r--r-- | satellit_installer/static_files/slxadmin-init/slxadmin-init.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/satellit_installer/static_files/slxadmin-init/slxadmin-init.php b/satellit_installer/static_files/slxadmin-init/slxadmin-init.php new file mode 100644 index 0000000..fbd5dce --- /dev/null +++ b/satellit_installer/static_files/slxadmin-init/slxadmin-init.php @@ -0,0 +1,52 @@ +<?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 = basedir(__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') || exit(1); +/* + * Boilerplate + */ + +define('CONFIG_DEBUG', true); +define('CONFIG_SQL_DSN', 'mysql:dbname=openslx;host=localhost'); +define('CONFIG_SQL_USER', $argv[1]); +define('CONFIG_SQL_PASS', $argv[2]); +define('CONFIG_SQL_FORCE_UTF8', true); + +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 + */ + +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); |