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

ef5584
#!/bin/bash
ef5584
# moinmoin-postinstall.sh
ef5584
# MoinMoin 1.5 instance installation script.
ef5584
#
ef5584
# The CentOS Artwork SIG.
ef5584
# http://projects.centos.org/trac/artwork/
ef5584
ef5584
ef5584
ef5584
# ---------------------------------------------------------
ef5584
# Begin Configuration Section
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. This is the name used to create the directory under
ef5584
# $WIKILOCATION and some others internal links.
ef5584
printf "Instance Name [wiki]      : "
ef5584
read WIKIINSTANCE
ef5584
if [ ! $WIKIINSTANCE ];then
ef5584
	WIKIINSTANCE='wiki'
ef5584
fi
ef5584
ef5584
# Instance name should be uniq.
ef5584
if [ -d ${WIKILOCATION}/$WIKIINSTANCE ];then
ef5584
	echo "The instance '$WIKIINSTANCE' already exists."
ef5584
	exit;
ef5584
fi
ef5584
ef5584
# Site Name. This is the name shown in the browser title bar.
ef5584
printf "Site Name [My Wiki]       : "
ef5584
read WIKISITENAME
ef5584
if [ ! $WIKINAME ];then
ef5584
	WIKINAME='My Wiki'
ef5584
fi
ef5584
ef5584
# Alias Name used to access the wiki. By default we access
ef5584
# the wiki with the form: `http://localhost/wiki'. If you
ef5584
# want to acces the wiki with other alias name then change
ef5584
# this value and fill it with the name you want to access
ef5584
# your wiki.
ef5584
WIKIALIAS=$WIKIINSTANCE
ef5584
ef5584
# Alias name used to access wiki static files. This value
ef5584
# should be different from $WIKIALIAS above.
ef5584
WIKIURLPREFIX=${WIKIINSTANCE}_staticfiles
ef5584
ef5584
# Wiki Super User. Add your WikiUserName here.
ef5584
printf "Site superuser [YourName] : "
ef5584
read WIKISUPERUSER
ef5584
if [ ! $WIKISUPERUSER ];then
ef5584
	WIKISUPERUSER='YourName'
ef5584
fi
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
echo "Creating instance ..."
ef5584
cd $WIKILOCATION
ef5584
mkdir $WIKIINSTANCE
ef5584
cp -R ${SHARE}data $WIKIINSTANCE
ef5584
cp -R ${SHARE}htdocs $WIKIINSTANCE
ef5584
cp -R ${SHARE}underlay $WIKIINSTANCE
ef5584
mkdir ${WIKIINSTANCE}/cgi-bin
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 create-wiki-instance.sh.
ef5584
# `echo date`
ef5584
ef5584
#
ef5584
# By Alias.
ef5584
#
ef5584
Alias /${WIKIURLPREFIX} "${WIKILOCATION}${WIKIINSTANCE}/htdocs/"
ef5584
<Directory "${WIKILOCATION}${WIKIINSTANCE}/htdocs/">
ef5584
   Order deny,allow
ef5584
   Allow from all
ef5584
</Directory>
ef5584
ef5584
ScriptAlias /${WIKIINSTANCE} "${WIKILOCATION}${WIKIINSTANCE}/cgi-bin/moin.cgi"
ef5584
<Directory "${WIKILOCATION}${WIKIINSTANCE}/cgi-bin">
ef5584
   Order deny,allow
ef5584
   Allow from all
ef5584
</Directory>
ef5584
ef5584
ef5584
# By Virtual Domains.
ef5584
#
ef5584
#<VirtualHost *:80>
ef5584
#   ServerName wiki.example.tld
ef5584
#   ServerAdmin webmaster@example.tld
ef5584
#   ErrorLog logs/wiki.example.tld-error_log
ef5584
#   CustomLog logs/wiki.example.tld-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
ef5584
# MoinMoin Configuration - wikiconfig.py
ef5584
#
ef5584
# Here is a copy and paste from original wikiconfig.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/wikiconfig.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 single wiki
ef5584
ef5584
    If you run a single wiki only, you can omit the farmconfig.py config
