]> gerrit.simantics Code Review - simantics/platform.git/blob - releng/doc/tag-wiki.sh
Fixed release engineering target platform preparation instructions
[simantics/platform.git] / releng / doc / tag-wiki.sh
1 #!/bin/bash
2
3 major=$1
4 minor=$2
5 www=$3
6 #www=/var/www/https-www.simantics.org
7 wikiname=$4
8 #wikiname=wiki
9 wikidb=$5
10 wikidbuser=$6
11
12 releasewww=${www}/${major}.${minor}
13
14 srcdb=${wikidb}
15 tgtdb=${wikidb}_${major}_${minor}
16
17 echo "Release version: $major.$minor"
18
19 function myexecute() {
20         echo "Sending to mysql using database $1: $2"
21         echo $2 | mysql -u root -p $1
22 }
23
24 # dump wiki db to file
25 echo "Dumping $srcdb"
26 mysqldump -p ${srcdb} > ${tgtdb}.dump
27 # load wiki db from file to name ${wikidb}_x_y, where x_y are major.minor version numbers
28 # add privileges for ${wikidbuser} to ${wikidb}_x_y
29 echo "Importing ${tgtdb}"
30 cat > import_${major}_${minor}.sql <<EOF
31 drop database if exists ${tgtdb};
32 create database ${tgtdb};
33 grant all privileges on $tgtdb.* to '${wikidbuser}'@'localhost';
34 grant all privileges on $tgtdb.* to '${wikidbuser}'@'%';
35 use $tgtdb;
36 source ${tgtdb}.dump;
37 EOF
38 myexecute $srcdb "source import_${major}_${minor}.sql;"
39
40 # copy /var/www/https-www.simantics.org/wiki to /var/www/https-www.simantics.org/x.y/wiki
41 echo "Copying wiki www-directory $www to $releasewww"
42 mkdir -p ${releasewww}
43 cp -a ${www}/${wikiname} ${releasewww}/${wikiname}
44
45 # change /var/www/https-www.simantics.org/x.y/wiki/LocalSettings.php to use simwikidb_x_y
46 echo "Fixing released wiki settings"
47 cat $www/$wikiname/LocalSettings.php | sed -e "s/$srcdb/$tgtdb/" |sed -e "s/\/${wikiname}/\/$major\.$minor\/${wikiname}/"> $releasewww/${wikiname}/LocalSettings.php
48 echo '$wgReadOnly = "Released version, no further changes allowed.";' >> $releasewww/${wikiname}/LocalSettings.php
49