Blame Identity/Webenv/Moin/create-wikifarm-instance.sh

ef5584
#!/bin/bash
ef5584
# moinmoin-postinstall.sh
ef5584
# MoinMoin 1.5 wikifarm instance installation script.
ef5584
#
ef5584
# The CentOS Artwork SIG.
ef5584
# http://wiki.centos.org/ArtWork
ef5584
ef5584
ef5584
ef5584
# ---------------------------------------------------------
ef5584
# Begin Configuration Section
ef5584
ef5584
# First Wiki Site Name. This is the name shown in the browser 
ef5584
# title bar.
ef5584
WIKISITENAME="mywiki"
ef5584
ef5584
# Your Domain Name (without the trailing slash).
ef5584
MYDOMAIN="localdomain"
ef5584
ef5584
# Name of the Wiki Front Page.
ef5584
WIKIFRONTPAGE="FrontPage"
ef5584
ef5584
# Directory name where the wiki instance will be copied.
ef5584
WIKILOCATION=/var/www/
ef5584
ef5584
# Instance Name.
ef5584
WIKIINSTANCE="wikifarm"
ef5584
ef5584
# Alias name used to access wiki static files. This value
ef5584
# should be different from $WIKIALIAS above.
ef5584
WIKIURLPREFIX="staticfiles"
ef5584
ef5584
# Wiki Super User. Add your WikiUserName here.
ef5584
WIKISUPERUSER="YourName"
ef5584
ef5584
# Do you want to restrict the edit actions ?  (yes|no).
ef5584
# 
ef5584
# a) If `yes' only the wiki superuser, and those listed into
ef5584
# EditGroup and AdminGroup pages will be able to edit pages
ef5584
# on your wiki. After this script is run, we suggest to:
ef5584
#
ef5584
#    1. Register the superuser. For example:
ef5584
#	Login > UserPreferences > Create Profile
ef5584
#    2. Create a EditGroup page.
ef5584
#    3. Add registered user names into EditGroup page.
ef5584
#
ef5584
#       At this point those users listed in EditGroup will
ef5584
#       be able to edit pages on your wiki. If you need to
ef5584
#       grant admin rights to other people then create the
ef5584
#       AdminGroup page and add register users names into
ef5584
#       it. After that they will have admin rights.
ef5584
#
ef5584
#       More info about acl can be found at
ef5584
#       http://localhost/wiki/HelpOnAccessControlLists once
ef5584
#       you have installed the wiki.
ef5584
# 
ef5584
# b) If `no' all users will be able to edit your wiki. Even
ef5584
# if they haven't a user register on it.
ef5584
WIKIRESTRICTEDIT="no"
ef5584
ef5584
# Mail
ef5584
WIKIMAILSMARTHOST=""
ef5584
WIKIMAILFROM=""
ef5584
WIKIMAILLOGIN=""
ef5584
ef5584
# Language.
ef5584
WIKILANGUAGE="en"
ef5584
ef5584
# Basic installation Prefix.
ef5584
PREFIX=/usr
ef5584
ef5584
# Share directory name.
ef5584
SHARE=$PREFIX/share/moin/
ef5584
ef5584
# User & Group used by your web server.
ef5584
USER=apache
ef5584
GROUP=$USER
ef5584
ef5584
# End of Configuration section
ef5584
# ---------------------------------------------------------
ef5584
ef5584
ef5584
# Copy files
ef5584
#
ef5584
# Here we create directories and copy files into the
ef5584
# instance.
ef5584
#
ef5584
cd $WIKILOCATION
ef5584
mkdir -p ${WIKIINSTANCE}/cgi-bin/
ef5584
mkdir -p ${WIKIINSTANCE}/${WIKISITENAME}.${MYDOMAIN}/
ef5584
cp -r ${SHARE}data/* ${WIKIINSTANCE}/${WIKISITENAME}.${MYDOMAIN}/
ef5584
cp -r ${SHARE}data ${WIKIINSTANCE}/
ef5584
cp -r ${SHARE}htdocs $WIKIINSTANCE
ef5584
cp -r ${SHARE}underlay $WIKIINSTANCE
ef5584
cp ${SHARE}server/moin.cgi ${WIKIINSTANCE}/cgi-bin/
ef5584
ef5584
ef5584
# Fix PATH in moin.cgi file
ef5584
#
ef5584
sed -i -e "
ef5584
        s/\/path\/to\/wikiconfig/\/var\/www\/${WIKIINSTANCE}\/cgi-bin/
ef5584
        s/\/path\/to\/farmconfig/\/var\/www\/${WIKIINSTANCE}\/cgi-bin\/farmconfig/
ef5584
        " ${WIKILOCATION}${WIKIINSTANCE}/cgi-bin/moin.cgi
ef5584
ef5584
ef5584
# Apache Configuration
ef5584
#
ef5584
# Here we create the apache configuration file. By default
ef5584
# the wiki will be accessed through the `wiki' apache alias.
ef5584
# Virtual domains are also included but commented by
ef5584
# default.
ef5584
cat <<APACHECONF > /etc/httpd/conf.d/${WIKIINSTANCE}.conf
ef5584
# Apache web server configuration for MoinMoin wiki.
ef5584
#
ef5584
# Created by moinmoin-postinstall-wikifarm.sh.
ef5584
ef5584
<VirtualHost *:80>
ef5584
   ServerName ${WIKISITENAME}.${MYDOMAIN}/
ef5584
   ServerAdmin webmaster@${MYDOMAIN}
ef5584
   ErrorLog logs/wiki-${WIKISITENAME}.error_log
ef5584
   CustomLog logs/wiki-${WIKISITENAME}.access_log common   
ef5584
   Alias /${WIKIURLPREFIX} "${WIKILOCATION}${WIKIINSTANCE}/htdocs/"
ef5584
   Alias /favicon.ico "${WIKILOCATION}${WIKIINSTANCE}/favicon.ico"
ef5584
   ScriptAlias / "${WIKILOCATION}${WIKIINSTANCE}/cgi-bin/moin.cgi/"
ef5584
</VirtualHost>
ef5584
APACHECONF
ef5584
ef5584
# MoinMoin Configuration - farmconfig.py
ef5584
#
ef5584
# Here is a copy and paste from original farmconfig.py file
ef5584
# in the moin-1.5.7-1.el5.rf package. Some additions were
ef5584
# included in the secutiry section to make it configurablen
ef5584
# between 1) an everyone editable wiki 2) a just Superuser,
ef5584
# EditGroup, and AdminGroup editable wiki.
ef5584
cat <<WIKICONFIG > ${WIKIINSTANCE}/cgi-bin/farmconfig.py 
ef5584
# -*- coding: iso-8859-1 -*-
ef5584
# IMPORTANT! This encoding (charset) setting MUST be correct! If you live in a
ef5584
# western country and you don't know that you use utf-8, you probably want to
ef5584
# use iso-8859-1 (or some other iso charset). If you use utf-8 (a Unicode
ef5584
# encoding) you MUST use: coding: utf-8
ef5584
# That setting must match the encoding your editor uses when you modify the
ef5584
# settings below. If it does not, special non-ASCII chars will be wrong.
ef5584
ef5584
"""
ef5584
    MoinMoin - Configuration for a wiki farm
ef5584
ef5584
    If you run a single wiki only, you can keep the "wikis" list "as is"
ef5584
    (it has a single rule mapping all requests to mywiki.py).
ef5584
ef5584
    Note that there are more config options than you'll find in
ef5584
    the version of this file that is installed by default; see
ef5584
    the module MoinMoin.multiconfig for a full list of names and their
ef5584
    default values.
ef5584
ef5584
    Also, the URL http://moinmoin.wikiwikiweb.de/HelpOnConfiguration has
ef5584
    a list of config options.
ef5584
"""
ef5584
ef5584
ef5584
# Wikis in your farm --------------------------------------------------
ef5584
ef5584
# If you run multiple wikis, you need this list of pairs (wikiname, url
ef5584
# regular expression). moin processes that list and tries to match the
ef5584
# regular expression against the URL of this request - until it matches.
ef5584
# Then it loads the <wikiname>.py config for handling that request.
ef5584
ef5584
# Important:
ef5584
#  * the left part is the wikiname enclosed in double quotes
ef5584
#  * the left part must be a valid python module name, so better use only
ef5584
#    lower letters "a-z" and "_". Do not use blanks or "-" there!!!
ef5584
#  * the right part is the url re, use r"..." for it
ef5584
#  * the right part does NOT include "http://" nor "https://" at the beginning
ef5584
#  * in the right part ".*" means "everything". Just "*" does not work like
ef5584
#    for filenames on the shell / commandline, you must use ".*" as it is a RE.
ef5584
#  * in the right part, "^" means "beginning" and "$" means "end"
ef5584
ef5584
wikis = [
ef5584
    # Standalone server needs the port e.g. localhost:8000
ef5584
    # Twisted server can now use the port, too.
ef5584
    
ef5584
    # wikiname,     url regular expression (no protocol)
ef5584
    # ---------------------------------------------------------------
ef5584
    #("mywiki",  r".*"),   # this is ok for a single wiki
ef5584
ef5584
    # for multiple wikis, do something like this:
ef5584
    #("moinmoin",    r"^moinmoin.wikiwikiweb.de/.*$"),
ef5584
    #("moinmaster",  r"^moinmaster.wikiwikiweb.de/.*$"),
ef5584
ef5584
    ("${WIKISITENAME}",		r"^${WIKISITENAME}.${MYDOMAIN}/.*$"),
ef5584
]
ef5584
ef5584
ef5584
# Common configuration for all wikis ----------------------------------
ef5584
ef5584
# Everything that should be configured the same way should go here,
ef5584
# anything else that should be different should go to the single wiki's
ef5584
# config.
ef5584
# In that single wiki's config, we will use the class FarmConfig we define
ef5584
# below as the base config settings and only override what's different.
ef5584
#
ef5584
# In exactly the same way, we first include MoinMoin's Config Defaults here -
ef5584
# this is to get everything to sane defaults, so we need to change only what
ef5584
# we like to have different:
ef5584
ef5584
from MoinMoin.multiconfig import DefaultConfig
ef5584
ef5584
# Now we subclass this DefaultConfig. This means that we inherit every setting
ef5584
# from the DefaultConfig, except those we explicitely define different.
ef5584
ef5584
class FarmConfig(DefaultConfig):
ef5584
ef5584
    # Critical setup  ---------------------------------------------------
ef5584
ef5584
    # Misconfiguration here will render your wiki unusable. Check that
ef5584
    # all directories are accessible by the web server or moin server.
ef5584
ef5584
    # If you encounter problems, try to set data_dir and data_underlay_dir
ef5584
    # to absolute paths.
ef5584
ef5584
    # Where your mutable wiki pages are. You want to make regular
ef5584
    # backups of this directory.
ef5584
    #data_dir = '${WIKILOCATION}${WIKIINSTANCE}/data/'
ef5584
ef5584
    # Where read-only system and help page are. You might want to share
ef5584
    # this directory between several wikis. When you update MoinMoin,
ef5584
    # you can safely replace the underlay directory with a new one. This
ef5584
    # directory is part of MoinMoin distribution, you don't have to
ef5584
    # backup it.
ef5584
    data_underlay_dir = '${WIKILOCATION}${WIKIINSTANCE}/underlay/'
ef5584
ef5584
    # Location of your STATIC files (css/png/js/...) - you must NOT use the
ef5584
    # same for invoking moin.cgi (or, in general, the moin code).
ef5584
    # url_prefix must be '/wiki' for Twisted and standalone servers.
ef5584
    # For CGI, it should match your Apache Alias setting.
ef5584
    url_prefix = '/${WIKIURLPREFIX}'
ef5584
ef5584
ef5584
    # Security ----------------------------------------------------------
ef5584
ef5584
    # This is checked by some rather critical and potentially harmful actions,
ef5584
    # like despam or PackageInstaller action:
ef5584
    #superuser = [u"${WIKISUPERUSER}", ]
ef5584
ef5584
    # IMPORTANT: grant yourself admin rights! replace YourName with
ef5584
    # your user name. See HelpOnAccessControlLists for more help.
ef5584
    # All acl_rights_xxx options must use unicode [Unicode]
ef5584
    #acl_rights_default = u"All:read"
ef5584
    #acl_rights_before  = u"${WIKISUPERUSER}:read,write,delete,revert,admin" \\
ef5584
    #			 u"AdminGroup:read,write,delete,revert,admin" \\
ef5584
    #			 u"EditGroup:read,write,delete,revert"
ef5584
ef5584
    # Link spam protection for public wikis (uncomment to enable).
ef5584
    # Needs a reliable internet connection.
ef5584
    #from MoinMoin.util.antispam import SecurityPolicy
ef5584
ef5584
ef5584
    # Mail --------------------------------------------------------------
ef5584
ef5584
    # Configure to enable subscribing to pages (disabled by default)
ef5584
    # or sending forgotten passwords.
ef5584
ef5584
    # SMTP server, e.g. "mail.provider.com" (None to disable mail)
ef5584
    #mail_smarthost = "${WIKIMAILSMARTHOST}"
ef5584
ef5584
    # The return address, e.g u"Jürgen Wiki <noreply@mywiki.org>" [Unicode]
ef5584
    #mail_from = u"${WIKIMAILFROM}"
ef5584
ef5584
    # "user pwd" if you need to use SMTP AUTH
ef5584
    #mail_login = "${WIKIMAILLOGIN}"
ef5584
ef5584
ef5584
    # User interface ----------------------------------------------------
ef5584
ef5584
    # Add your wikis important pages at the end. It is not recommended to
ef5584
    # remove the default links.  Leave room for user links - don't use
ef5584
    # more than 6 short items.
ef5584
    # You MUST use Unicode strings here, but you need not use localized
ef5584
    # page names for system and help pages, those will be used automatically
ef5584
    # according to the user selected language. [Unicode]
ef5584
    navi_bar = [
ef5584
        # If you want to show your page_front_page here:
ef5584
        #u'%(page_front_page)s',
ef5584
        u'RecentChanges',
ef5584
        u'FindPage',
ef5584
        u'HelpContents',
ef5584
    ]
ef5584
ef5584
ef5584
    # You must use Unicode strings here [Unicode]
ef5584
    page_category_regex = u'^Category[A-Z]'
ef5584
    page_dict_regex = u'[a-z]Dict$'
ef5584
    page_group_regex = u'[a-z]Group$'
ef5584
    page_template_regex = u'[a-z]Template$'
ef5584
ef5584
    # Content options ---------------------------------------------------
ef5584
ef5584
    # Show users hostnames in RecentChanges
ef5584
    show_hosts = 1
ef5584
ef5584
    # Show the interwiki name (and link it to page_front_page) in the Theme,
ef5584
    # nice for farm setups or when your logo does not show the wiki's name.
ef5584
    show_interwiki = 1
ef5584
    #logo_string = u''
ef5584
ef5584
    # Enable graphical charts, requires gdchart.
ef5584
    #chart_options = {'width': 600, 'height': 300}
ef5584
WIKICONFIG
ef5584
ef5584
# Copy First Wiki Configuration file.
ef5584
#
ef5584
cat <<WIKICONFIG > ${WIKIINSTANCE}/cgi-bin/${WIKISITENAME}.py
ef5584
# -*- coding: iso-8859-1 -*-
ef5584
# IMPORTANT! This encoding (charset) setting MUST be correct! If you live in a
ef5584
# western country and you don't know that you use utf-8, you probably want to
ef5584
# use iso-8859-1 (or some other iso charset). If you use utf-8 (a Unicode
ef5584
# encoding) you MUST use: coding: utf-8
ef5584
# That setting must match the encoding your editor uses when you modify the
ef5584
# settings below. If it does not, special non-ASCII chars will be wrong.
ef5584
ef5584
"""
ef5584
This is a sample config for a wiki that is part of a wiki farm and uses
ef5584
farmconfig for common stuff. Here we define what has to be different from
ef5584
the farm's common settings.
ef5584
"""
ef5584
ef5584
# we import the FarmConfig class for common defaults of our wikis:
ef5584
from farmconfig import FarmConfig
ef5584
ef5584
# now we subclass that config (inherit from it) and change what's different:
ef5584
class Config(FarmConfig):
ef5584
ef5584
    # basic options (you normally need to change these)
ef5584
    sitename = u'${WIKISITENAME}' # [Unicode]
ef5584
    interwikiname = '${WIKISITENAME}'
ef5584
ef5584
    # name of entry page / front page [Unicode], choose one of those:
ef5584
ef5584
    # a) if most wiki content is in a single language
ef5584
    #page_front_page = u"MyStartingPage"
ef5584
ef5584
    # b) if wiki content is maintained in many languages
ef5584
    page_front_page = u"${WIKIFRONTPAGE}"
ef5584
ef5584
    logo_string = u'MoinMoin Logo'
ef5584
ef5584
    # The default theme anonymous or new users get
ef5584
    theme_default = 'modern'
ef5584
ef5584
    # Language options --------------------------------------------------
ef5584
    
ef5584
    # See http://moinmoin.wikiwikiweb.de/ConfigMarket for configuration in 
ef5584
    # YOUR language that other people contributed.
ef5584
    
ef5584
    # The main wiki language, set the direction of the wiki pages
ef5584
    language_default = '${WIKILANGUAGE}'
ef5584
ef5584
    data_dir = '${WIKILOCATION}${WIKIINSTANCE}/${WIKISITENAME}.${MYDOMAIN}/'
ef5584
WIKICONFIG
ef5584
ef5584
# Uncomment some options in the farmconfig.py file if ...
ef5584
if [ "$WIKISUPERUSER" != "" ]; then
ef5584
ef5584
	sed -i -e '
ef5584
		/#superuser/s/#//
ef5584
		s/YourName/'$WIKISUPERUSER'/' ${WIKIINSTANCE}/cgi-bin/farmconfig.py
ef5584
ef5584
fi
ef5584
ef5584
if [ "$WIKIRESTRICTEDIT" = "yes" ]; then
ef5584
ef5584
	sed -i -r -e '
ef5584
		/#acl_rights_before/s/#//
ef5584
		/#acl_rights_default/s/#//
ef5584
		/#[\t ]*u"EditGroup/s/#//
ef5584
		/#[\t ]*u"AdminGroup/s/#//' ${WIKIINSTANCE}/cgi-bin/farmconfig.py
ef5584
ef5584
fi
ef5584
ef5584
if [ "$WIKIMAILSMARTHOST" != "" ]; then
ef5584
ef5584
	sed -i -e '
ef5584
		/#mail_smarthost/s/#//' ${WIKIINSTANCE}/cgi-bin/farmconfig.py
ef5584
ef5584
fi
ef5584
ef5584
if [ "$WIKIMAILFROM" != "" ];then
ef5584
ef5584
	sed -i -e '
ef5584
		/#mail_from/s/#//' ${WIKIINSTANCE}/cgi-bin/farmconfig.py
ef5584
ef5584
fi
ef5584
ef5584
if [ "$WIKIMAILLOGIN" != "" ];then
ef5584
 
ef5584
	sed -i -e '
ef5584
		/#mail_login/s/#//' ${WIKIINSTANCE}/cgi-bin/farmconfig.py
ef5584
ef5584
fi
ef5584
ef5584
# File Permissions
ef5584
#
ef5584
# Here we set the file permissons to the created and copied
ef5584
# files.
ef5584
#
ef5584
chown -R $USER.$GROUP $WIKIINSTANCE
ef5584
chmod -R ug=rwx $WIKIINSTANCE
ef5584
chmod -R o-rwx $WIKIINSTANCE
ef5584
cd $WIKIINSTANCE
ef5584
chown -R $USER.$GOUP cgi-bin 
ef5584
chmod -R ug=rx cgi-bin
ef5584
chmod -R o-rwx cgi-bin
ef5584
ef5584
ef5584
# Last Message
ef5584
#
ef5584
less <
ef5584
ef5584
------------------------------------------------------------
ef5584
	     *** WIKIFARM INSTANCE CREATED *** 
ef5584
------------------------------------------------------------
ef5584
ef5584
   To finish the installation do the following:
ef5584
ef5584
	1. Restart the Web Server (service httpd restart)
ef5584
ef5584
	2. Open your browser and try the address:
ef5584
	http://${WIKISITENAME}.${MYDOMAIN}/"
ef5584
ef5584
------------------------------------------------------------
ef5584
	      *** HOWTO CREATE NEW WIKIS  *** 
ef5584
------------------------------------------------------------
ef5584
ef5584
  To create new wikis into the farm check the following
ef5584
  steps:
ef5584
ef5584
  	1. Update your farmconfig.py file adding the new
ef5584
	wiki definition. Ex.
ef5584
ef5584
	("mywiki2",    r"^mywiki2.${MYDOMAIN}/.*$"),
ef5584
ef5584
	2. Create a directory to store your new wiki data.
ef5584
	Ex.
ef5584
	
ef5584
	mkdir ${WIKILOCATION}${WIKIINSTANCE}/mywiki2.${MYDOMAIN}/
ef5584
ef5584
	3. Copy the content of data directory into the
ef5584
	recently created directory. Ex.: 
ef5584
ef5584
	cp -rv ${WIKILOCATION}${WIKIINSTANCE}/data/* \\
ef5584
	${WIKILOCATION}${WIKIINSTANCE}/mywiki2.${MYDOMAIN}/
ef5584
ef5584
	4. Create a copy of your cgi-bin/mywiki.py into
ef5584
	cgi-bin/mywiki2.py. Then modify mywiki2 with the new
ef5584
	and specific configuration, related to the second
ef5584
	wiki. Ex.:
ef5584
ef5584
	sitename = u'mywiki2' # [Unicode]
ef5584
	interwikiname = 'mywiki2'
ef5584
	data_dir = '/var/www/wikifarm/mywiki2.${MYDOMAIN}/'
ef5584
		
ef5584
ef5584
------------------------------------------------------------
ef5584
		   *** GET TROUBLES ? ***
ef5584
------------------------------------------------------------
ef5584
ef5584
   If you get some error when try to reach your wiki through
ef5584
   the web browser, check the following:
ef5584
ef5584
	1. Add in your DNS or HOSTS file a record to your
ef5584
	wiki address. For example, if your domain is
ef5584
	${MYDOMAIN} and your wiki is in a host with the ip
ef5584
	192.168.0.1, and you want a wiki address like
ef5584
	http://${WIKISITENAME}.${MYDOMAIN}/ it is possible
ef5584
	that you should add a related CNAME record into your
ef5584
	DNS to your new wiki address, something like the
ef5584
	following:
ef5584
ef5584
   	${WIKISITENAME}.${MYDOMAIN}.	IN CNAME	${MYDOMAINl}.
ef5584
ef5584
	Remeber to do a 'service named restart' after
ef5584
	changes.
ef5584
ef5584
	2. Check Virtual Domain configuration in your Apache
ef5584
	server. It is possible that it is disabled so enable
ef5584
	it by uncomenting a line like the following:
ef5584
ef5584
	NameVirtualHost *:80
ef5584
ef5584
	3. It is possible that you want something in
ef5584
	http://${MYDOMAIN}/ other than the error that
ef5584
	sometimes appears there after you get your wiki
ef5584
	working into virtual domains. So you should create a
ef5584
	virtual domain for that address too and change the
ef5584
	DocumentoRoot param to wherever you want to load at
ef5584
	that moment.
ef5584
ef5584
	If you are still in troubles, you can write to:
ef5584
	<alain.reguera@gmail.com>. 
ef5584
	
ef5584
	Other way ...
ef5584
	
ef5584
   Enjoy your installed wikifarm :).
ef5584
ef5584
LASTMESSAGE