Blame Extras/Moin/create-wiki-instance.sh

4c79b5
#!/bin/bash
4c79b5
# moinmoin-postinstall.sh
4c79b5
# MoinMoin 1.5 instance installation script.
4c79b5
#
4c79b5
# The CentOS Artwork SIG.
4c79b5
# http://projects.centos.org/trac/artwork/
4c79b5
4c79b5
4c79b5
4c79b5
# ---------------------------------------------------------
4c79b5
# Begin Configuration Section
4c79b5
4c79b5
# Name of the Wiki Front Page.
4c79b5
WIKIFRONTPAGE="FrontPage"
4c79b5
4c79b5
# Directory name where the wiki instance will be copied.
4c79b5
WIKILOCATION=/var/www/
4c79b5
4c79b5
# Instance Name. This is the name used to create the directory under
4c79b5
# $WIKILOCATION and some others internal links.
4c79b5
printf "Instance Name [wiki]      : "
4c79b5
read WIKIINSTANCE
4c79b5
if [ ! $WIKIINSTANCE ];then
4c79b5
	WIKIINSTANCE='wiki'
4c79b5
fi
4c79b5
4c79b5
# Instance name should be uniq.
4c79b5
if [ -d ${WIKILOCATION}/$WIKIINSTANCE ];then
4c79b5
	echo "The instance '$WIKIINSTANCE' already exists."
4c79b5
	exit;
4c79b5
fi
4c79b5
4c79b5
# Site Name. This is the name shown in the browser title bar.
4c79b5
printf "Site Name [My Wiki]       : "
4c79b5
read WIKISITENAME
4c79b5
if [ ! $WIKINAME ];then
4c79b5
	WIKINAME='My Wiki'
4c79b5
fi
4c79b5
4c79b5
# Alias Name used to access the wiki. By default we access
4c79b5
# the wiki with the form: `http://localhost/wiki'. If you
4c79b5
# want to acces the wiki with other alias name then change
4c79b5
# this value and fill it with the name you want to access
4c79b5
# your wiki.
4c79b5
WIKIALIAS=$WIKIINSTANCE
4c79b5
4c79b5
# Alias name used to access wiki static files. This value
4c79b5
# should be different from $WIKIALIAS above.
4c79b5
WIKIURLPREFIX=${WIKIINSTANCE}_staticfiles
4c79b5
4c79b5
# Wiki Super User. Add your WikiUserName here.
4c79b5
printf "Site superuser [YourName] : "
4c79b5
read WIKISUPERUSER
4c79b5
if [ ! $WIKISUPERUSER ];then
4c79b5
	WIKISUPERUSER='YourName'
4c79b5
fi
4c79b5
4c79b5
# Do you want to restrict the edit actions ?  (yes|no).
4c79b5
# 
4c79b5
# a) If `yes' only the wiki superuser, and those listed into
4c79b5
# EditGroup and AdminGroup pages will be able to edit pages
4c79b5
# on your wiki. After this script is run, we suggest to:
4c79b5
#
4c79b5
#    1. Register the superuser. For example:
4c79b5
#	Login > UserPreferences > Create Profile
4c79b5
#    2. Create a EditGroup page.
4c79b5
#    3. Add registered user names into EditGroup page.
4c79b5
#
4c79b5
#       At this point those users listed in EditGroup will
4c79b5
#       be able to edit pages on your wiki. If you need to
4c79b5
#       grant admin rights to other people then create the
4c79b5
#       AdminGroup page and add register users names into
4c79b5
#       it. After that they will have admin rights.
4c79b5
#
4c79b5
#       More info about acl can be found at
4c79b5
#       http://localhost/wiki/HelpOnAccessControlLists once
4c79b5
#       you have installed the wiki.
4c79b5
# 
4c79b5
# b) If `no' all users will be able to edit your wiki. Even
4c79b5
# if they haven't a user register on it.
4c79b5
WIKIRESTRICTEDIT="no"
4c79b5
4c79b5
# Mail
4c79b5
WIKIMAILSMARTHOST=""
4c79b5
WIKIMAILFROM=""
4c79b5
WIKIMAILLOGIN=""
4c79b5
4c79b5
# Language.
4c79b5
WIKILANGUAGE="en"
4c79b5
4c79b5
# Basic installation Prefix.
4c79b5
PREFIX=/usr
4c79b5
4c79b5
# Share directory name.
4c79b5
SHARE=$PREFIX/share/moin/
4c79b5
4c79b5
# User & Group used by your web server.
4c79b5
USER=apache
4c79b5
GROUP=$USER
4c79b5
4c79b5
# End of Configuration section
4c79b5
# ---------------------------------------------------------
4c79b5
4c79b5
4c79b5
# Copy files
4c79b5
#
4c79b5
# Here we create directories and copy files into the
4c79b5
# instance.
4c79b5
#
4c79b5
echo "Creating instance ..."
4c79b5
cd $WIKILOCATION
4c79b5
mkdir $WIKIINSTANCE
4c79b5
cp -R ${SHARE}data $WIKIINSTANCE
4c79b5
cp -R ${SHARE}htdocs $WIKIINSTANCE
4c79b5
cp -R ${SHARE}underlay $WIKIINSTANCE
4c79b5
mkdir ${WIKIINSTANCE}/cgi-bin
4c79b5
cp ${SHARE}server/moin.cgi ${WIKIINSTANCE}/cgi-bin
4c79b5
4c79b5
4c79b5
# Fix PATH in moin.cgi file
4c79b5
#
4c79b5
sed -i -e "
4c79b5
        s/\/path\/to\/wikiconfig/\/var\/www\/${WIKIINSTANCE}\/cgi-bin/
4c79b5
        s/\/path\/to\/farmconfig/\/var\/www\/${WIKIINSTANCE}\/cgi-bin\/farmconfig/
4c79b5
        " ${WIKILOCATION}${WIKIINSTANCE}/cgi-bin/moin.cgi
4c79b5
4c79b5
4c79b5
# Apache Configuration
4c79b5
#
4c79b5
# Here we create the apache configuration file. By default
4c79b5
# the wiki will be accessed through the `wiki' apache alias.
4c79b5
# Virtual domains are also included but commented by
4c79b5
# default.
4c79b5
cat <<APACHECONF > /etc/httpd/conf.d/${WIKIINSTANCE}.conf
4c79b5
# Apache web server configuration for MoinMoin wiki.
4c79b5
#
4c79b5
# Created by create-wiki-instance.sh.
4c79b5
# `echo date`
4c79b5
4c79b5
#
4c79b5
# By Alias.
4c79b5
#
4c79b5
Alias /${WIKIURLPREFIX} "${WIKILOCATION}${WIKIINSTANCE}/htdocs/"
4c79b5
<Directory "${WIKILOCATION}${WIKIINSTANCE}/htdocs/">
4c79b5
   Order deny,allow
4c79b5
   Allow from all
4c79b5
</Directory>
4c79b5
4c79b5
ScriptAlias /${WIKIINSTANCE} "${WIKILOCATION}${WIKIINSTANCE}/cgi-bin/moin.cgi"
4c79b5
<Directory "${WIKILOCATION}${WIKIINSTANCE}/cgi-bin">
4c79b5
   Order deny,allow
4c79b5
   Allow from all
