Skip to content

Commit

Permalink
Reorganize LocalSettings and composer
Browse files Browse the repository at this point in the history
  • Loading branch information
pastakhov committed Mar 11, 2022
1 parent b13259e commit dc9e025
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 70 deletions.
6 changes: 2 additions & 4 deletions Dockerfile
Expand Up @@ -643,9 +643,7 @@ RUN set -x; \
&& chmod g+w -R $MW_HOME/canasta-skins \
# Create symlinks from $MW_VOLUME to the wiki root for images and cache directories
&& ln -s $MW_VOLUME/images $MW_HOME/images \
&& ln -s $MW_VOLUME/cache $MW_HOME/cache \
# Create placeholder symlink for the LocalSettings file
&& ln -s $MW_VOLUME/config/LocalSettings.php $MW_HOME/LocalSettings.php
&& ln -s $MW_VOLUME/cache $MW_HOME/cache

FROM base as final

Expand Down Expand Up @@ -679,7 +677,7 @@ COPY _sources/configs/php_timeouts.ini /etc/php/7.4/apache2/conf.d/
COPY _sources/scripts/*.sh /
COPY _sources/configs/robots.txt $WWW_ROOT/
COPY _sources/configs/.htaccess $WWW_ROOT/
COPY _sources/canasta/CanastaUtils.php $MW_HOME/
COPY _sources/canasta/LocalSettings.php _sources/canasta/CanastaUtils.php _sources/canasta/CanastaDefaultSettings.php $MW_HOME/
COPY _sources/canasta/getMediawikiSettings.php /
COPY _sources/configs/mpm_prefork.conf /etc/apache2/mods-available/mpm_prefork.conf

Expand Down
68 changes: 68 additions & 0 deletions _sources/canasta/CanastaDefaultSettings.php
@@ -0,0 +1,68 @@
<?php

# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
exit;
}

function getCanastaLocalSettingsFilePath() {
return getenv( 'MW_VOLUME' ) . '/config/LocalSettings.php';
}

if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
// Called from WebInstaller or similar entry point

if ( !file_exists( getCanastaLocalSettingsFilePath() ) ) {
// We don't define any variables and WebInstaller should decide that "$IP/LocalSettings.php" does not exist.
return;
}
}
// WebStart entry point

// Check that user's LocalSettings.php exists
$canastaLocalSettingsFilePath = getCanastaLocalSettingsFilePath();
if ( !is_readable( $canastaLocalSettingsFilePath ) ) {
// Emulate that "$IP/LocalSettings.php" does not exist

// Set MW_CONFIG_FILE for NoLocalSettings template work correctly
define( "MW_CONFIG_FILE", $canastaLocalSettingsFilePath );

// Do the same what function wfWebStartNoLocalSettings() does
require_once "$IP/includes/NoLocalSettings.php";
die();
}

// Canasta default settings below

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/w";
$wgScriptExtension = ".php";
$wgArticlePath = '/wiki/$1';
$wgStylePath = $wgScriptPath . '/skins';

## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;

# SyntaxHighlight_GeSHi
$wgPygmentizePath = '/usr/bin/pygmentize';

# We use job runner instead
$wgJobRunRate = 0;

# Docker specific setup
# see https://www.mediawiki.org/wiki/Manual:$wgCdnServersNoPurge
$wgUseCdn = true;
$wgCdnServersNoPurge = [];
$wgCdnServersNoPurge[] = '172.16.0.0/12';

# Include user defined LocalSettings.php file
require_once "$canastaLocalSettingsFilePath";

# Include all files in LocalSettings.php.d directory
foreach (glob(getenv( 'MW_VOLUME' ) . '/config/LocalSettings.php.d/*.php') as $filename) {
require_once $filename;
}
25 changes: 0 additions & 25 deletions _sources/canasta/CanastaUtils.php
Expand Up @@ -5,31 +5,6 @@
exit;
}

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/w";
$wgScriptExtension = ".php";
$wgArticlePath = '/wiki/$1';
$wgStylePath = $wgScriptPath . '/skins';

## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;

# SyntaxHighlight_GeSHi
$wgPygmentizePath = '/usr/bin/pygmentize';

# We use job runner instead
$wgJobRunRate = 0;

# Docker specific setup
# see https://www.mediawiki.org/wiki/Manual:$wgCdnServersNoPurge
$wgUseCdn = true;
$wgCdnServersNoPurge = [];
$wgCdnServersNoPurge[] = '172.16.0.0/12';

/**
* @param $extName
*/
Expand Down
9 changes: 9 additions & 0 deletions _sources/canasta/LocalSettings.php
@@ -0,0 +1,9 @@
<?php

# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
exit;
}

require_once "$IP/CanastaUtils.php";
require_once "$IP/CanastaDefaultSettings.php";
82 changes: 41 additions & 41 deletions _sources/scripts/run-apache.sh
Expand Up @@ -79,44 +79,44 @@ else
chmod -R g=rwX $APACHE_LOG_DIR
fi

autoinclude() {
echo "Auto-include started.."
while true; do
# Look for LocalSettings presence
if [ -e "$MW_VOLUME/config/LocalSettings.php" ]; then
# Automatically include CanastaUtils.php
if ! grep -q "CanastaUtils.php" "$MW_VOLUME/config/LocalSettings.php"; then
echo "Adding CanastaUtils.."
# Add include
sed -i 's/# End of automatically generated settings./@include("CanastaUtils.php");/g' "$MW_VOLUME/config/LocalSettings.php"
# Replace possible load calls, though we don't expect any because the initial state of the
# ./extensions folder should be empty so the wizard won't allow to select any skins or extensions
# to be enabled during LocalSettings generation
sed -i 's/wfLoadExtension/cfLoadExtension/g' "$MW_VOLUME/config/LocalSettings.php"
sed -i 's/wfLoadSkin/cfLoadSkin/g' "$MW_VOLUME/config/LocalSettings.php"
# Add list of bundled extensions
echo "# List of bundled extensions" >> "$MW_VOLUME/config/LocalSettings.php"
echo "" >> "$MW_VOLUME/config/LocalSettings.php"
cat "$MW_VOLUME/installedExtensions.txt" >> "$MW_VOLUME/config/LocalSettings.php"
echo "" >> "$MW_VOLUME/config/LocalSettings.php"
# Add list of bundled skins
echo "# List of bundled skins" >> "$MW_VOLUME/config/LocalSettings.php"
echo "" >> "$MW_VOLUME/config/LocalSettings.php"
cat "$MW_VOLUME/installedSkins.txt" >> "$MW_VOLUME/config/LocalSettings.php"
# Done
echo "Auto-include DONE"
# Run auto-update to avoid the need to retart the stack
run_autoupdate
break
else
# Inclusion is already in place
echo "Auto-include not needed"
break
fi
fi
sleep 1
done
}
#autoinclude() {
# echo "Auto-include started.."
# while true; do
# # Look for LocalSettings presence
# if [ -e "$MW_VOLUME/config/LocalSettings.php" ]; then
# # Automatically include CanastaUtils.php
# if ! grep -q "CanastaUtils.php" "$MW_VOLUME/config/LocalSettings.php"; then
# echo "Adding CanastaUtils.."
# # Add include
# sed -i 's/# End of automatically generated settings./@include("CanastaUtils.php");/g' "$MW_VOLUME/config/LocalSettings.php"
# # Replace possible load calls, though we don't expect any because the initial state of the
# # ./extensions folder should be empty so the wizard won't allow to select any skins or extensions
# # to be enabled during LocalSettings generation
# sed -i 's/wfLoadExtension/cfLoadExtension/g' "$MW_VOLUME/config/LocalSettings.php"
# sed -i 's/wfLoadSkin/cfLoadSkin/g' "$MW_VOLUME/config/LocalSettings.php"
# # Add list of bundled extensions
# echo "# List of bundled extensions" >> "$MW_VOLUME/config/LocalSettings.php"
# echo "" >> "$MW_VOLUME/config/LocalSettings.php"
# cat "$MW_VOLUME/installedExtensions.txt" >> "$MW_VOLUME/config/LocalSettings.php"
# echo "" >> "$MW_VOLUME/config/LocalSettings.php"
# # Add list of bundled skins
# echo "# List of bundled skins" >> "$MW_VOLUME/config/LocalSettings.php"
# echo "" >> "$MW_VOLUME/config/LocalSettings.php"
# cat "$MW_VOLUME/installedSkins.txt" >> "$MW_VOLUME/config/LocalSettings.php"
# # Done
# echo "Auto-include DONE"
# # Run auto-update to avoid the need to retart the stack
# run_autoupdate
# break
# else
# # Inclusion is already in place
# echo "Auto-include not needed"
# break
# fi
# fi
# sleep 1
# done
#}

jobrunner() {
sleep 3
Expand Down Expand Up @@ -174,9 +174,9 @@ run_autoupdate () {
# Wait db
waitdatabase

autoinclude &
# Let it cycle at least once
sleep 1
#autoinclude &
## Let it cycle at least once
#sleep 1

cd "$MW_HOME" || exit

Expand Down

0 comments on commit dc9e025

Please sign in to comment.