Creation of new wiki instances.....
Matt Lorimer <[email protected]> Thu, 07 Apr 2005 13:46:44 -0600
| Newsgroups | gmane.comp.web.wiki.moin.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. --------------020400060908060803080701 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit After getting confused by the documentation on how to create a new wiki 3 or 4 times, I set out to write better documentation. Then it dawned on me that it wouldn't be too hard to write a script to do it. I threw together a little script, and here it is. I am not sure if you want to use it or not, but I thought I would make it available to you. Matt Lorimer Systems Administrator USU NCS - Banner Project 4410 Old Main Hill SER 324 Logan, UT 84321 435.797.8950 [email protected] --------------020400060908060803080701 Content-Type: text/plain; name="newwiki.sh" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="newwiki.sh" #!/bin/bash #newwiki.sh - Script to create a new wiki instance. #v-0.75 #Created by Matt Lorimer [email protected] #Last edited on 04-07-2005 #Function to display available options you can pass to this script function ShowOpts { if [ $# -lt 1 ] then { echo "newwiki.sh WikiName [-f] [-l] [-u] [-g] [-p] [-s] [-h] [--help]" echo " WikiName is the name of the wiki you are creating" echo " -f --farm Indicates this is part of a wiki farm (some" echo " files are not copied) - default value is false" echo " -l --location Location you would like you wiki data stored" echo " in - default value is current directory" echo " -u User Apache runs under - default value is apache" echo " -g Group Apache runs under - default value is apache" echo " -p --prefix Prefix you used when installing moin - default" echo " value is /usr (same as installer)" echo " -s Share directory for moin installation - default" echo " value is \$PREFIX/share/moin (same as installer)" echo " -q --quiet Supress all output except errors" echo " -v --verbose Display information on progress" echo " -h --help Display this information" exit 1 } fi } #function that actually creates the wiki function CreateWiki { #create the directory for this instance mkdir -p $WIKILOCATION/$INSTANCE if [ $VERBOSE = true ] then echo "Copying Share data to $WIKILOCATION/$INSTANCE/ ...." fi # Copy template data directory cp -r $SHARE/data $WIKILOCATION/$INSTANCE/ if [ $FARM = true ] then if [ $VERBOSE = true ] then echo "Copying default wikiconfig to $WIKILOCATION/$INSTANCE.py..." fi cp $SHARE/config/wikiconfig.py $WIKILOCATION/$INSTANCE.py if [ $VERBOSE = true ] then echo "Setting permissions on $WIKILOCATION/$INSTANCE.py..." fi # Set permissions correctly on this file chown $USER:$GROUP $WIKILOCATION/$INSTANCE.py chmod -R ug+rwX $WIKILOCATION/$INSTANCE chmod -R o-rwx $WIKILOCATION/$INSTANCE else if [ $VERBOSE = true ] then echo "Copying underlay directory and wikiconfig.py file to $WIKILOCATION/$INSTANCE/ ..." fi # Copy underlay data directory -- Not necissary for additional wiki's with one install cp -r $SHARE/underlay $WIKILOCATION/$INSTANCE/ # Copy wiki configuration sample file cp $SHARE/config/wikiconfig.py $WIKILOCATION/$INSTANCE fi if [ $VERBOSE = true ] then echo "Fixing Permissions on $WIKILOCATION/$INSTANCE/ ..." fi # Fix any ownership problems chown -R $USER.$GROUP $WIKILOCATION/$INSTANCE # Make apache user and group have read and write permissions and execute permissions where necissary chmod -R ug+rwX $WIKILOCATION/$INSTANCE # Nobody else needs to do anything with the files. chmod -R o-rwx $WIKILOCATION/$INSTANCE if [ $QUIET = false ] then echo "$INSTANCE created successfully. You must edit your apache config file accordingly." if [ $FARM = true ] then echo "You must also edit $WIKILOCATION/$INSTANCE.py" echo "and your $WIKILOCATION/farmconfig.py file" else echo "You must also edit $WIKILOCATION/$INSTANCE/wikiconfig.py" fi fi } #Default values for the script #Weather this is being added to a wiki farm or not FARM=false # Prefix you used when installing moinmoin PREFIX=/usr # If you didn't change this, this is correct. SHARE=$PREFIX/share/moin # Where your wiki data will be stored. WIKILOCATION="./" # User and group apache runs under USER=apache GROUP=apache #Set quiet and verbose to both be off by default QUIET=false VERBOSE=false #Time to parse out the TEMP=`getopt -o fhvql:u:g:p:s: -l help,farm,quiet,verbose,prefix:,location: -- "$@"` #Make sure they didn't pass any invalid arguments to the script if [ $? != 0 ] then #if they did, then show them what the options are and quit with an error code of 1 ShowOpts exit 1 fi # Note the quotes around `$TEMP': they are essential! eval set -- "$TEMP" while true ; do case "$1" in -h|--help) ShowOpts ; shift ;; -q|--quiet) QUIET=true ; shift ;; -v|--verbose) VERBOSE=true ; shift ;; -f|--farm) FARM=true ; shift ;; -l|--location) WIKILOCATION=$2 ; shift 2 ;; -u) USER=$2 ; shift 2 ;; -g) GROUP=$2 ; shift 2 ;; -p|--prefix) PREFIX=$2 ; shift 2 ;; -s) SHARE=$2 ; shift 2 ;; --) shift ; break ;; *) echo "Internal error!" ; exit 1 ;; esac done if [ $# -ne 1 ] then echo "You specified $# values. The command must only have one value" ShowOpts exit 1 fi INSTANCE=$1 CreateWiki --------------020400060908060803080701-- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click