Page MenuHomeDevCentral

D1452.id3730.diff
No OneTemporary

D1452.id3730.diff

diff --git a/pillar/saas/mediawiki.sls b/pillar/saas/mediawiki.sls
--- a/pillar/saas/mediawiki.sls
+++ b/pillar/saas/mediawiki.sls
@@ -20,6 +20,10 @@
mediawiki_saas:
directory: /var/51-wwwroot/saas-mediawiki
+ mediawiki_directory: /srv/mediawiki
+ db:
+ host: 127.0.0.1
+ user: mediawiki-saas
mediawiki_datastores:
###
diff --git a/roles/saas-mediawiki/software/files/mw.sh.jinja b/roles/saas-mediawiki/software/files/mw.sh.jinja
new file mode 100755
--- /dev/null
+++ b/roles/saas-mediawiki/software/files/mw.sh.jinja
@@ -0,0 +1,100 @@
+#!/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 <wiki> <maintenance script to call> [arguments]" >&2
+ exit 1
+fi
+
+WIKI=$1
+SCRIPT=$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
+
+# -------------------------------------------------------------
+# 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 MW_INSTALL_PATH
+
+rlwrap php "$FULL_SCRIPT_PATH" "$@"
diff --git a/roles/saas-mediawiki/software/init.sls b/roles/saas-mediawiki/software/init.sls
--- a/roles/saas-mediawiki/software/init.sls
+++ b/roles/saas-mediawiki/software/init.sls
@@ -6,10 +6,10 @@
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
-{% from "map.jinja" import packages with context %}
+{% from "map.jinja" import dirs, packages with context %}
# -------------------------------------------------------------
-# Software required by MediaWiki
+# Software required by MediaWiki or other tools
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mediawiki_software_dependencies:
@@ -21,3 +21,16 @@
- {{ packages.imagemagick }}
- {{ packages['jpeg-turbo'] }}
- {{ packages.lua }}
+ - rlwrap
+
+# -------------------------------------------------------------
+# Administration tool
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{{ dirs.bin }}/mw:
+ file.managed:
+ - source: roles/saas-mediawiki/software/files/mw.sh.jinja
+ - mode: 755
+ - template: jinja
+ - context:
+ saas: {{ pillar['mediawiki_saas'] }}

File Metadata

Mime Type
text/plain
Expires
Sun, Sep 29, 22:54 (21 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2165132
Default Alt Text
D1452.id3730.diff (4 KB)

Event Timeline