4c79b5
</Directory>
4c79b5
4c79b5
4c79b5
# By Virtual Domains.
4c79b5
#
4c79b5
#<VirtualHost *:80>
4c79b5
#   ServerName wiki.example.tld
4c79b5
#   ServerAdmin webmaster@example.tld
4c79b5
#   ErrorLog logs/wiki.example.tld-error_log
4c79b5
#   CustomLog logs/wiki.example.tld-access_log common   
4c79b5
#   Alias /${WIKIURLPREFIX} "${WIKILOCATION}${WIKIINSTANCE}/htdocs/"
4c79b5
#   Alias /favicon.ico "${WIKILOCATION}${WIKIINSTANCE}/favicon.ico"
4c79b5
#   ScriptAlias / "${WIKILOCATION}${WIKIINSTANCE}/cgi-bin/moin.cgi/"
4c79b5
#</VirtualHost>
4c79b5
APACHECONF
4c79b5
4c79b5
4c79b5
# MoinMoin Configuration - wikiconfig.py
4c79b5
#
4c79b5
# Here is a copy and paste from original wikiconfig.py file
4c79b5
# in the moin-1.5.7-1.el5.rf package. Some additions were
4c79b5
# included in the secutiry section to make it configurablen
4c79b5
# between 1) an everyone editable wiki 2) a just Superuser,
4c79b5
# EditGroup, and AdminGroup editable wiki.
4c79b5
cat <<WIKICONFIG > ${WIKIINSTANCE}/cgi-bin/wikiconfig.py 
4c79b5
# -*- coding: iso-8859-1 -*-
4c79b5
# IMPORTANT! This encoding (charset) setting MUST be correct! If you live in a
4c79b5
# western country and you don't know that you use utf-8, you probably want to
4c79b5
# use iso-8859-1 (or some other iso charset). If you use utf-8 (a Unicode
4c79b5
# encoding) you MUST use: coding: utf-8
4c79b5
# That setting must match the encoding your editor uses when you modify the
4c79b5
# settings below. If it does not, special non-ASCII chars will be wrong.
4c79b5
4c79b5
"""
4c79b5
    MoinMoin - Configuration for a single wiki
4c79b5
4c79b5
    If you run a single wiki only, you can omit the farmconfig.py config
4c79b5
    file and just use wikiconfig.py - it will be used for every request
4c79b5
    we get in that case.
4c79b5
4c79b5
    Note that there are more config options than you'll find in
4c79b5
    the version of this file that is installed by default; see
4c79b5
    the module MoinMoin.multiconfig for a full list of names and their
4c79b5
    default values.
4c79b5
4c79b5
    Also, the URL http://moinmoin.wikiwikiweb.de/HelpOnConfiguration has
4c79b5
    a list of config options.
4c79b5
4c79b5
    ** Please do not use this file for a wiki farm. Use the sample file 
4c79b5
    from the wikifarm directory instead! **
4c79b5
"""
4c79b5
4c79b5
from MoinMoin.multiconfig import DefaultConfig
4c79b5
4c79b5
4c79b5
class Config(DefaultConfig):
4c79b5
4c79b5
    # Wiki identity ----------------------------------------------------
4c79b5
4c79b5
    # Site name, used by default for wiki name-logo [Unicode]
4c79b5
    sitename = u'${WIKISITENAME}'
4c79b5
4c79b5
    # Wiki logo. You can use an image, text or both. [Unicode]
4c79b5
    # For no logo or text, use '' - the default is to show the sitename.
4c79b5
    # See also url_prefix setting below!
4c79b5
    logo_string = u'MoinMoin Logo'
4c79b5
4c79b5
    # name of entry page / front page [Unicode], choose one of those:
4c79b5
4c79b5
    # a) if most wiki content is in a single language
4c79b5
    #page_front_page = u"MyStartingPage"
4c79b5
4c79b5
    # b) if wiki content is maintained in many languages
4c79b5
    page_front_page = u"${WIKIFRONTPAGE}"
4c79b5
4c79b5
    # The interwiki name used in interwiki links
4c79b5
    #interwikiname = 'UntitledWiki'
4c79b5
    # Show the interwiki name (and link it to page_front_page) in the Theme,
4c79b5
    # nice for farm setups or when your logo does not show the wiki's name.
4c79b5
    #show_interwiki = 1
4c79b5
4c79b5
4c79b5
    # Critical setup  ---------------------------------------------------
4c79b5
4c79b5
    # Misconfiguration here will render your wiki unusable. Check that
4c79b5
    # all directories are accessible by the web server or moin server.
4c79b5
4c79b5
    # If you encounter problems, try to set data_dir and data_underlay_dir
4c79b5
    # to absolute paths.
4c79b5
4c79b5
    # Where your mutable wiki pages are. You want to make regular
4c79b5
    # backups of this directory.
4c79b5
    data_dir = '${WIKILOCATION}${WIKIINSTANCE}/data/'
4c79b5
4c79b5
    # Where read-only system and help page are. You might want to share
4c79b5
    # this directory between several wikis. When you update MoinMoin,
4c79b5
    # you can safely replace the underlay directory with a new one. This
4c79b5
    # directory is part of MoinMoin distribution, you don't have to
4c79b5
    # backup it.
4c79b5
    data_underlay_dir = '${WIKILOCATION}${WIKIINSTANCE}/underlay/'
4c79b5
4c79b5
    # Location of your STATIC files (css/png/js/...) - you must NOT use the
4c79b5
    # same for invoking moin.cgi (or, in general, the moin code).
4c79b5
    # url_prefix must be '/wiki' for Twisted and standalone servers.
4c79b5
    # For CGI, it should match your Apache Alias setting.
4c79b5
    url_prefix = '/${WIKIURLPREFIX}'
4c79b5
4c79b5
4c79b5
    # Security ----------------------------------------------------------
4c79b5
4c79b5
    # This is checked by some rather critical and potentially harmful actions,
4c79b5
    # like despam or PackageInstaller action:
4c79b5
    #superuser = [u"${WIKISUPERUSER}", ]
4c79b5
4c79b5
    # IMPORTANT: grant yourself admin rights! replace YourName with
4c79b5
    # your user name. See HelpOnAccessControlLists for more help.
4c79b5
    # All acl_rights_xxx options must use unicode [Unicode]
4c79b5
    #acl_rights_default = u"All:read"
4c79b5
    #acl_rights_before  = u"${WIKISUPERUSER}:read,write,delete,revert,admin" \\
4c79b5
    #			 u"AdminGroup:read,write,delete,revert,admin" \\
4c79b5
    #			 u"EditGroup:read,write,delete,revert"
4c79b5
4c79b5
    # Link spam protection for public wikis (Uncomment to enable)
4c79b5
    # Needs a reliable internet connection.
4c79b5
    #from MoinMoin.util.antispam import SecurityPolicy
4c79b5
4c79b5
4c79b5
    # Mail --------------------------------------------------------------
4c79b5
4c79b5
    # Configure to enable subscribing to pages (disabled by default)
4c79b5
    # or sending forgotten passwords.
4c79b5
4c79b5
    # SMTP server, e.g. "mail.provider.com" (None to disable mail)
4c79b5
    #mail_smarthost = "${WIKIMAILSMARTHOST}"
4c79b5
4c79b5
    # The return address, e.g u"Jürgen Wiki <noreply@mywiki.org>" [Unicode]
4c79b5
    #mail_from = u"${WIKIMAILFROM}"
4c79b5
4c79b5
    # "user pwd" if you need to use SMTP AUTH
4c79b5
    #mail_login = "${WIKIMAILLOGIN}"
4c79b5
4c79b5
4c79b5
    # User interface ----------------------------------------------------
4c79b5
4c79b5
    # Add your wikis important pages at the end. It is not recommended to
4c79b5
    # remove the default links.  Leave room for user links - don't use
4c79b5
    # more than 6 short items.
4c79b5
    # You MUST use Unicode strings here, but you need not use localized
4c79b5
    # page names for system and help pages, those will be used automatically
4c79b5
    # according to the user selected language. [Unicode]
4c79b5
    navi_bar = [
4c79b5
        # If you want to show your page_front_page here:
4c79b5
        #u'%(page_front_page)s',
4c79b5
        u'RecentChanges',
4c79b5
        u'FindPage',
4c79b5
        u'SiteNavigation',
4c79b5
        u'HelpContents',
4c79b5
    ]
4c79b5
4c79b5
    # The default theme anonymous or new users get
4c79b5
    theme_default = 'modern'
4c79b5
4c79b5
4c79b5
    # Language options --------------------------------------------------
