Skip to content

Instantly share code, notes, and snippets.

@kartikm
Last active June 8, 2019 07:06
Show Gist options
  • Save kartikm/7c7442e8c112a4698747ed15c526e935 to your computer and use it in GitHub Desktop.
Save kartikm/7c7442e8c112a4698747ed15c526e935 to your computer and use it in GitHub Desktop.
Make it easier to install CX, Translate, MW or MLEB on Labs or localhost
#!/bin/bash
# Make it easier to install CX, Translate, MW or MLEB on Labs or localhost
function DI {
clear
echo "Let's install required packages first!"
sudo apt install apache2 apache2-utils libapache2-mod-php7.0 php7.0 php7.0-curl php7.0-json php7.0-mbstring php7.0-mysql php7.0-xml php7.0-readline php7.0-opcache php7.0-cli php-mysql mariadb-server mariadb-common default-mysql-server composer git
}
function MWI {
git clone https://gerrit.wikimedia.org/r/mediawiki/core
cd "$MWL/core" || exit
composer update --no-dev
cd "$MWL/core/skins" || exit
git clone https://gerrit.wikimedia.org/r/mediawiki/skins/Vector
cd "$MWL" || exit
}
function MWAI {
echo "It seems MediaWiki is already installed! Updating it now!"
cd "$MWL/core" || exit
git checkout master
git reset --hard origin/master
git pull
composer update --no-dev
cd "$MWL/core/skins/Vector" || exit
git pull
cd "$MWL" || exit
}
function MWTI {
echo "It seems MediaWiki is already installed! Updating it now!"
cd "$MWL/core" || exit
git checkout master
git reset --hard origin/master
git pull
git checkout -b "$tag" "$tag"
composer update --no-dev
cd "$MWL/core/skins/Vector" || exit
git checkout master
git reset --hard origin/master
git pull
git branch -D "$tag"
git checkout -b "$tag" "$tag"
cd "$MWL" || exit
}
function EM {
for dir in "$MWLE"/*/
do
cd "$dir" || exit
git checkout master
git reset --hard origin/master
git pull
git submodule update
echo "Extensions are updated to master!"
done
}
function ET {
for dir in $MWLE
do
cd "$dir" || exit
git checkout master
git reset --hard origin/master
git pull
git branch -D "$tag"
git checkout -b "$tag" "$tag"
echo "Extensions are updated to $tag!"
done
}
function EMI {
if [ "$tag" = "master" ];
then
EM
else
ET
fi
}
function MWMI {
if [ "$tag" = "master" ];
then
if [ ! -d "core" ];
then
MWI
else
MWAI
fi
else
if [ ! -d "core" ];
then
MWI
else
MWTI
fi
fi
}
echo "Enter location of MediaWiki installation. eg. /var/www"
read -r MWL
MWLE=$MWL/core/extensions
echo "Which tag you want to use? eg. master, 1.32.1,.."
read -r tag
echo "Which setup you want to install:"
options=("MW" "CX" "Translate" "MLEB" "Quit")
select opt in "${options[@]}"
do
case $opt in
"MW")
DI
cd "$MWL" || exit
echo "Installing Mediawiki in $MWL now.."
MWMI
echo "Now, go to instance URL and follow the instructions!"
break
;;
"CX")
clear
echo "Let's install CX!"
echo "Once MediaWiki and extensions are installed, you need to setup ContentTranslation database to finish setup"
echo "See ContentTranslation/sql directory"
DI
cd "$MWL" || exit
echo "Installing Mediawiki in $MWL now.."
MWMI
echo "Installing extensions now.."
cd "$MWLE" || exit
if [ ! -d "ContentTranslation" ];
then
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/BetaFeatures
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/ContentTranslation
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GuidedTour
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/UniversalLanguageSelector
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
cd VisualEditor && git submodule init && git submodule update && cd ..
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
EMI
else
echo "It seems CX is already installed! Updating it to now!"
EMI
fi
echo "Now, go to instance URL and follow the instructions!"
break
;;
"Translate")
clear
echo "Let's install Transate!"
DI
cd "$MWL" || exit
echo "Installing Mediawiki in $MWL now.."
MWMI
cd "$MWLE" || exit
if [ ! -d "Transate" ];
then
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/UniversalLanguageSelector
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Translate
EMI
else
echo "It seems Translate is already installed! Updating it to now!"
EMI
fi
echo "Now, go to instance URL and follow the instructions!"
break
;;
"MLEB")
clear
echo "Let's install MLEB! It contains Babel, CleanChanges, cldr, LocalisationUpdate, Translate, UniversalLanguageSelector extensions."
DI
cd "$MWL" || exit
echo "Installing Mediawiki in $MWL now.."
MWMI
echo "Installing extensions now.."
cd "$MWLE" || exit
if [ ! -d "cldr" ];
then
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Babel
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/cldr
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CleanChanges
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LocalisationUpdate
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Translate
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/UniversalLanguageSelector
EMI
else
echo "It seems Translate is already installed! Updating it to now!"
EMI
fi
echo "Now, go to instance URL and follow the instructions!"
break
;;
"Quit")
echo "Bye!"
break
;;
*) echo "Invalid option $REPLY";;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment