diff options
Diffstat (limited to 'satellit_installer')
-rw-r--r-- | satellit_installer/includes/65-gpg.inc | 13 | ||||
-rw-r--r-- | satellit_installer/includes/90-patch_slxadmin.inc | 29 | ||||
-rwxr-xr-x | satellit_installer/satellit_installer | 9 | ||||
-rw-r--r-- | satellit_installer/static_files/rclocal_script.sh | 6 | ||||
-rw-r--r-- | satellit_installer/static_files/slxadmin-init/gpg-key.asc (renamed from satellit_installer/static_files/gpg-key.asc) | 0 | ||||
-rw-r--r-- | satellit_installer/static_files/slxadmin-init/slxadmin-init.php | 52 |
6 files changed, 80 insertions, 29 deletions
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 <?php @@ -18,8 +18,8 @@ patch_slxadmin () { mkdir -p "$WWWDIR/slx-admin/modules" cd "$WWWDIR/slx-admin/modules" || perror "Cannot cd to slxadmin/modules" for MOD in ${SLXADMIN_MODULES}; do - NAME=${MOD%%-*} - ln -s "../modules-available/$MOD" "$NAME" || pwarning "Could not activate module '$MOD' (alias '$NAME')" + NAME="${MOD%%-*}" + ln -s "../modules-available/$MOD" "$NAME" || perror "Could not activate module '$MOD' (alias '$NAME')" done cd - 1>/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/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 <<THEREDOC *** bwLehrpool Satelliten-Server, Version $VERSION *** diff --git a/satellit_installer/static_files/gpg-key.asc b/satellit_installer/static_files/slxadmin-init/gpg-key.asc index abbe024..abbe024 100644 --- a/satellit_installer/static_files/gpg-key.asc +++ b/satellit_installer/static_files/slxadmin-init/gpg-key.asc 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); |