git-remote-mediawiki: scripts to install, delete and clear a MediaWiki

install_wiki.sh allows the user to install a MediaWiki instance in a single shell command. Like "git instaweb", it configures and launches lighttpd without requiring root priviledges. To simplify database management, it uses SQLite, which doesn't require a running daemon, and allows reseting the database by simply replacing a single file. This allows install_wiki to also defines a function wiki_reset which clear all content of the previously created wiki, which will be very useful to run several indepenant tests on the same wiki. Note those functionnalities are made to be used from the user command line in the directory git/contrib/mw-to-git/t/ Signed-off-by: Simon CATHEBRAS <Simon.Cathebras@ensimag.imag.fr> Signed-off-by: Julien KHAYAT <Julien.Khayat@ensimag.imag.fr> Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr> Signed-off-by: Charles ROUSSEL <Charles.Roussel@ensimag.imag.fr> Signed-off-by: Guillaume SASDY <Guillaume.Sasdy@ensimag.imag.fr> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Guillaume Sasdy committed Jul 6, 2012 at 12:03 UTC 5ef6ad178521d146ccef84c8f4d2993d5c77c7e6
7 files changed +620
contrib/mw-to-git/t/.gitignore new
+2
@@ -0,0 +1,2 @@
1 +WEB/
2 +wiki/
contrib/mw-to-git/t/install-wiki.sh new
+45
@@ -0,0 +1,45 @@
1 +#!/bin/sh
2 +
3 +# This script installs or deletes a MediaWiki on your computer.
4 +# It requires a web server with PHP and SQLite running. In addition, if you
5 +# do not have MediaWiki sources on your computer, the option 'install'
6 +# downloads them for you.
7 +# Please set the CONFIGURATION VARIABLES in ./test-gitmw-lib.sh
8 +
9 +WIKI_TEST_DIR=$(cd "$(dirname "$0")" && pwd)
10 +
11 +if test -z "$WIKI_TEST_DIR"
12 +then
13 + WIKI_TEST_DIR=.
14 +fi
15 +
16 +. "$WIKI_TEST_DIR"/test-gitmw-lib.sh
17 +usage () {
18 + echo "Usage: "
19 + echo " ./install-wiki.sh <install | delete | --help>"
20 + echo " install | -i : Install a wiki on your computer."
21 + echo " delete | -d : Delete the wiki and all its pages and "
22 + echo " content."
23 +}
24 +
25 +
26 +# Argument: install, delete, --help | -h
27 +case "$1" in
28 + "install" | "-i")
29 + wiki_install
30 + exit 0
31 + ;;
32 + "delete" | "-d")
33 + wiki_delete
34 + exit 0
35 + ;;
36 + "--help" | "-h")
37 + usage
38 + exit 0
39 + ;;
40 + *)
41 + echo "Invalid argument: $1"
42 + usage
43 + exit 1
44 + ;;
45 +esac
contrib/mw-to-git/t/install-wiki/.gitignore new
+1
@@ -0,0 +1 @@
1 +wikidb.sqlite
contrib/mw-to-git/t/install-wiki/LocalSettings.php new
+128
@@ -0,0 +1,128 @@
1 +<?php
2 +# This file was automatically generated by the MediaWiki 1.19.0
3 +# installer. If you make manual changes, please keep track in case you
4 +# need to recreate them later.
5 +#
6 +# See includes/DefaultSettings.php for all configurable settings
7 +# and their default values, but don't forget to make changes in _this_
8 +# file, not there.
9 +#
10 +# Further documentation for configuration settings may be found at:
11 +# http://www.mediawiki.org/wiki/Manual:Configuration_settings
12 +
13 +# Protect against web entry
14 +if ( !defined( 'MEDIAWIKI' ) ) {
15 + exit;
16 +}
17 +
18 +## Uncomment this to disable output compression
19 +# $wgDisableOutputCompression = true;
20 +
21 +$wgSitename = "Git-MediaWiki-Test";
22 +$wgMetaNamespace = "Git-MediaWiki-Test";
23 +
24 +## The URL base path to the directory containing the wiki;
25 +## defaults for all runtime URL paths are based off of this.
26 +## For more information on customizing the URLs please see:
27 +## http://www.mediawiki.org/wiki/Manual:Short_URL
28 +$wgScriptPath = "@WG_SCRIPT_PATH@";
29 +$wgScriptExtension = ".php";
30 +
31 +## The protocol and server name to use in fully-qualified URLs
32 +$wgServer = "@WG_SERVER@";
33 +
34 +## The relative URL path to the skins directory
35 +$wgStylePath = "$wgScriptPath/skins";
36 +
37 +## The relative URL path to the logo. Make sure you change this from the default,
38 +## or else you'll overwrite your logo when you upgrade!
39 +$wgLogo = "$wgStylePath/common/images/wiki.png";
40 +
41 +## UPO means: this is also a user preference option
42 +
43 +$wgEnableEmail = true;
44 +$wgEnableUserEmail = true; # UPO
45 +
46 +$wgEmergencyContact = "apache@localhost";
47 +$wgPasswordSender = "apache@localhost";
48 +
49 +$wgEnotifUserTalk = false; # UPO
50 +$wgEnotifWatchlist = false; # UPO
51 +$wgEmailAuthentication = true;
52 +
53 +## Database settings
54 +$wgDBtype = "sqlite";
55 +$wgDBserver = "";
56 +$wgDBname = "@WG_SQLITE_DATAFILE@";
57 +$wgDBuser = "";
58 +$wgDBpassword = "";
59 +
60 +# SQLite-specific settings
61 +$wgSQLiteDataDir = "@WG_SQLITE_DATADIR@";
62 +
63 +
64 +## Shared memory settings
65 +$wgMainCacheType = CACHE_NONE;
66 +$wgMemCachedServers = array();
67 +
68 +## To enable image uploads, make sure the 'images' directory
69 +## is writable, then set this to true:
70 +$wgEnableUploads = false;
71 +$wgUseImageMagick = true;
72 +$wgImageMagickConvertCommand ="@CONVERT@";
73 +
74 +# InstantCommons allows wiki to use images from http://commons.wikimedia.org
75 +$wgUseInstantCommons = false;
76 +
77 +## If you use ImageMagick (or any other shell command) on a
78 +## Linux server, this will need to be set to the name of an
79 +## available UTF-8 locale
80 +$wgShellLocale = "en_US.utf8";
81 +
82 +## If you want to use image uploads under safe mode,
83 +## create the directories images/archive, images/thumb and
84 +## images/temp, and make them all writable. Then uncomment
85 +## this, if it's not already uncommented:
86 +#$wgHashedUploadDirectory = false;
87 +
88 +## Set $wgCacheDirectory to a writable directory on the web server
89 +## to make your wiki go slightly faster. The directory should not
90 +## be publically accessible from the web.
91 +#$wgCacheDirectory = "$IP/cache";
92 +
93 +# Site language code, should be one of the list in ./languages/Names.php
94 +$wgLanguageCode = "en";
95 +
96 +$wgSecretKey = "1c912bfe3519fb70f5dc523ecc698111cd43d81a11c585b3eefb28f29c2699b7";
97 +#$wgSecretKey = "@SECRETKEY@";
98 +
99 +
100 +# Site upgrade key. Must be set to a string (default provided) to turn on the
101 +# web installer while LocalSettings.php is in place
102 +$wgUpgradeKey = "ddae7dc87cd0a645";
103 +
104 +## Default skin: you can change the default skin. Use the internal symbolic
105 +## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector':
106 +$wgDefaultSkin = "vector";
107 +
108 +## For attaching licensing metadata to pages, and displaying an
109 +## appropriate copyright notice / icon. GNU Free Documentation
110 +## License and Creative Commons licenses are supported so far.
111 +$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
112 +$wgRightsUrl = "";
113 +$wgRightsText = "";
114 +$wgRightsIcon = "";
115 +
116 +# Path to the GNU diff3 utility. Used for conflict resolution.
117 +$wgDiff3 = "/usr/bin/diff3";
118 +
119 +# Query string length limit for ResourceLoader. You should only set this if
120 +# your web server has a query string length limit (then set it to that limit),
121 +# or if you have suhosin.get.max_value_length set in php.ini (then set it to
122 +# that value)
123 +$wgResourceLoaderMaxQueryLength = -1;
124 +
125 +
126 +
127 +# End of automatically generated settings.
128 +# Add more configuration options below.
contrib/mw-to-git/t/install-wiki/db_install.php new
+120
@@ -0,0 +1,120 @@
1 +<?php
2 +/**
3 + * This script generates a SQLite database for a MediaWiki version 1.19.0
4 + * You must specify the login of the admin (argument 1) and its
5 + * password (argument 2) and the folder where the database file
6 + * is located (absolute path in argument 3).
7 + * It is used by the script install-wiki.sh in order to make easy the
8 + * installation of a MediaWiki.
9 + *
10 + * In order to generate a SQLite database file, MediaWiki ask the user
11 + * to submit some forms in its web browser. This script simulates this
12 + * behavior though the functions <get> and <submit>
13 + *
14 + */
15 +$argc = $_SERVER['argc'];
16 +$argv = $_SERVER['argv'];
17 +
18 +$login = $argv[2];
19 +$pass = $argv[3];
20 +$tmp = $argv[4];
21 +$port = $argv[5];
22 +
23 +$url = 'http://localhost:'.$port.'/wiki/mw-config/index.php';
24 +$db_dir = urlencode($tmp);
25 +$tmp_cookie = tempnam($tmp, "COOKIE_");
26 +/*
27 + * Fetchs a page with cURL.
28 + */
29 +function get($page_name = "") {
30 + $curl = curl_init();
31 + $page_name_add = "";
32 + if ($page_name != "") {
33 + $page_name_add = '?page='.$page_name;
34 + }
35 + $url = $GLOBALS['url'].$page_name_add;
36 + $tmp_cookie = $GLOBALS['tmp_cookie'];
37 + curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);
38 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
39 + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
40 + curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);
41 + curl_setopt($curl, CURLOPT_HEADER, true);
42 + curl_setopt($curl, CURLOPT_URL, $url);
43 +
44 + $page = curl_exec($curl);
45 + if (!$page) {
46 + die("Could not get page: $url\n");
47 + }
48 + curl_close($curl);
49 + return $page;
50 +}
51 +
52 +/*
53 + * Submits a form with cURL.
54 + */
55 +function submit($page_name, $option = "") {
56 + $curl = curl_init();
57 + $datapost = 'submit-continue=Continue+%E2%86%92';
58 + if ($option != "") {
59 + $datapost = $option.'&'.$datapost;
60 + }
61 + $url = $GLOBALS['url'].'?page='.$page_name;
62 + $tmp_cookie = $GLOBALS['tmp_cookie'];
63 + curl_setopt($curl, CURLOPT_URL, $url);
64 + curl_setopt($curl, CURLOPT_POST, true);
65 + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
66 + curl_setopt($curl, CURLOPT_POSTFIELDS, $datapost);
67 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
68 + curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);
69 + curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);
70 +
71 + $page = curl_exec($curl);
72 + if (!$page) {
73 + die("Could not get page: $url\n");
74 + }
75 + curl_close($curl);
76 + return "$page";
77 +}
78 +
79 +/*
80 + * Here starts this script: simulates the behavior of the user
81 + * submitting forms to generates the database file.
82 + * Note this simulation was made for the MediaWiki version 1.19.0,
83 + * we can't assume it works with other versions.
84 + *
85 + */
86 +
87 +$page = get();
88 +if (!preg_match('/input type="hidden" value="([0-9]+)" name="LanguageRequestTime"/',
89 + $page, $matches)) {
90 + echo "Unexpected content for page downloaded:\n";
91 + echo "$page";
92 + die;
93 +};
94 +$timestamp = $matches[1];
95 +$language = "LanguageRequestTime=$timestamp&uselang=en&ContLang=en";
96 +$page = submit('Language', $language);
97 +
98 +submit('Welcome');
99 +
100 +$db_config = 'DBType=sqlite';
101 +$db_config = $db_config.'&sqlite_wgSQLiteDataDir='.$db_dir;
102 +$db_config = $db_config.'&sqlite_wgDBname='.$argv[1];
103 +submit('DBConnect', $db_config);
104 +
105 +$wiki_config = 'config_wgSitename=TEST';
106 +$wiki_config = $wiki_config.'&config__NamespaceType=site-name';
107 +$wiki_config = $wiki_config.'&config_wgMetaNamespace=MyWiki';
108 +$wiki_config = $wiki_config.'&config__AdminName='.$login;
109 +
110 +$wiki_config = $wiki_config.'&config__AdminPassword='.$pass;
111 +$wiki_config = $wiki_config.'&config__AdminPassword2='.$pass;
112 +
113 +$wiki_config = $wiki_config.'&wiki__configEmail=email%40email.org';
114 +$wiki_config = $wiki_config.'&config__SkipOptional=skip';
115 +submit('Name', $wiki_config);
116 +submit('Install');
117 +submit('Install');
118 +
119 +unlink($tmp_cookie);
120 +?>
contrib/mw-to-git/t/test-gitmw-lib.sh new
+289
@@ -0,0 +1,289 @@
1 +# Copyright (C) 2012
2 +# Charles Roussel <charles.roussel@ensimag.imag.fr>
3 +# Simon Cathebras <simon.cathebras@ensimag.imag.fr>
4 +# Julien Khayat <julien.khayat@ensimag.imag.fr>
5 +# Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
6 +# Simon Perrat <simon.perrat@ensimag.imag.fr>
7 +# License: GPL v2 or later
8 +
9 +#
10 +# CONFIGURATION VARIABLES
11 +# You might want to change these ones
12 +#
13 +
14 +. ./test.config
15 +
16 +CURR_DIR=$(pwd)
17 +TEST_OUTPUT_DIRECTORY=$(pwd)
18 +TEST_DIRECTORY="$CURR_DIR"/../../../t
19 +
20 +export TEST_OUTPUT_DIRECTORY TEST_DIRECTORY CURR_DIR
21 +
22 +if test "$LIGHTTPD" = "false" ; then
23 + PORT=80
24 +else
25 + WIKI_DIR_INST="$CURR_DIR/$WEB_WWW"
26 +fi
27 +
28 +# ================= Install part =================
29 +
30 +error () {
31 + echo "$@" >&2
32 + exit 1
33 +}
34 +
35 +# config_lighttpd
36 +#
37 +# Create the configuration files and the folders necessary to start lighttpd.
38 +# Overwrite any existing file.
39 +config_lighttpd () {
40 + mkdir -p $WEB
41 + mkdir -p $WEB_TMP
42 + mkdir -p $WEB_WWW
43 + cat > $WEB/lighttpd.conf <<EOF
44 + server.document-root = "$CURR_DIR/$WEB_WWW"
45 + server.port = $PORT
46 + server.pid-file = "$CURR_DIR/$WEB_TMP/pid"
47 +
48 + server.modules = (
49 + "mod_rewrite",
50 + "mod_redirect",
51 + "mod_access",
52 + "mod_accesslog",
53 + "mod_fastcgi"
54 + )
55 +
56 + index-file.names = ("index.php" , "index.html")
57 +
58 + mimetype.assign = (
59 + ".pdf" => "application/pdf",
60 + ".sig" => "application/pgp-signature",
61 + ".spl" => "application/futuresplash",
62 + ".class" => "application/octet-stream",
63 + ".ps" => "application/postscript",
64 + ".torrent" => "application/x-bittorrent",
65 + ".dvi" => "application/x-dvi",
66 + ".gz" => "application/x-gzip",
67 + ".pac" => "application/x-ns-proxy-autoconfig",
68 + ".swf" => "application/x-shockwave-flash",
69 + ".tar.gz" => "application/x-tgz",
70 + ".tgz" => "application/x-tgz",
71 + ".tar" => "application/x-tar",
72 + ".zip" => "application/zip",
73 + ".mp3" => "audio/mpeg",
74 + ".m3u" => "audio/x-mpegurl",
75 + ".wma" => "audio/x-ms-wma",
76 + ".wax" => "audio/x-ms-wax",
77 + ".ogg" => "application/ogg",
78 + ".wav" => "audio/x-wav",
79 + ".gif" => "image/gif",
80 + ".jpg" => "image/jpeg",
81 + ".jpeg" => "image/jpeg",
82 + ".png" => "image/png",
83 + ".xbm" => "image/x-xbitmap",
84 + ".xpm" => "image/x-xpixmap",
85 + ".xwd" => "image/x-xwindowdump",
86 + ".css" => "text/css",
87 + ".html" => "text/html",
88 + ".htm" => "text/html",
89 + ".js" => "text/javascript",
90 + ".asc" => "text/plain",
91 + ".c" => "text/plain",
92 + ".cpp" => "text/plain",
93 + ".log" => "text/plain",
94 + ".conf" => "text/plain",
95 + ".text" => "text/plain",
96 + ".txt" => "text/plain",
97 + ".dtd" => "text/xml",
98 + ".xml" => "text/xml",
99 + ".mpeg" => "video/mpeg",
100 + ".mpg" => "video/mpeg",
101 + ".mov" => "video/quicktime",
102 + ".qt" => "video/quicktime",
103 + ".avi" => "video/x-msvideo",
104 + ".asf" => "video/x-ms-asf",
105 + ".asx" => "video/x-ms-asf",
106 + ".wmv" => "video/x-ms-wmv",
107 + ".bz2" => "application/x-bzip",
108 + ".tbz" => "application/x-bzip-compressed-tar",
109 + ".tar.bz2" => "application/x-bzip-compressed-tar",
110 + "" => "text/plain"
111 + )
112 +
113 + fastcgi.server = ( ".php" =>
114 + ("localhost" =>
115 + ( "socket" => "$CURR_DIR/$WEB_TMP/php.socket",
116 + "bin-path" => "$PHP_DIR/php-cgi -c $CURR_DIR/$WEB/php.ini"
117 +
118 + )
119 + )
120 + )
121 +EOF
122 +
123 + cat > $WEB/php.ini <<EOF
124 + session.save_path ='$CURR_DIR/$WEB_TMP'
125 +EOF
126 +}
127 +
128 +# start_lighttpd
129 +#
130 +# Start or restart daemon lighttpd. If restart, rewrite configuration files.
131 +start_lighttpd () {
132 + if test -f "$WEB_TMP/pid"; then
133 + echo "Instance already running. Restarting..."
134 + stop_lighttpd
135 + fi
136 + config_lighttpd
137 + "$LIGHTTPD_DIR"/lighttpd -f "$WEB"/lighttpd.conf
138 +
139 + if test $? -ne 0 ; then
140 + echo "Could not execute http deamon lighttpd"
141 + exit 1
142 + fi
143 +}
144 +
145 +# stop_lighttpd
146 +#
147 +# Kill daemon lighttpd and removes files and folders associated.
148 +stop_lighttpd () {
149 + test -f "$WEB_TMP/pid" && kill $(cat "$WEB_TMP/pid")
150 + rm -rf "$WEB"
151 +}
152 +
153 +# Create the SQLite database of the MediaWiki. If the database file already
154 +# exists, it will be deleted.
155 +# This script should be runned from the directory where $FILES_FOLDER is
156 +# located.
157 +create_db () {
158 + rm -f "$TMP/$DB_FILE"
159 +
160 + echo "Generating the SQLite database file. It can take some time ..."
161 + # Run the php script to generate the SQLite database file
162 + # with cURL calls.
163 + php "$FILES_FOLDER/$DB_INSTALL_SCRIPT" $(basename "$DB_FILE" .sqlite) \
164 + "$WIKI_ADMIN" "$WIKI_PASSW" "$TMP" "$PORT"
165 +
166 + if [ ! -f "$TMP/$DB_FILE" ] ; then
167 + error "Can't create database file $TMP/$DB_FILE. Try to run ./install-wiki.sh delete first."
168 + fi
169 +
170 + # Copy the generated database file into the directory the
171 + # user indicated.
172 + cp "$TMP/$DB_FILE" "$FILES_FOLDER" ||
173 + error "Unable to copy $TMP/$DB_FILE to $FILES_FOLDER"
174 +}
175 +
176 +# Install a wiki in your web server directory.
177 +wiki_install () {
178 + if test $LIGHTTPD = "true" ; then
179 + start_lighttpd
180 + fi
181 +
182 + SERVER_ADDR=$SERVER_ADDR:$PORT
183 + # In this part, we change directory to $TMP in order to download,
184 + # unpack and copy the files of MediaWiki
185 + (
186 + mkdir -p "$WIKI_DIR_INST/$WIKI_DIR_NAME"
187 + if [ ! -d "$WIKI_DIR_INST/$WIKI_DIR_NAME" ] ; then
188 + error "Folder $WIKI_DIR_INST/$WIKI_DIR_NAME doesn't exist.
189 + Please create it and launch the script again."
190 + fi
191 +
192 + # Fetch MediaWiki's archive if not already present in the TMP directory
193 + cd "$TMP"
194 + if [ ! -f "$MW_VERSION.tar.gz" ] ; then
195 + echo "Downloading $MW_VERSION sources ..."
196 + wget "http://download.wikimedia.org/mediawiki/1.19/mediawiki-1.19.0.tar.gz" ||
197 + error "Unable to download "\
198 + "http://download.wikimedia.org/mediawiki/1.19/"\
199 + "mediawiki-1.19.0.tar.gz. "\
200 + "Please fix your connection and launch the script again."
201 + echo "$MW_VERSION.tar.gz downloaded in `pwd`. "\
202 + "You can delete it later if you want."
203 + else
204 + echo "Reusing existing $MW_VERSION.tar.gz downloaded in `pwd`."
205 + fi
206 + archive_abs_path=$(pwd)/"$MW_VERSION.tar.gz"
207 + cd "$WIKI_DIR_INST/$WIKI_DIR_NAME/" ||
208 + error "can't cd to $WIKI_DIR_INST/$WIKI_DIR_NAME/"
209 + tar xzf "$archive_abs_path" --strip-components=1 ||
210 + error "Unable to extract WikiMedia's files from $archive_abs_path to "\
211 + "$WIKI_DIR_INST/$WIKI_DIR_NAME"
212 + ) || exit 1
213 +
214 + create_db
215 +
216 + # Copy the generic LocalSettings.php in the web server's directory
217 + # And modify parameters according to the ones set at the top
218 + # of this script.
219 + # Note that LocalSettings.php is never modified.
220 + if [ ! -f "$FILES_FOLDER/LocalSettings.php" ] ; then
221 + error "Can't find $FILES_FOLDER/LocalSettings.php " \
222 + "in the current folder. "\
223 + "Please run the script inside its folder."
224 + fi
225 + cp "$FILES_FOLDER/LocalSettings.php" \
226 + "$FILES_FOLDER/LocalSettings-tmp.php" ||
227 + error "Unable to copy $FILES_FOLDER/LocalSettings.php " \
228 + "to $FILES_FOLDER/LocalSettings-tmp.php"
229 +
230 + # Parse and set the LocalSettings file of the user according to the
231 + # CONFIGURATION VARIABLES section at the beginning of this script
232 + file_swap="$FILES_FOLDER/LocalSettings-swap.php"
233 + sed "s,@WG_SCRIPT_PATH@,/$WIKI_DIR_NAME," \
234 + "$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
235 + mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
236 + sed "s,@WG_SERVER@,http://$SERVER_ADDR," \
237 + "$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
238 + mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
239 + sed "s,@WG_SQLITE_DATADIR@,$TMP," \
240 + "$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
241 + mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
242 + sed "s,@WG_SQLITE_DATAFILE@,$( basename $DB_FILE .sqlite)," \
243 + "$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
244 + mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
245 +
246 + mv "$FILES_FOLDER/LocalSettings-tmp.php" \
247 + "$WIKI_DIR_INST/$WIKI_DIR_NAME/LocalSettings.php" ||
248 + error "Unable to move $FILES_FOLDER/LocalSettings-tmp.php" \
249 + "in $WIKI_DIR_INST/$WIKI_DIR_NAME"
250 + echo "File $FILES_FOLDER/LocalSettings.php is set in" \
251 + " $WIKI_DIR_INST/$WIKI_DIR_NAME"
252 +
253 + echo "Your wiki has been installed. You can check it at
254 + http://$SERVER_ADDR/$WIKI_DIR_NAME"
255 +}
256 +
257 +# Reset the database of the wiki and the password of the admin
258 +#
259 +# Warning: This function must be called only in a subdirectory of t/ directory
260 +wiki_reset () {
261 + # Copy initial database of the wiki
262 + if [ ! -f "../$FILES_FOLDER/$DB_FILE" ] ; then
263 + error "Can't find ../$FILES_FOLDER/$DB_FILE in the current folder."
264 + fi
265 + cp "../$FILES_FOLDER/$DB_FILE" "$TMP" ||
266 + error "Can't copy ../$FILES_FOLDER/$DB_FILE in $TMP"
267 + echo "File $FILES_FOLDER/$DB_FILE is set in $TMP"
268 +}
269 +
270 +# Delete the wiki created in the web server's directory and all its content
271 +# saved in the database.
272 +wiki_delete () {
273 + if test $LIGHTTPD = "true"; then
274 + stop_lighttpd
275 + else
276 + # Delete the wiki's directory.
277 + rm -rf "$WIKI_DIR_INST/$WIKI_DIR_NAME" ||
278 + error "Wiki's directory $WIKI_DIR_INST/" \
279 + "$WIKI_DIR_NAME could not be deleted"
280 + # Delete the wiki's SQLite database.
281 + rm -f "$TMP/$DB_FILE" ||
282 + error "Database $TMP/$DB_FILE could not be deleted."
283 + fi
284 +
285 + # Delete the wiki's SQLite database
286 + rm -f "$TMP/$DB_FILE" || error "Database $TMP/$DB_FILE could not be deleted."
287 + rm -f "$FILES_FOLDER/$DB_FILE"
288 + rm -rf "$TMP/$MW_VERSION"
289 +}
contrib/mw-to-git/t/test.config new
+35
@@ -0,0 +1,35 @@
1 +# Name of the web server's directory dedicated to the wiki is WIKI_DIR_NAME
2 +WIKI_DIR_NAME=wiki
3 +
4 +# Login and password of the wiki's admin
5 +WIKI_ADMIN=WikiAdmin
6 +WIKI_PASSW=AdminPass
7 +
8 +# Address of the web server
9 +SERVER_ADDR=localhost
10 +
11 +# SQLite database of the wiki, named DB_FILE, is located in TMP
12 +TMP=/tmp
13 +DB_FILE=wikidb.sqlite
14 +
15 +# If LIGHTTPD is not set to true, the script will use the defaut
16 +# web server running in WIKI_DIR_INST.
17 +WIKI_DIR_INST=/var/www
18 +
19 +# If LIGHTTPD is set to true, the script will use Lighttpd to run
20 +# the wiki.
21 +LIGHTTPD=true
22 +
23 +# The variables below are useful only if LIGHTTPD is set to true.
24 +PORT=1234
25 +PHP_DIR=/usr/bin
26 +LIGHTTPD_DIR=/usr/sbin
27 +WEB=WEB
28 +WEB_TMP=$WEB/tmp
29 +WEB_WWW=$WEB/www
30 +
31 +# The variables below are used by the script to install a wiki.
32 +# You should not modify these unless you are modifying the script itself.
33 +MW_VERSION=mediawiki-1.19.0
34 +FILES_FOLDER=install-wiki
35 +DB_INSTALL_SCRIPT=db_install.php