#! /bin/sh
path="$1"
if dirname "$1" | grep '^[^/]' > /dev/null || test ! -d `dirname "$1"`; then
cat >&2 <<EOF
$0: invalid parameter
Usage: $0 PATH
PATH is the path of the instance's wiki root
The parent directories must exist.
EOF
fi
if ! test -e "$path"; then
mkdir "$path"
fi
if ! test -e "$path"/LocalSettings.php; then
cp -a "@datadir@"/mediawiki/mw-config "$path"
fi
if ! test -e "$path"/images; then
mkdir "$path"/images
ln -s "@datadir@"/mediawiki/images/.htaccess "$path"/images
chown apache:apache "$path"/images
fi
for f in index.php api.php extensions img_auth.php includes languages load.php \
maintenance opensearch_desc.php profileinfo.php \
resources serialized skins thumb_handler.php thumb.php vendor; do
rm -f "$path"/$f
ln -s "@datadir@"/mediawiki/$f "$path"/$f
done