|
|
| (10 intermediate revisions by one user not shown) |
| Line 1: |
Line 1: |
| − | <pre>
| + | {{Project |
| − | #! /bin/bash
| + | |Current=No |
| | + | |Participants=Jeroen De Dauw, |
| | + | |Short description=Bash script for updating the wiki codebase |
| | + | }} |
| | + | [[User:Jeroen_De_Dauw|Newfag]] bash script for updating the hackerspace wiki's from a local install. |
| | | | |
| − | # set -x
| + | [https://github.com/JeroenDeDauw/scripts/blob/master/svn-hackerspace.sh Script on github] |
| | | | |
| − | echo "Initiating update of hackerspace wiki(s)..."
| + | Similar script inspired (and probably a bunch less crappy :) by this one [https://source.hacker.lu/projects/scripts/repository/revisions/a3c999b7df829cc44da24b4fc63733d1517c68ca/changes/wikiupdate/update-wikis.sh here]. |
| − | | + | |
| − | | + | |
| − | | + | |
| − | # Update local code first
| + | |
| − | #svnup.sh
| + | |
| − | | + | |
| − | | + | |
| − | | + | |
| − | # Svn export
| + | |
| − | echo "Preparing export directories..."
| + | |
| − | rm -r -f ~/export
| + | |
| − | mkdir ~/export
| + | |
| − | mkdir ~/export/extensions
| + | |
| − | | + | |
| − | | + | |
| − | | + | |
| − | echo "Initiating svn export..."
| + | |
| − | | + | |
| − | cd ~/root
| + | |
| − | svn export phase3 ~/export/phase3
| + | |
| − | | + | |
| − | cd ~/root/extensions
| + | |
| − | | + | |
| − | extensions=( Validator Maps SemanticMediaWiki SemanticDrilldown SemanticMaps SemanticForms SemanticResultFormats '''Awesomeness''' SemanticCompoundQueries ParserFunctions Widgets RSS googleAnalytics Cite ConfirmEdit LiquidThreads )
| + | |
| − | | + | |
| − | for i in ${extensions[@]}; do
| + | |
| − | if [ -d $i ]; then
| + | |
| − | svn export $i ~/export/extensions/$i;
| + | |
| − | fi
| + | |
| − | done
| + | |
| − | | + | |
| − | echo "... svn export finished."
| + | |
| − | | + | |
| − | | + | |
| − | | + | |
| − | in_array(){
| + | |
| − | local i
| + | |
| − | needle=$1
| + | |
| − | shift 1
| + | |
| − | # array() undefined
| + | |
| − | [ -z "$1" ] && return 1
| + | |
| − | for i in $*
| + | |
| − | do
| + | |
| − | [ "$i" == "$needle" ] && return 0
| + | |
| − | done
| + | |
| − | return 1
| + | |
| − | }
| + | |
| − | | + | |
| − | get_changes(){
| + | |
| − | echo "Choose the stuff to update:"
| + | |
| − | select change in ${changes[@]} ${extensions[@]}; do
| + | |
| − | if in_array $change ${changes[@]} ${extensions[@]}; then
| + | |
| − | break
| + | |
| − | fi
| + | |
| − | done
| + | |
| − | }
| + | |
| − | | + | |
| − | get_space(){
| + | |
| − | echo "Choose the space:"
| + | |
| − | select space in "all" ${spaces[@]}; do
| + | |
| − | if in_array $space "all" ${spaces[@]}; then
| + | |
| − | break
| + | |
| − | fi
| + | |
| − | done
| + | |
| − | }
| + | |
| − | | + | |
| − | spaces=( ghent brussels )
| + | |
| − | | + | |
| − | get_space
| + | |
| − | | + | |
| − | changes=( all core extensions )
| + | |
| − | | + | |
| − | get_changes
| + | |
| − | | + | |
| − | | + | |
| − | | + | |
| − | # Confirmation by authentication
| + | |
| − | echo "You are about to change $change for $space wiki"
| + | |
| − | ssh-add ~/.ssh/hackerspacebe.openssh
| + | |
| − | | + | |
| − | | + | |
| − | | + | |
| − | # Clear temp folder
| + | |
| − | tempfolder="~/temp"
| + | |
| − | echo "Preparing temporary directory..."
| + | |
| − | | + | |
| − | | + | |
| − | | + | |
| − | | + | |
| − | # Normalize changes list
| + | |
| − | if [ $change == "all" ]; then
| + | |
| − | changes=( "core" ${extensions[@]} )
| + | |
| − | elif [ $change == "extensions" ]; then
| + | |
| − | changes=( ${extensions[@]} )
| + | |
| − | elif [ $change == "core" ]; then
| + | |
| − | changes=( "core" )
| + | |
| − | else
| + | |
| − | changes=( $change )
| + | |
| − | fi
| + | |
| − | | + | |
| − | | + | |
| − | | + | |
| − | # Upload all stuff the should be changed to temp dir
| + | |
| − | for i in ${changes[@]}; do
| + | |
| − | if [ $i == "core" ]; then
| + | |
| − | echo "Uploading MediaWiki core to temp dir..."
| + | |
| − | | + | |
| − | | + | |
| − | else
| + | |
| − | echo "Uploading extension $i to temp dir..."
| + | |
| − | ssh -i ~/.ssh/hackerspacebe.openssh hackerspace@hackerspace.be "mkdir -p $tempfolder/extensions/$i"
| + | |
| − | scp -r -i ~/ .ssh/ hackerspacebe.openssh ~/ export/ extensions/ $i [email protected]:$tempfolder/ extensions | + | |
| − | fi
| + | |
| − | done
| + | |
| − | | + | |
| − | | + | |
| − | | + | |
| − | # Normalize spaces list
| + | |
| − | if [ $space != "all" ]; then
| + | |
| − | spaces=( $space )
| + | |
| − | fi
| + | |
| − | | + | |
| − | # Space path info
| + | |
| − | declare -A options
| + | |
| − | options[ghent]="smw"
| + | |
| − | options[brussels]="smw"
| + | |
| − | | + | |
| − | # Apply the changes for all spaces
| + | |
| − | for space in ${spaces[@]}; do
| + | |
| − | echo "Starting update of $space wiki..."
| + | |
| − | | + | |
| − | wikifolder="~/$space/www/${options[$space]}"
| + | |
| − | oldfolder="~/$space/www/smw-old"
| + | |
| − | | + | |
| − | # Make a backup
| + | |
| − | echo " Creating backup of $wikifolder at $oldfolder..."
| + | |
| − | ssh -i ~/.ssh/hackerspacebe.openssh [email protected] "rm -r -f $oldfolder; mkdir -p $oldfolder; cp -r $wikifolder/* $oldfolder" | + | |
| − | | + | |
| − | for change in ${changes[@]}; do
| + | |
| − | if [ $change == "core" ]; then
| + | |
| − | echo " Updating MediaWiki core..."
| + | |
| − | ssh -i ~/.ssh/hackerspacebe.openssh [email protected] "cp -r -f $tempfolder/phase3/* $wikifolder" | + | |
| − | else
| + | |
| − | echo " Updating extension $change..."
| + | |
| − | ssh -i ~/.ssh/hackerspacebe.openssh [email protected] "rm -r -f $wikifolder/extensions/$change; cp -r $tempfolder/extensions/$change* $wikifolder/extensions/$change" | + | |
| − | fi
| + | |
| − | done
| + | |
| − | | + | |
| − | echo "... $space wiki updated."
| + | |
| − | done
| + | |
| − | | + | |
| − | | + | |
| − | | + | |
| − | echo "... all wiki's have been updated."</pre>
| + | |
bash script for updating the hackerspace wiki's from a local install.