4c79b5
4c79b5
    # See http://moinmoin.wikiwikiweb.de/ConfigMarket for configuration in 
4c79b5
    # YOUR language that other people contributed.
4c79b5
4c79b5
    # The main wiki language, set the direction of the wiki pages
4c79b5
    language_default = '${WIKILANGUAGE}'
4c79b5
4c79b5
    # You must use Unicode strings here [Unicode]
4c79b5
    page_category_regex = u'^Category[A-Z]'
4c79b5
    page_dict_regex = u'[a-z]Dict$'
4c79b5
    page_form_regex = u'[a-z]Form$'
4c79b5
    page_group_regex = u'[a-z]Group$'
4c79b5
    page_template_regex = u'[a-z]Template$'
4c79b5
4c79b5
    # Content options ---------------------------------------------------
4c79b5
4c79b5
    # Show users hostnames in RecentChanges
4c79b5
    show_hosts = 1                  
4c79b5
4c79b5
    # Enable graphical charts, requires gdchart.
4c79b5
    #chart_options = {'width': 600, 'height': 300}
4c79b5
WIKICONFIG
4c79b5
4c79b5
#
4c79b5
# Uncomment some options in the wikiconfig.py file if ...
4c79b5
#
4c79b5
4c79b5
if [ "$WIKISUPERUSER" != "" ]; then
4c79b5
4c79b5
	sed -i -e '
4c79b5
		/#superuser/s/#//
4c79b5
		s/YourName/'$WIKISUPERUSER'/' ${WIKIINSTANCE}/cgi-bin/wikiconfig.py
4c79b5
4c79b5
fi
4c79b5
4c79b5
if [ "$WIKIRESTRICTEDIT" = "yes" ]; then
4c79b5
4c79b5
	sed -i -r -e '
4c79b5
		/#acl_rights_before/s/#//
4c79b5
		/#acl_rights_default/s/#//
4c79b5
		/#[\t ]*u"EditGroup/s/#//
4c79b5
		/#[\t ]*u"AdminGroup/s/#//' ${WIKIINSTANCE}/cgi-bin/wikiconfig.py
4c79b5
4c79b5
fi
4c79b5
4c79b5
if [ "$WIKIMAILSMARTHOST" != "" ]; then
4c79b5
4c79b5
	sed -i -e '
4c79b5
		/#mail_smarthost/s/#//' ${WIKIINSTANCE}/cgi-bin/wikiconfig.py
4c79b5
4c79b5
fi
4c79b5
4c79b5
if [ "$WIKIMAILFROM" != "" ];then
4c79b5
4c79b5
	sed -i -e '
4c79b5
		/#mail_from/s/#//' ${WIKIINSTANCE}/cgi-bin/wikiconfig.py
4c79b5
4c79b5
fi
4c79b5
4c79b5
if [ "$WIKIMAILLOGIN" != "" ];then
4c79b5
 
4c79b5
	sed -i -e '
4c79b5
		/#mail_login/s/#//' ${WIKIINSTANCE}/cgi-bin/wikiconfig.py
4c79b5
4c79b5
fi
4c79b5
4c79b5
4c79b5
# File Permissions
4c79b5
#
4c79b5
# Here we set the file permissons to the created and copied
4c79b5
# files.
4c79b5
#
4c79b5
echo 'Setting permissions ...'
4c79b5
chown -R $USER.$GROUP $WIKIINSTANCE
4c79b5
chmod -R 750 $WIKIINSTANCE
4c79b5
4c79b5
4c79b5
# Last Message
4c79b5
echo '---------------------------------------------'
4c79b5
echo ' *** The wiki instance had been created! *** '
4c79b5
echo '---------------------------------------------'
4c79b5
echo 'To finish the installation do the following:'
4c79b5
echo "  1. Restart the Web Server (service httpd restart)"
4c79b5
echo "  2. Open your browser and try the address: http://localhost/${WIKIALIAS}"
4c79b5
echo '  3. Enjoy your installed wiki :).'
4c79b5
echo ''