Skip to content

Instantly share code, notes, and snippets.

@mrclay
Created September 13, 2014 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrclay/7e1eab495545426e3e0b to your computer and use it in GitHub Desktop.
Save mrclay/7e1eab495545426e3e0b to your computer and use it in GitHub Desktop.
Scripts to take an Elgg 1.9 site down so that plugins can be added/removed without them being booted
<?php
/**
* Place a site in maintenance mode, disable caches, and disable plugin boot.
*/
if (php_sapi_name() !== "cli") {
exit;
}
require __DIR__ . '/engine/start.php';
if (!is_writable(elgg_get_data_path())) {
echo "Insufficient write permissions. Try sudo.\n";
exit;
}
echo "Placing site in maintenance mode.\n";
elgg_save_config('elgg_maintenance_mode', '1', null);
echo "Disabling simplecache.\n";
elgg_disable_simplecache();
echo "Disabling system cache.\n";
elgg_disable_system_cache();
echo "Deleting autoload cache.\n";
_elgg_services()->autoloadManager->deleteCache();
$file = elgg_get_plugins_path() . 'disabled';
echo "Temporarily disabling plugin boot by creating file: mod/disabled\n";
touch($file);
chmod($file, 0666);
<?php
/**
* Re-enable plugin boot, re-enable caches.
*/
if (php_sapi_name() !== "cli") {
exit;
}
require __DIR__ . '/engine/start.php';
if (!is_writable(elgg_get_data_path())) {
echo "Insufficient write permissions. Try sudo.\n";
exit;
}
$file = elgg_get_plugins_path() . 'disabled';
echo "Re-enabling plugin boot by deleting: mod/disabled\n";
unlink($file);
echo "Enabling system cache.\n";
elgg_enable_system_cache();
echo "Enabling simplecache.\n";
elgg_enable_simplecache();
echo "Deleting autoload cache.\n";
_elgg_services()->autoloadManager->deleteCache();
echo "Note: Your site is still in maintenance mode.\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment