Merge lp:~bellini666/charms/precise/mediawiki/server_address_and_suffix into lp:charms/mediawiki

Proposed by Thiago Bellini
Status: Merged
Merged at revision: 78
Proposed branch: lp:~bellini666/charms/precise/mediawiki/server_address_and_suffix
Merge into: lp:charms/mediawiki
Diff against target: 110 lines (+39/-7)
3 files modified
config.yaml (+8/-0)
hooks/config-changed (+29/-5)
hooks/db-relation-changed (+2/-2)
To merge this branch: bzr merge lp:~bellini666/charms/precise/mediawiki/server_address_and_suffix
Reviewer Review Type Date Requested Status
Marco Ceppi (community) Approve
Review via email: mp+219044@code.launchpad.net

Commit message

Allow to remove the "/mediawiki" suffix and to change the wgServer config

Description of the change

Some changes we made on our server to allow reverse proxying and to remove the "/mediawiki" suffix.

The changes keep compatility with the actual behaviour, so it should not break or change anything to anyone, unless they change the configuration.

Also, everything is working fine, as we have 2 services deployed (2 hosted wikis) with those modifications.

To post a comment you must log in.
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

LGTM! Thank you for contributing this fix back up stream, we appreciate your contributions!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2013-12-13 19:39:03 +0000
3+++ config.yaml 2014-05-09 18:29:32 +0000
4@@ -11,10 +11,18 @@
5 description: URL to fetch logo from
6 default: ''
7 type: string
8+ server_address:
9+ description: The server url to set "$wgServer". Useful for reverse proxies
10+ default: ''
11+ type: string
12 admins:
13 description: Admin users to create, user:pass
14 default: ''
15 type: string
16+ use_suffix:
17+ default: true
18+ type: boolean
19+ description: If we should put '/mediawiki' suffix on the url
20 debug:
21 default: false
22 type: boolean
23
24=== modified file 'hooks/config-changed'
25--- hooks/config-changed 2014-01-20 05:33:44 +0000
26+++ hooks/config-changed 2014-05-09 18:29:32 +0000
27@@ -5,6 +5,21 @@
28 skin=`config-get skin`
29 logo=`config-get logo`
30 admins=`config-get admins`
31+server_address=`config-get server_address`
32+
33+if [ "`config-get --format json use_suffix`" = "true" ] ; then
34+ # Change root from /usr/share/mediawiki /to var/www
35+ sed -ie 's/\/usr\/share\/mediawiki/\/var\/www/' \
36+ /etc/apache2/sites-enabled/000-default
37+ imagepath="/var/www/images"
38+ scriptpath="/mediawiki"
39+else
40+ # Change root from /var/www to /usr/share/mediawiki
41+ sed -ie 's/\/var\/www/\/usr\/share\/mediawiki/' \
42+ /etc/apache2/sites-enabled/000-default
43+ imagepath="/usr/share/mediawiki/images"
44+ scriptpath=""
45+fi
46
47 if [ -n "$logo" ] ; then
48 wgLogo=$(
49@@ -12,11 +27,12 @@
50 cd $dldir
51 if wget $logo ; then
52 file=`ls`
53- mkdir -p /var/www/images
54- mv $file /var/www/images
55- chmod a+rx /var/www/images
56- chgrp www-data /var/www/images/$file
57- chmod g+r /var/www/images/$file
58+ mkdir -p $imagepath
59+ mv $file $imagepath
60+ chmod a+rx $imagepath
61+ chgrp www-data $imagepath/$file
62+ chmod g+r $imagepath/$file
63+
64 echo "/images/$file"
65 fi
66 cd /
67@@ -36,9 +52,14 @@
68 <?php
69 \$wgSitename="${wikiname}";
70 \$wgDefaultSkin="${skin}";
71+\$wgScriptPath="${scriptpath}";
72 \$wgLogo=$wgLogo;
73 EOF
74
75+if [ -n "$server_address" ] ; then
76+ echo "\$wgServer=\"${server_address}\";" >> $new_file
77+fi
78+
79 if [ "`config-get --format json debug`" = "true" ] ; then
80 cat >> $new_file <<EOF
81 \$wgDebugLogFile = "$CHARM_DIR/debug.log";
82@@ -72,3 +93,6 @@
83 fi
84 done
85 fi
86+
87+# Make sure any use_suffix changes are applied
88+service apache2 reload
89
90=== modified file 'hooks/db-relation-changed'
91--- hooks/db-relation-changed 2012-06-28 00:01:05 +0000
92+++ hooks/db-relation-changed 2014-05-09 18:29:32 +0000
93@@ -59,8 +59,6 @@
94 ## Uncomment this to disable output compression
95 # $wgDisableOutputCompression = true;
96
97-include dirname(__FILE__).'/config-settings.php';
98-
99 ## The URL base path to the directory containing the wiki;
100 ## defaults for all runtime URL paths are based off of this.
101 ## For more information on customizing the URLs please see:
102@@ -68,6 +66,8 @@
103 $wgScriptPath = "/mediawiki";
104 $wgScriptExtension = ".php";
105
106+include dirname(__FILE__).'/config-settings.php';
107+
108 ## UPO means: this is also a user preference option
109
110 $wgEnableEmail = true;

Subscribers

People subscribed via source and target branches

to all changes: