mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Implement a maintenance mode
Add support for a maintenance mode that disables both the website and the SSH interface and can be enabled easily using a configuration option. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
2164750f1e
commit
a45b5073ca
4 changed files with 27 additions and 0 deletions
|
@ -28,6 +28,7 @@ auto_delete_age = 86400
|
||||||
pkgbuild_uri = https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=%s
|
pkgbuild_uri = https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=%s
|
||||||
log_uri = https://aur.archlinux.org/cgit/aur.git/log/?h=%s
|
log_uri = https://aur.archlinux.org/cgit/aur.git/log/?h=%s
|
||||||
snapshot_uri = https://aur.archlinux.org/cgit/aur.git/snapshot/%s.tar.gz
|
snapshot_uri = https://aur.archlinux.org/cgit/aur.git/snapshot/%s.tar.gz
|
||||||
|
enable-maintenance = 1
|
||||||
|
|
||||||
[auth]
|
[auth]
|
||||||
valid-keytypes = ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 ssh-ed25519
|
valid-keytypes = ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 ssh-ed25519
|
||||||
|
|
|
@ -21,6 +21,8 @@ repo_regex = config.get('serve', 'repo-regex')
|
||||||
git_shell_cmd = config.get('serve', 'git-shell-cmd')
|
git_shell_cmd = config.get('serve', 'git-shell-cmd')
|
||||||
ssh_cmdline = config.get('serve', 'ssh-cmdline')
|
ssh_cmdline = config.get('serve', 'ssh-cmdline')
|
||||||
|
|
||||||
|
enable_maintenance = config.getboolean('options', 'enable-maintenance')
|
||||||
|
|
||||||
def pkgbase_exists(pkgbase):
|
def pkgbase_exists(pkgbase):
|
||||||
db = mysql.connector.connect(host=aur_db_host, user=aur_db_user,
|
db = mysql.connector.connect(host=aur_db_host, user=aur_db_user,
|
||||||
passwd=aur_db_pass, db=aur_db_name,
|
passwd=aur_db_pass, db=aur_db_name,
|
||||||
|
@ -110,6 +112,9 @@ if not cmd:
|
||||||
cmdargv = shlex.split(cmd)
|
cmdargv = shlex.split(cmd)
|
||||||
action = cmdargv[0]
|
action = cmdargv[0]
|
||||||
|
|
||||||
|
if enable_maintenance:
|
||||||
|
die("The AUR is down due to maintenance. We will be back soon.")
|
||||||
|
|
||||||
if action == 'git-upload-pack' or action == 'git-receive-pack':
|
if action == 'git-upload-pack' or action == 'git-receive-pack':
|
||||||
if len(cmdargv) < 2:
|
if len(cmdargv) < 2:
|
||||||
die_with_help("%s: missing path" % (action))
|
die_with_help("%s: missing path" % (action))
|
||||||
|
|
15
web/html/503.php
Normal file
15
web/html/503.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
|
||||||
|
|
||||||
|
html_header( __("Service Unavailable") );
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div id="error-page" class="box 503">
|
||||||
|
<h2>503 - <?= __("Service Unavailable") ?></h2>
|
||||||
|
<p><?= __("Don't panic! This site is down due to maintenance. We will be back soon.") ?></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
html_footer(AURWEB_VERSION);
|
||||||
|
|
|
@ -7,6 +7,12 @@ include_once("pkgfuncs.inc.php");
|
||||||
$path = $_SERVER['PATH_INFO'];
|
$path = $_SERVER['PATH_INFO'];
|
||||||
$tokens = explode('/', $path);
|
$tokens = explode('/', $path);
|
||||||
|
|
||||||
|
if (config_get_bool('options', 'enable-maintenance') && (empty($tokens[1]) || ($tokens[1] != "css" && $tokens[1] != "images"))) {
|
||||||
|
header("HTTP/1.0 503 Service Unavailable");
|
||||||
|
include "./503.php";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) {
|
if (!empty($tokens[1]) && '/' . $tokens[1] == get_pkg_route()) {
|
||||||
if (!empty($tokens[2])) {
|
if (!empty($tokens[2])) {
|
||||||
/* TODO: Create a proper data structure to pass variables from
|
/* TODO: Create a proper data structure to pass variables from
|
||||||
|
|
Loading…
Add table
Reference in a new issue