-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmw-install-extension
executable file
·57 lines (50 loc) · 2.03 KB
/
mw-install-extension
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
if [ -z $1 ]; then
echo "No name of a MW extension was specified. Exiting." >&2
exit 1
fi
if [ "$(whoami)" != 'www-data' ]; then
echo "The script needs to be run as the webserver's user (assumed to be 'www-data'). Exiting." >&2
exit 1
fi
MW_VER=${2-'1.35'}
echo "No Mediawiki version has been specified. Assuming $MW_VER" >&2
#This script assumes the directory structure specification of WikiDo
MW_BASE_DIR=$(readlink --canonicalize-existing '../')
if [[ "$(head -1 $MW_BASE_DIR/RELEASE-NOTES-$MW_VER)" != "= MediaWiki $MW_VER =" ]]; then
echo "Mediawiki's instalation base could not be detected. This script must be run in the extensions directory of a MW instance. Exiting." >&2
exit 1
else
WIKIDO_EXT_REPO=$(readlink --canonicalize-existing "$MW_BASE_DIR/../extra/extensions")
if [ $? != 0 ]; then
echo "Extensions' codebase directory was not found! Exiting." >&2
exit 1
else
echo "Extensions' codebase directory is: $WIKIDO_EXT_REPO" >&2
echo "Working Extensions directory is: $MW_BASE_DIR/extensions" >&2
fi
fi
if [ ! -d "$MW_BASE_DIR/extensions/$1" ]; then
if [ ! -d "$WIKIDO_EXT_REPO/$1-REL${MW_VER/./_}-"* ]; then
echo "Downloading $1, since it didn't exist in local repository..." >&2
$(dirname "$0")/mw-get-extension.py --mw-version "$MW_VER" --target-dir "$WIKIDO_EXT_REPO" "$1" >&2
error_code=$?
if [ $error_code -ne 0 ]; then
echo "Something wrong happened while downloading $1. Last error code was $error_code. Check the output above. Exiting." >&2
exit 1
else
echo "done."
fi
else
echo "Skipping downloading $1. It already exists in the repository." >&2
fi
echo -n "$1 is being linked from the extensions' repository to the working extensions directory..." >&2
ln --symbolic --no-target-directory $(ls -d "$WIKIDO_EXT_REPO/$1-"*) "$MW_BASE_DIR/extensions/$1" && echo "done"
else
if [ -h "$MW_BASE_DIR/extensions/$1" ]; then
echo "Skipping $1, since it is already installed." >&2
else
echo "Skipping $1, since seems to have been bundled with MW $MW_VER." >&2
fi
fi
echo "Completed." >&2