From 554c63664f0545ddffbfded2daf7c7505933eb6b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 25 Oct 2019 16:28:11 +0200 Subject: [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. --- satellit_installer/includes/65-gpg.inc | 13 ------ satellit_installer/includes/90-patch_slxadmin.inc | 29 +++++++++--- satellit_installer/satellit_installer | 9 ++-- satellit_installer/static_files/gpg-key.asc | 52 ---------------------- satellit_installer/static_files/rclocal_script.sh | 6 --- .../static_files/slxadmin-init/gpg-key.asc | 52 ++++++++++++++++++++++ .../static_files/slxadmin-init/slxadmin-init.php | 52 ++++++++++++++++++++++ 7 files changed, 132 insertions(+), 81 deletions(-) delete mode 100644 satellit_installer/includes/65-gpg.inc delete mode 100644 satellit_installer/static_files/gpg-key.asc create mode 100644 satellit_installer/static_files/slxadmin-init/gpg-key.asc create mode 100644 satellit_installer/static_files/slxadmin-init/slxadmin-init.php diff --git a/satellit_installer/includes/65-gpg.inc b/satellit_installer/includes/65-gpg.inc deleted file mode 100644 index 95f51b5..0000000 --- a/satellit_installer/includes/65-gpg.inc +++ /dev/null @@ -1,13 +0,0 @@ - -import_gpg () { - # Install trust for all users - this is dumb but gpg wants to WRITE tp that directory, so - # we can't just use a public dir owned by root with 0755 permissions (which would be OK security-wise, - # as we never sign anything but just want to verify) - local PWUSER - local KEY="/tmp/bwlp-blubbediblubb.asc" - cp "${BASEDIR}/static_files/gpg-key.asc" "$KEY" - chmod 0444 "$KEY" - for PWUSER in taskmanager root; do - sudo -u "$PWUSER" gpg --import "$KEY" || perror "Could not import gpg key for $PWUSER" - done -} diff --git a/satellit_installer/includes/90-patch_slxadmin.inc b/satellit_installer/includes/90-patch_slxadmin.inc index 99f4c16..d6d6e88 100644 --- a/satellit_installer/includes/90-patch_slxadmin.inc +++ b/satellit_installer/includes/90-patch_slxadmin.inc @@ -1,12 +1,12 @@ -patch_slxadmin () { +copy_slxadmin_config () { # Install config cp -p "${BASEDIR}/static_files/slxadmin-config.php" "$WWWDIR/slx-admin/config.php" || perror "slxadmin config.php not found" chmod 640 "$WWWDIR/slx-admin/config.php" chown root:www-data "$WWWDIR/slx-admin/config.php" +} - # appending a variable with satellite server build date/time to slx-admin config: - echo "define('CONFIG_FOOTER', 'Build time: $(date "+%Y-%m-%d %H:%m:%S"), $VERSION');" >> "$WWWDIR/slx-admin/config.php" - +# Prepare files and symlinks in slx-admin www dir +patch_slxadmin_dir () { # Create redirect for / cat > "$WWWDIR/index.php" <<-HIERDOCK /dev/null # Add system cronjob to execute slx-admin cronjob @@ -31,3 +31,20 @@ patch_slxadmin () { ln -nfs "../slxadmin-boot.service" "/etc/systemd/system/multi-user.target.wants/slxadmin-boot.service" || perror "Could not enable slxadmin boot service" } +# This needs to be called after mysql users have been created +install_slxadmin_db () { + # Prepare temporary config + copy_slxadmin_config + sed -i "s/%MYSQL_OPENSLX_PASS%/${MYSQL_OPENSLX_PASS}/" "$WWWDIR/slx-admin/config.php" + # Install slx-admin DB + cd "$WWWDIR/slx-admin" || perror "Cannot cd to $WWWDIR" + echo "# Installing slx-admin database" + sudo -n -u www-data ./install-all || perror "Could not install slx-admin database" + cd - 1>/dev/null + # Fill with data we need + php "${BASEDIR}/static_files/slxadmin-init/slxadmin-init.php" || perror "Filling tables with required data failed" + # Reset with original template for firstboot script + copy_slxadmin_config + # appending a variable with satellite server build date/time to slx-admin config: + echo "define('CONFIG_FOOTER', 'Build time: $(date "+%Y-%m-%d %H:%m:%S"), $VERSION');" >> "$WWWDIR/slx-admin/config.php" +} diff --git a/satellit_installer/satellit_installer b/satellit_installer/satellit_installer index b252d6b..5704678 100755 --- a/satellit_installer/satellit_installer +++ b/satellit_installer/satellit_installer @@ -115,8 +115,6 @@ check_users # Meet interesting users with uid>=1000 and kill them. # user 65534/sync will be ignored. add_users_groups # Adding necessary users and groups -import_gpg - sudo_config # Adding sudo config for user taskmanager install_ipxe "$IPXEDIR" @@ -185,8 +183,8 @@ install_slxlog install_timesync # cheap HTTP based timesync on boot install_finalize # Script for cleaning some stuff after installation -# Remove translation from menu etc. -patch_slxadmin +# Remove translation from menu etc., enable required modules +patch_slxadmin_dir # Check dir and file permissions: set_directory_permissions @@ -194,6 +192,9 @@ set_directory_permissions # And set some symbolic links thereafter: set_links +# Create tables, fill with predefined stuff +install_slxadmin_db + tar -z -c -T /dev/null -f /opt/openslx/empty.tgz # Mark vmstore as not mounted diff --git a/satellit_installer/static_files/gpg-key.asc b/satellit_installer/static_files/gpg-key.asc deleted file mode 100644 index abbe024..0000000 --- a/satellit_installer/static_files/gpg-key.asc +++ /dev/null @@ -1,52 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1.4.11 (GNU/Linux) - -mQINBFRjgJMBEADRhRM6UIFrH/vbo1VKzG3V7NFkLPK+L6ZG7arlJT06A4KNsEdu -YWyxYC94JTaZX7bKPMeVP5a4HJuFGPNkfwgBZmH445MOQ4IzEByrpwN76MmbeK53 -3b1ibCrkVWtXvzu/7dsb6dH/lrisHdz2kOpcdioMeD9KcXv71Uni/T2j6zTeDzpw -TWV5uxpAaVMFPpLRVJzuYOOz0a+cQ+eXgHQBBUL5pwXtiAp3G9FKq7zHHnoC1yJ1 -pm4y8pL8owp8NeIYzEFXnCGiNxQ1hP+O+gsG9r/yHxAODYEGwdXFoJ/4wDSwtyAl -HmAuI0SH7Cd8TsC3Oj9lg0m7U4PRkJZfxQImpJIeYdOx/EsX96oq0rJJqphVGCfE -TM5nvJaV7D0lFNNA5loeZVyk/wjuAeLqZcTrXgBABye3od/Vi3QX21OQtl68zsAN -r2dKrbubmzL6XmfqE4Tpi6nH6bHh+uLUiv4xNK+AaKdV9/X5R0vGVWQHbkgCx1ua -2apXHeuMQ8Omi1jYSqdbcLvDZvPvUFyAFQgT5g0ZFtsKON6CFr7LHO8GvJrVpBVH -K0GZRQvR9PZS/3WsKXYaphcCZlne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RcYw0odDwlKHPQPlUUj9xhUFoRfeidOjaYSVQW3+OzJIxt -LyapFu10PCLbWUoDWs5DP4auVGeIXo31MUy58bGYdOYn5WItn9KDUkSv+ZbA1Egg -FJbNugNpsuBuAwohVkKmZOAylWL8zjja/f8U2n6p5NlEmcGnDuDEn5W5P0z3ShK0 -eozay7YCIKN73LLHLfi5P3oLGkmOgadLbzuivdkYK/TsbmANmEurMVQ4I0c6o9W7 -bNW+ww3uI6KYQJ/x7RKa7MLgplxcEtNJIQ== -=vxZn ------END PGP PUBLIC KEY BLOCK----- diff --git a/satellit_installer/static_files/rclocal_script.sh b/satellit_installer/static_files/rclocal_script.sh index 381b56a..91bf30d 100644 --- a/satellit_installer/static_files/rclocal_script.sh +++ b/satellit_installer/static_files/rclocal_script.sh @@ -102,12 +102,6 @@ for i in dmsd.service taskmanager.service; do systemctl start $i done -# Install slx-admin DB -( - cd "/srv/openslx/www/slx-admin" - sudo -n -u www-data ./install-all >> /root/init.log -) - # Write MOTD cat > /etc/motd <.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); -- cgit v1.2.3-55-g7522