Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4793826
mw.sh.jinja
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
mw.sh.jinja
View Options
#!/bin/sh
# -------------------------------------------------------------
# mw
#
# Call a MediaWiki script
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Author: Sébastien Santoro aka Dereckson
# Created: 2018-03-21
# Licence: BSD-2-Clause
# Source file: roles/saas-mediawiki/software/files/mw.sh
# -------------------------------------------------------------
#
# <auto-generated>
# This file is managed by our rOPS SaltStack repository.
#
# Changes to this file may cause incorrect behavior
# and will be lost if the state is redeployed.
# </auto-generated>
MEDIAWIKI_DIRECTORY=
{{
saas.mediawiki_directory
}}
# -------------------------------------------------------------
# Configuration required by the MediaWiki or the SaaS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MEDIAWIKI_ENTRY_POINT=
{{
saas.mediawiki_directory
}}
/index.php
DB_HOST=
{{
saas.db.host
}}
DB_USER=
{{
saas.db.user
}}
# Allow to run arbitrary scripts outside the main directory
MW_INSTALL_PATH=
{{
saas.mediawiki_directory
}}
# -------------------------------------------------------------
# Helper methods
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
getcommandname() {
basename "$0"
}
# -------------------------------------------------------------
# Check arguments
#
# $1: wiki name (database name or alias)
# $2: script to call
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [ $# -lt 2 ]; then
echo "Usage: $0 <maintenance script to call> <wiki> [arguments]" >&2
exit 1
fi
SCRIPT=$1
WIKI=$2
# Other arguments are for the maintenance script
shift 2
# -------------------------------------------------------------
# Determine host
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HTTP_HOST=$(saas-mediawiki-get-host "$WIKI")
HTTP_HOST_EXIT_CODE=$?
if [ $HTTP_HOST_EXIT_CODE -ne 0 ]; then
exit $HTTP_HOST_EXIT_CODE
fi
SERVER_NAME=$HTTP_HOST
# -------------------------------------------------------------
# Determine script path
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Appends .php if string doesn't contain it
test "${SCRIPT#*.php}" != "$SCRIPT" || SCRIPT="$SCRIPT.php"
# By default, scripts are located in maintenance wgCacheDirectory
if [ "${SCRIPT#/}" == "$SCRIPT" ]; then
FULL_SCRIPT_PATH=$MEDIAWIKI_DIRECTORY/maintenance/$SCRIPT
else
FULL_SCRIPT_PATH=$SCRIPT
fi
if [ ! -f "$FULL_SCRIPT_PATH" ]; then
echo "$(getcommandname): $FULL_SCRIPT_PATH: No such file" >&2
exit 64
fi
# -------------------------------------------------------------
# Run script
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
export MEDIAWIKI_ENTRY_POINT
export DB_HOST
export DB_USER
export HTTP_HOST
export SERVER_NAME
export MW_INSTALL_PATH
rlwrap php "$FULL_SCRIPT_PATH" "$@"
File Metadata
Details
Attached
Mime Type
text/x-shellscript
Expires
Fri, Feb 28, 22:47 (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2436828
Default Alt Text
mw.sh.jinja (2 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment