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

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