ef5584
    file and just use wikiconfig.py - it will be used for every request
ef5584
    we get in that case.
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
    ** Please do not use this file for a wiki farm. Use the sample file 
ef5584
    from the wikifarm directory instead! **
ef5584
"""
ef5584
ef5584
from MoinMoin.multiconfig import DefaultConfig
ef5584
ef5584
ef5584
class Config(DefaultConfig):
ef5584
ef5584
    # Wiki identity ----------------------------------------------------
ef5584
ef5584
    # Site name, used by default for wiki name-logo [Unicode]
ef5584
    sitename = u'${WIKISITENAME}'
ef5584
ef5584
    # Wiki logo. You can use an image, text or both. [Unicode]
ef5584
    # For no logo or text, use '' - the default is to show the sitename.
ef5584
    # See also url_prefix setting below!
ef5584
    logo_string = u'MoinMoin Logo'
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
    # The interwiki name used in interwiki links
ef5584
    #interwikiname = 'UntitledWiki'
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
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'SiteNavigation',
ef5584
        u'HelpContents',
ef5584
    ]
ef5584
ef5584
    # The default theme anonymous or new users get
ef5584
    theme_default = 'modern'
ef5584
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
    # 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_form_regex = u'[a-z]Form$'
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
    # Enable graphical charts, requires gdchart.
ef5584
    #chart_options = {'width': 600, 'height': 300}
ef5584
WIKICONFIG
ef5584
ef5584
#
ef5584
# Uncomment some options in the wikiconfig.py file if ...
ef5584
#
ef5584
ef5584
if [ "$WIKISUPERUSER" != "" ]; then
ef5584
ef5584
	sed -i -e '
ef5584
		/#superuser/s/#//
ef5584
		s/YourName/'$WIKISUPERUSER'/' ${WIKIINSTANCE}/cgi-bin/wikiconfig.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/wikiconfig.py
ef5584
ef5584
fi
ef5584
ef5584
if [ "$WIKIMAILSMARTHOST" != "" ]; then
ef5584
ef5584
	sed -i -e '
ef5584
		/#mail_smarthost/s/#//' ${WIKIINSTANCE}/cgi-bin/wikiconfig.py
ef5584
ef5584
fi
ef5584
ef5584
if [ "$WIKIMAILFROM" != "" ];then
ef5584
ef5584
	sed -i -e '
ef5584
		/#mail_from/s/#//' ${WIKIINSTANCE}/cgi-bin/wikiconfig.py
ef5584
ef5584
fi
ef5584
ef5584
if [ "$WIKIMAILLOGIN" != "" ];then
ef5584
 
ef5584
	sed -i -e '
ef5584
		/#mail_login/s/#//' ${WIKIINSTANCE}/cgi-bin/wikiconfig.py
ef5584
ef5584
fi
ef5584
ef5584
ef5584
# File Permissions
ef5584
#
ef5584
# Here we set the file permissons to the created and copied
ef5584
# files.
ef5584
#
ef5584
echo 'Setting permissions ...'
ef5584
chown -R $USER.$GROUP $WIKIINSTANCE
ef5584
chmod -R 750 $WIKIINSTANCE
ef5584
ef5584
ef5584
# Last Message
ef5584
echo '---------------------------------------------'
ef5584
echo ' *** The wiki instance had been created! *** '
ef5584
echo '---------------------------------------------'
ef5584
echo 'To finish the installation do the following:'
ef5584
echo "  1. Restart the Web Server (service httpd restart)"
ef5584
echo "  2. Open your browser and try the address: http://localhost/${WIKIALIAS}"
ef5584
echo '  3. Enjoy your installed wiki :).'
ef5584
echo ''