gpunktschmitz / mediawiki-updater Goto Github PK
View Code? Open in Web Editor NEWscript to: backup mediawiki database, files, download latest version, update files and database
License: Creative Commons Zero v1.0 Universal
script to: backup mediawiki database, files, download latest version, update files and database
License: Creative Commons Zero v1.0 Universal
Hi,
i try to update and adapt your mediawiki-update script to my wiki installation (I can also share the updates at the end.). But I don't really understand how you compare the version numbers. So how do the following two functions (vercomp and testvercomp) work? I always get an error message.
#get releases from https://github.com/wikimedia/mediawiki/releases.atom
LATEST_RELEASES=$(${WGETEXECUTABLE} -q -O- "https://github.com/wikimedia/mediawiki/releases.atom" | ${GREPEXECUTABLE} -o -P '<title>[^"]*' | ${SEDEXECUTABLE} "s/<title>//g" | ${SEDEXECUTABLE} "s/<\/title>//g")
for RELEASE in ${LATEST_RELEASES}; do
if [[ "${RELEASE}" =~ [0-9] ]]; then
#skip if release candidate
if ! ${GREPEXECUTABLE} "\-rc\." <<< ${RELEASE} &>/dev/null; then
if testvercomp ${RELEASE} "<" ${LATEST_RELEASE}; then
LATEST_RELEASE=${RELEASE}
fi
fi
fi
done
echo "latest release found: ${LATEST_RELEASE}"
#check if latest version is newer
if testvercomp ${LATEST_RELEASE} ">" ${INSTALLED_VERSION}; then
echo "no newer version found on the interweb -> exiting"
exit 1
fi
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}
testvercomp () {
vercomp $1 $3
case $? in
0) op='=';;
1) op='>';;
2) op='<';;
esac
if [[ $op != $2 ]]
then
return 0
echo 0
else
return 1
echo 1
fi
}
currently installed version: 1.35.0
test.sh: line 49: ((: 10#wmf: value too great for base (error token is "10#wmf")
test.sh: line 53: ((: 10#wmf: value too great for base (error token is "10#wmf")
test.sh: line 49: ((: 10#1 > 10#wmf: value too great for base (error token is "10#wmf")
test.sh: line 53: ((: 10#1 < 10#wmf: value too great for base (error token is "10#wmf")
test.sh: line 49: ((: 10#1 > 10#wmf: value too great for base (error token is "10#wmf")
test.sh: line 53: ((: 10#1 < 10#wmf: value too great for base (error token is "10#wmf")
test.sh: line 49: ((: 10#1 > 10#wmf: value too great for base (error token is "10#wmf")
test.sh: line 53: ((: 10#1 < 10#wmf: value too great for base (error token is "10#wmf")
test.sh: line 49: ((: 10#1 > 10#wmf: value too great for base (error token is "10#wmf")
test.sh: line 53: ((: 10#1 < 10#wmf: value too great for base (error token is "10#wmf")
test.sh: line 49: ((: 10#1 > 10#wmf: value too great for base (error token is "10#wmf")
test.sh: line 53: ((: 10#1 < 10#wmf: value too great for base (error token is "10#wmf")
latest release found: wmf-1.36.0-wmf.31-testing:
test.sh: line 49: ((: 10#wmf: value too great for base (error token is "10#wmf")
test.sh: line 53: ((: 10#wmf: value too great for base (error token is "10#wmf")
Hi!
I just tested your script. And it still works for me.
There was however a deprecation warning:
NOTE: Do not run maintenance scripts directly, use maintenance/run.php instead!
Running scripts directly has been deprecated in MediaWiki 1.40.
It may not work for some (or any) scripts in the future.
In order to correct the script only one line has to be changed:
#execute update script
244 ${PHPEXECUTABLE} ${MEDIAWIKIDIR}/maintenance/run.php update.php
Thank you very much for sharing your script!
Dear Guenther,
I found your script few days ago searching to ... automate few mediawiki upgrades and it motivates me to bring some suggestions and adapt to my use cases and generic solutions.
Allow me to attach the current script which shows most changes in itself and as comments in code.
I just saw that you updated your current script, thanks again ;-), I will have a look and continue to improve it if I can (I am not a Shell script expert).
mediawiki-updater v2017-11-21.sh.txt
Pleased to contribute ...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.