Extension:EmailToWiki/get EmailToWiki to extensions wmf-shared.sh
From Biowikifarm Metawiki
< Extension:EmailToWiki
Revision as of 14:10, 7 July 2016 by Andreas Plank (Talk | contribs) (fix checking target directory)
#!/bin/bash
######################################################
# Warning: run this only as script not as
# copy and paste in console!!
# Documentation: the script will download the extension
# into your home directory, extract it, creates some files
# set user rights according to https://www.mediawiki.org/wiki/Extension:EmailToWiki#Installation
# it needs sudo
######################################################
###################################
usr_share_wiki_path="/usr/share/mediawiki26"
usr_share_extension_path="${usr_share_wiki_path}/extensions-simple-features"
usr_share_extension_path="${usr_share_wiki_path}/extensions-rich-features"
# prompt User
CAN_I_RUN_SUDO=$(sudo -n uptime 2>&1|grep "load"|wc -l)
if [[ ! $CAN_I_RUN_SUDO -gt 0 ]]; then
echo "# "
echo -e "# The script was stopped because it \e[1mrequires sudo\e[0m running without prompt. It will fail to work now. Please run any sudo"
echo "# action before to have sudo action available without password prompt, e.g. list directory as sudo"
echo -e "# \e[1msudo ls\e[0m"
echo "# "
exit 1
fi
echo "# Extension:EmailToWiki"
if ! [[ -d ${usr_share_extension_path} ]];then
echo "# Target directory '${usr_share_extension_path}' does not exist (exit now)"
exit 1
fi
if [[ -d ${usr_share_extension_path}/EmailToWiki ]];then
echo "# found existing directory ${usr_share_extension_path}/EmailToWiki. Please remove or use it (exit now)"
exit 1
fi
# get external https://www.mediawiki.org/wiki/Extension:EmailToWiki
if ! [[ -d ~/temp ]] ; then
echo "# create ~/temp"
mkdir --parents ~"/temp"
fi
echo "# download https://github.com/OrganicDesign/extensions/archive/master.zip"
cd ~/temp && wget https://github.com/OrganicDesign/extensions/archive/master.zip --output-document=OrganicDesign_extensions_master.zip
echo "# unzip OrganicDesign_extensions_master.zip"
unzip OrganicDesign_extensions_master.zip
if [[ -d ~/temp/extensions-master/MediaWiki/EmailToWiki/ ]] ; then
cd ~/temp/extensions-master/MediaWiki/EmailToWiki/
echo "# add README.biowikifarm to extension"
echo "###################################" > README.biowikifarm
echo "# This is a non MediaWiki extension see: https://www.mediawiki.org/wiki/Extension:EmailToWiki#Installation" >> README.biowikifarm
echo "# It was downloaded and extracted manually via wget https://github.com/OrganicDesign/extensions/archive/master.zip " >> README.biowikifarm
echo "# wget https://github.com/OrganicDesign/extensions/archive/master.zip " >> README.biowikifarm
echo "# and copied manually to this shared wiki directory. If this extension does not function properly after setup" >> README.biowikifarm
echo "# deactivate and remove it. The configuration file EmailToWiki.conf should be owned by root (see documentation)" >> README.biowikifarm
echo "# not by www-data, it must be readable by the perlscript and cron. (AP 2016-07-07)" >> README.biowikifarm
if ! [[ -d ~/temp/extensions-master/MediaWiki/EmailToWiki/EmailToWiki.tmp ]];then
echo "# add empty EmailToWiki.tmp directory "
mkdir --parents ~/temp/extensions-master/MediaWiki/EmailToWiki/EmailToWiki.tmp
fi
if ! [[ -e ~/temp/extensions-master/MediaWiki/EmailToWiki/EmailToWiki.log ]];then
echo "# add empty EmailToWiki.log file "
touch ~/temp/extensions-master/MediaWiki/EmailToWiki/EmailToWiki.log
fi
if [[ -e ~/temp/extensions-master/MediaWiki/EmailToWiki/EmailToWiki.conf.sample ]];then
echo "# copy sample configuration to EmailToWiki.conf file "
cp --interactive --preserve ~/temp/extensions-master/MediaWiki/EmailToWiki/EmailToWiki.conf.sample ~/temp/extensions-master/MediaWiki/EmailToWiki/EmailToWiki.conf
fi
echo "# set ownership to www-data, but EmailToWiki.conf to root"
sudo chown www-data:www-data --recursive ~/temp/extensions-master/MediaWiki/EmailToWiki
sudo chown root:root ~/temp/extensions-master/MediaWiki/EmailToWiki/EmailToWiki.conf
echo "# copy ~/temp/extensions-master/MediaWiki/EmailToWiki to ${usr_share_extension_path}"
sudo -u www-data -g www-data cp --preserve --recursive ~/temp/extensions-master/MediaWiki/EmailToWiki "${usr_share_extension_path}"
echo "# Consult https://www.mediawiki.org/wiki/Extension:EmailToWiki for further readings."
echo "# (done)"
else
unzip -l OrganicDesign_extensions_master.zip | grep --ignore-case 'emailtowiki'
echo "# structure of ZIP archive is different from expected"
echo "# check above (exit now)"
exit 1
fi