Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion iki-new.sh: set up a new Git-based Ikiwiki instance
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ivan Shmakov  
View profile  
 More options Jun 28 2012, 12:32 am
Newsgroups: alt.sources
Followup-To: alt.sources.d
From: Ivan Shmakov <oneing...@gmail.com>
Date: Thu, 28 Jun 2012 11:32:41 +0700
Local: Thurs, Jun 28 2012 12:32 am
Subject: iki-new.sh: set up a new Git-based Ikiwiki instance
Archive-name: iki-new-is
Submitted-by: oneing...@gmail.com
Last-modified: 2012-06-27 00:00
Copyright-Notice: Both the README and the code are in the public domain;
    this applies worldwide.  Alternatively, both the README and the code
    may be used under the terms and conditions of the MirOS license,
    which is included within the code.

README.iki-new  -*- Text -*-

    Synopsis

        $ iki-new [-e] [-c GIT-URI] SLUG

    Dependencies

        Git, Rsync

    Description

        Iki-new sets up a new Git-based Ikiwiki instance, either without
        (default) or with (-e) the CGI-based Web editing interface.

        The script creates a "current" source directory with a Git
        repository holding either a copy of the "skeleton" files
        (default), or a clone of the other Git repository specified
        (with -c.)  It also creates a "bare" public Git repository,
        (empty) "temporary" and "public" destination directories, and an
        Ikiwiki configuration file.

        After the new instance is set up, Ikiwiki has to be run, like:

            $ ikiwiki --refresh --setup ~/.ikiwiki/SLUG.ikiwiki

        The expected result is that the instance will be available at:

            http://EXAMPLE.ORG/~USER/SLUG/

        (where EXAMPLE.ORG is the server's host name.)

        The locations this script uses are as follows:

        /home/public/users/ivan/iki-new-skel

            (be sure to change to fit your environment!) the set of
            files to comprise the initial Git revision is copied from
            here;

        /home/public/users/${USER}

            the public destination directory, the public Git repository,
            and the current source directory, will be created under this
            directory; depending on the particular setup, it may be
            necessary to change this to ${HOME}/public_html;

        ${public}/${slug}

            the public destination directory;

        ${public}/archives/git/${slug}-iki.git

            the public Git repository;

        ${public}/src/${slug}-current

            the current source directory (operated by Ikiwiki);

        ${HOME}/.ikiwiki/${slug}.ikiwiki

            the configuration file will be created with this filename;

        ${HOME}/tmp/${slug}

            the "temporary" destination directory.

    Bugs

        Should support the use of different configuration file
        templates.

        The Ikiwiki configuration file template provided may not fit
        every setup (and most probably has bugs.)

README.iki-new ends here

#!/bin/bash
### iki-new.sh --- Set up a new Ikiwiki instance  -*- Sh -*-

### Copyright (C) 2012 Ivan Shmakov
## Provided that these terms and disclaimer and all copyright notices
## are retained or reproduced in an accompanying document, permission is
## granted to deal in this work without restriction, including unlimited
## rights to use, publicly perform, distribute, sell, modify, merge,
## give away, or sublicence.
##
## This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
## the utmost extent permitted by applicable law, neither express nor
## implied; without malicious intent or gross negligence. In no event
## may a licensor, author or contributor be held liable for indirect,
## direct, other damage, loss, or other issues arising in any way out of
## dealing in the work, even if advised of the possibility of such
## damage or existence of a defect, except proven that it results out of
## said person's immediate fault when using the work as intended.

### Code:
set -e
set -x

progname=${0##*/}

usage () {
    printf %s\\n \
        "Usage: ${progname} [-e] [-c GIT-URI] SLUG" \
        >&2
    ## .
    exit 1

}

if [ $# -lt 1 ] ; then
    usage
fi

editable_p=
read_only_p=yes
clone_uri=
if [ "$1" = -e ] ; then
    editable_p=yes
    read_only_p=
    shift
fi
if [ "$1" != -c ] ; then
    : ## do nothing
elif [ $# -lt 2 ] ; then
    usage
else
    clone_uri=$2
    shift 2
fi
if [ $# != 1 ] ; then
    usage
fi
slug=$1
case "$slug" in
    (-* | *[^a-z0-9-]*)
        usage
        ;;
esac        

skel=/home/public/users/ivan/iki-new-skel
public=/home/public/users/${USER}
iki_conf=${HOME}/.ikiwiki/${slug}.ikiwiki
dest_tmp=${HOME}/tmp/${slug}
dest_pub=${public}/${slug}
source=${public}/src/${slug}-current
source_git=${source}/.git
git_dir=${public}/archives/git/${slug}-iki.git

test \! -e "$iki_conf"

mkdir -pv -- \
    "${iki_conf%/*}" \
    "${dest_tmp%/*}" \
    "${dest_pub%/*}" \
    "${source%/*}" \
    "${git_dir%/*}"

mkdir -v -- \
    "$dest_tmp" \
    "$dest_pub"

if [ -z "$clone_uri" ] ; then
    mkdir -v -- \
        "$source" \
        "$git_dir"
    rsync -vb -rOtH --ignore-existing \
        --exclude=\*~ --exclude=.\*/ -- \
        "$skel"/ "$source"/
    GIT_DIR=${git_dir} \
        git init --bare
    (
        set -e -x
        cd "$source"
        git init
        git remote add -t master origin "$git_dir"
        git add .
        git commit -m 'Initial revision.'
    )
else
    git clone --bare -- "$clone_uri" "$git_dir"
    git clone -- "$git_dir" "$source"
fi

test \! -e "$iki_conf"

cat > "$iki_conf" <<EOF
### ${iki_conf##*/}  -*- Perl -*-

### Ivan Shmakov, 2011, 2012
## This code is in the public domain.

### Code:

use strict;
use warnings;

package my_${slug/-/_};

sub my_ikiwiki_parameters {
    my \$wikislug
        = '${slug}';
    my \$wikitmp
        = '${dest_tmp}';
    my \$wikipfx
        = '${dest_pub}';
    my \$wikiuri
        = ("https://spire.am-1.org/"
           . '~${USER}/' . \$wikislug);
    my \$wikicgiuri
        = (\$wikiuri
           . "ikiwiki.cgi");
    my \$gitweburi
        = ("https://spire.am-1.org/"
           . '~${USER}'
           . "/archives/git/gitweb.cgi"
           . "?p=" . \$wikislug . "-iki.git");
    my \$email
        = ('${USER}@${HOSTNAME}');

    my \$rsync_cmd
        = ("rsync -c -vb -rOtH"
           . ' --suffix=.~"\$(date +%s)"~'
           . " --backup-dir=.rsync-backup"
           . " --exclude=\\\\*~"
           . " --exclude=.rsync-backup/ --exclude=.backup/"
           . " --exclude=.htaccess --exclude=ikiwiki.cgi"
           . " --delete"
           . " -- ./"
           . " " . \$wikipfx);

    ## .
    return {
        wikiname    => '${slug}',
        adminemail  => \$email,

        srcdir      => '${source}',
        destdir     => \$wikitmp,

        url         => \$wikiuri,
        # cgiurl      => \$wikicgiuri,

        rcs         => "git",
        historyurl  => (\$gitweburi
                        . ";a=history;f=[[file]]"),

        wrappers => [ {
            ## the CGI wrapper
            ${read_only_p:+"# "}cgi => 1,
            wrapper => (\$wikitmp
                        . "/ikiwiki1.cgi"),
            wrappermode => "04755"
        } ],

        add_plugins => [
            ${read_only_p:+"# "} "anonok",
            "brokenlinks",
            "color",
            # "comments",
            "date",
            "format",
            "getsource",
            # "h1title",
            # "highlight",
            # "htmltidy",
            "inline",
            "map",
            "mdwn",
            "meta",
            "orphans",
            "recentchanges",
            "rsync",
            "trail",
            "toc",
            "txt",
            "version"
        ],
        disable_plugins => [
            ${editable_p:+"# "}"htmlscrubber",
            ${editable_p:+"# "}"lockedit",
            "openid",
            # "parentlinks",
            "passwordauth",
            # "recentchanges",
            "signinedit",
            # "transient"
        ],
        underlaydir => "/nowhere",
        underlaydirbase => "/nowhere",

        verbose     => 1,

        sslcookie   => 1,

        timeformat  => "%F %T %z",
        locale      => "C",
        ENV         => { "TZ" => "UTC" },

        # html5       => 1,
        ## FIXME: unfortunately, no xmlns is generated for HTML5
        html5       => 0,
        htmlext     => "xhtml",
        numbacklinks => 16,
        hardlink    => 1,

        ## anonok plugin
        anonok_pagespec => "*",

        ## comments plugin
        comments_commit     => 0,
        comments_pagespec   => "! */Discussion",

        ## inline plugin
        allowatom   => 1,
        allowrss    => 1,
        atom        => 1,
        rss         => 0,

        getsource_mimetype => "text/plain; charset=utf-8",

        tohighlight => ".c .h .pl .sh Makefile:make",

        recentchangesnum => 128,

        rsync_command => \$rsync_cmd,
    };

}

use IkiWiki::Setup::Standard
    (my_${slug/-/_}::my_ikiwiki_parameters ());

### Emacs trailer
## Local variables:
## coding: utf-8
## fill-column: 64
## indent-tabs-mode: nil
## ispell-local-dictionary: "american"
## End:
### ${iki_conf##*/} ends here
EOF

### Emacs trailer
## Local variables:
## coding: us-ascii
## fill-column: 72
## indent-tabs-mode: nil
## End:
### iki-new.sh ends here

--
FSF associate member #7257


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.