Extension:EmailToWiki/get EmailToWiki to extensions wmf-shared.sh
From Biowikifarm Metawiki
#!/bin/bash
######################################################
# Warning: run this only as script not via 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
# and it needs sudo to be executed
######################################################
################################### settings start
# settings may be adjusted to your needs:
usr_share_wiki_path="/usr/share/mediawiki27wmf"
usr_share_extension_path="${usr_share_wiki_path}/extensions-simple-features"
################################### settings end
# 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
# get external https://www.mediawiki.org/wiki/Extension:EmailToWiki
if ! [[ -d ~/temp ]] ; then
echo "# Extension:EmailToWiki: create ~/temp"
mkdir --parents ~"/temp"
fi
echo "# Extension:EmailToWiki: 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 "# Extension:EmailToWiki: 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 "# Extension:EmailToWiki: 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 ]]
echo "# Extension:EmailToWiki: add empty EmailToWiki.tmp directory "
mkdir --parents ~/temp/extensions-master/MediaWiki/EmailToWiki/EmailToWiki.tmp
fi
if ! [[ -e ~/temp/extensions-master/MediaWiki/EmailToWiki/EmailToWiki.log ]]
echo "# Extension:EmailToWiki: add empty EmailToWiki.log file "
touch ~/temp/extensions-master/MediaWiki/EmailToWiki/EmailToWiki.log
fi
if [[ -e ~/temp/extensions-master/MediaWiki/EmailToWiki/EmailToWiki.conf.sample ]]
echo "# Extension:EmailToWiki: 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 "# Extension:EmailToWiki: 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 "# Extension:EmailToWiki: 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}"
else
unzip -l OrganicDesign_extensions_master.zip | grep --ignore-case 'emailtowiki'
echo "# Extension:EmailToWiki: structure of ZIP archive is different from expected"
echo "# Extension:EmailToWiki: check above (skipped copy extension)"
fi