# $Id: smeserver-mediawiki.spec,v 1.6 2008/06/02 16:10:02 slords Exp $ # Authority: ber_die # Name: Dietmar Berteld %define name smeserver-mediawiki %define version 1.6.10 %define release 9 Summary: Mediawiki Web Application for SME Server 7.x based on Mediawiki 1.6.10 Name: %{name} Version: %{version} Release: %{release}%{?dist} License: GPL Group: /Web/Applications Source: %{name}-%{version}.tar.gz Patch0: smeserver-mediawiki-1.6.10-1.patch URL: http://mediawiki.org/ BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot BuildArch: noarch Requires: e-smith-base, e-smith-release >= 7 BuildRequires: e-smith-devtools %description This RPM is an unofficial addon for the SME Server 7.x. The target audience is the Linux/E-smith administrator who wants to add Wikipedia-SW. Mediawiki is a very popular Wiki and is used by the wikipedia-project. After installation open your webbrowser your local site http://your_e-smith-server_adress/wiki %changelog * Mon May 12 2008 Dietmar Berteld> 1.6.10-9 - Disabing automatic creation of SME groups. No idea to synchronise them to mediawiki groups. * Mon May 12 2008 Dietmar Berteld> 1.6.10-8 - Adding PwAuth-function, SME users can login with their SME passwords Automatic creation of a few default mw_groups and list them in the configuration file as well so admins only need to add users to the proper groups in the server-manager * Thu Feb 26 2008 Dietmar Berteld> - [1.6.10-7] Fixed httpd-settings for local access only * Thu Oct 23 2007 Dietmar Berteld> - [1.6.10-6] Fixed automated uninstall issue for MySQL-DB and MySQL-user * Fri Oct 19 2007 Dietmar Berteld> - [1.6.10-5] Fixed short URL's - Improved Apache template for better security - Improved integration in SME (PublicAccess local/global - global) * Wed Oct 10 2007 Sylvain Gomez - [1.6.10-4] Fixed short URL's Fixed Apache restarting at the wrong time while uninstalling Added missing MySQL User Added automatic lang detection at install stage Changed sme.png logo * Wed Sep 05 2007 Dietmar Berteld - [1.6.10-3] Simpler method to create MySQL-Datebase Using short URL's * Wed Apr 25 2007 Dietmar Berteld - [1.6.10-2] Security Improvements (template, MySQL, directory-rights) Thanks for the help to Sylvain Gomez * Thu Apr 12 2007 Dietmar Berteld - [1.6.10-1] Initial version %prep rm -rf $RPM_BUILD_ROOT %setup %patch0 -p1 %build %install rm -rf $RPM_BUILD_ROOT (cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT) rm -f %{name}-%{version}-filelist /sbin/e-smith/genfilelist $RPM_BUILD_ROOT > %{name}-%{version}-filelist %clean rm -rf $RPM_BUILD_ROOT %pre UPDATE=$(ls /opt | grep -c mediawiki) case $UPDATE in 0) echo "Installing MediaWiki... Please wait!" ;; *) echo "Updating MediaWiki... Please wait!" mkdir -p /opt/MW_RPM_BACKUP cd /opt echo "Backing up installation files..." tar -czf /opt/MW_RPM_BACKUP/mediawiki.tar.gz mediawiki echo "Backing up MySQL database..." mysqldump mediawiki > /opt/MW_RPM_BACKUP/mediawiki.sql /sbin/e-smith/db configuration show mediawiki > /opt/MW_RPM_BACKUP/config.txt ;; esac %post # General Information /etc/e-smith/events/actions/initialize-default-databases # General Information APP=MediaWiki URL=wiki WORKDIR=/root INSTALLDIR=/usr/share/doc/mediawiki-1.6.10/Sources HTMLDIR=/opt/mediawiki MYSQLDB=mediawiki MYSQLUSER=mediawikiuser MYSQLPASS=$(/sbin/e-smith/db configuration getprop mediawiki DbPassword) DOMAIN=$(/sbin/e-smith/db configuration get DomainName) SRVNAME=$(/sbin/e-smith/db configuration get SystemName) UPDATE=$(ls /opt | grep -c mediawiki) grep "LANG=" /etc/sysconfig/i18n > lang1 sed -e 's/LANG="//g' lang1 > lang2 sed -e 's/"//g' lang2 > lang LANG=$(cat lang) rm -rf lang* #Untar application echo "Decompressing files..." mkdir -p $HTMLDIR tar xzf $INSTALLDIR/mediawiki-1.6.10.tar.gz -C /opt case $UPDATE in 0) mv -f /opt/mediawiki-1.6.10/* $HTMLDIR ;; *) cp -ufR /opt/mediawiki-1.6.10/* $HTMLDIR --reply=yes ;; esac rm -rf /opt/mediawiki-1.6.10 cp $INSTALLDIR/sme.* $HTMLDIR/skins/common/images #Prepare config settings sed 's.mediawikipassword.'$MYSQLPASS'.g' $INSTALLDIR/LocalSettings.php > $HTMLDIR/LocalSettings.php sed "s/mydomain/$DOMAIN/g" $HTMLDIR/LocalSettings.php > $HTMLDIR/LocalSettings2.php case "$LANG" in de_DE) sed 's.$wgLanguageCode = "en";.$wgLanguageCode = "de";.g' $HTMLDIR/LocalSettings2.php > $HTMLDIR/LocalSettings.php ;; es_ES) sed 's.$wgLanguageCode = "en";.$wgLanguageCode = "es";.g' $HTMLDIR/LocalSettings2.php > $HTMLDIR/LocalSettings.php ;; fr_FR) sed 's.$wgLanguageCode = "en";.$wgLanguageCode = "fr";.g' $HTMLDIR/LocalSettings2.php > $HTMLDIR/LocalSettings.php ;; it_IT) sed 's.$wgLanguageCode = "en";.$wgLanguageCode = "it";.g' $HTMLDIR/LocalSettings2.php > $HTMLDIR/LocalSettings.php ;; *) sed 's.$wgLanguageCode = "en";.$wgLanguageCode = "en";.g' $HTMLDIR/LocalSettings2.php > $HTMLDIR/LocalSettings.php ;; esac rm $HTMLDIR/LocalSettings2.php cp $INSTALLDIR/PwAuthPlugin.php $HTMLDIR/extensions/PwAuthPlugin.php #Creating SME-Groups for MediaWiki (disabled) #/sbin/e-smith/db accounts set mw_read group #/sbin/e-smith/db accounts setprop mw_read Description "MediaWiki Read" #/sbin/e-smith/db accounts set mw_edit group #/sbin/e-smith/db accounts setprop mw_edit Description "MediaWiki Edit" #/sbin/e-smith/db accounts set mw_createpage group #/sbin/e-smith/db accounts setprop mw_createpage Description "MediaWiki Create Page" #/sbin/e-smith/db accounts set mw_createtalk group #/sbin/e-smith/db accounts setprop mw_createtalk Description "MediaWiki Create Talk" #/sbin/e-smith/signal-event group-create #Changing some rights chmod 644 $HTMLDIR/extensions/PwAuthPlugin.php chown -R root:root $HTMLDIR chown root:www $HTMLDIR/images chown root:www $HTMLDIR/LocalSettings.php chmod 775 $HTMLDIR/images chmod 440 $HTMLDIR/LocalSettings.php #Creating DataBase echo "MySQL installation:" case $UPDATE in 0) echo "Creating MySQL User and DataBase..." mysqladmin -u root create $MYSQLDB mysql $MYSQLDB < $INSTALLDIR/$MYSQLDB.sql mysql -u root -e "SET PASSWORD FOR $MYSQLUSER@localhost = PASSWORD( '$MYSQLPASS' ) " mysqladmin flush-privileges ;; *) echo "Fixing MySQL rights..." mysql -u root -e "SET PASSWORD FOR $MYSQLUSER@localhost = PASSWORD( '$MYSQLPASS' ) " mysqladmin flush-privileges ;; esac # Rebuilding Wiki language menus php $HTMLDIR/maintenance/rebuildMessages.php --rebuild echo "Applying modifications to services..." # Uncomment the PwAuth-function sed 's.#!..g' $HTMLDIR/LocalSettings.php > $HTMLDIR/LocalSettings2.php mv $HTMLDIR/LocalSettings2.php $HTMLDIR/LocalSettings.php /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf /usr/local/bin/svc -h /service/httpd-e-smith echo "-------------------------------------------------------------------------------" case $UPDATE in 0) echo "$APP Installation completed." echo "Reminder:" echo "- Website open globally" echo "- go to http://$DOMAIN/$URL" echo "- Usernames are identical with SME users" echo "- Passwords are identical with SME passwords" echo "- MediaWiki admin = SME admin" ;; *) echo "$APP update completed." echo "Reminder:" echo "- The old install was backed up and can be found in /opt/MW_RPM_BACKUP" echo " PLEASE MOVE THIS DIRECTORY TO A SAFE PLACE!!!" echo "- Website open globally" echo "- go to http://$DOMAIN/$URL" echo "- Usernames are identical with SME users" echo "- Passwords are identical with SME passwords" echo "- MediaWiki admin = SME admin" ;; esac echo "-------------------------------------------------------------------------------" echo "Following DB parameters are allowed:" echo " # config setprop $MYSQLDB HTTPS on/off" echo " # config setprop $MYSQLDB PublicAccess local/global" echo " " echo "Don't forget to apply modifications with following commands:" echo " # expand-template /etc/httpd/conf/httpd.conf" echo " # svc -h /service/httpd-e-smith" echo " " echo "For more details, see http://wiki.contribs.org/Mediawiki" echo "-------------------------------------------------------------------------------" %preun INSTALLDIR=/usr/share/doc/mediawiki-1.6.10/Sources if [ $1 = 0 ] ; then mv $INSTALLDIR/DO_NOT_USE_OR_DELETE/MW-Full-Uninstall.sh /root/ fi %postun if [ $1 = 0 ] ; then echo "Restarting services..." /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf /usr/local/bin/svc -h /service/httpd-e-smith echo " " echo "Uninstallation finished!" echo "If you want to completly remove it (installation files and MySQL user+database)" echo "please issue the following command at the prompt:" echo "# sh /root/MW-Full-Uninstall.sh" fi %files -f %{name}-%{version}-filelist %defattr(-,root,root)