- #!/bin/sh
- # Origin: http://ikiwiki.info/setup/
- set -e
- host=$1
- [ -z "$host" ] && echo "ERROR: Hostname must be supplied!" && exit 1
- srchost=${2:-source.$host}
- SRCDIR=~/private_webdata/$host/content
- CFGDIR=~/private_webdata/$host
- DESTDIR=~/public_websites/$host
- DESTSRCDIR=~/public_websites/$srchost
- ## Init public RCS repositories
- mkdir -p $DESTSRCDIR
- GIT_DIR=$DESTSRCDIR/content.git git --bare init --shared
- GIT_DIR=$DESTSRCDIR/backend.git git --bare init --shared
- ## Create initial content
- mkdir -p $SRCDIR
- cat <<'EOF' >$SRCDIR/index.mdwn
- Welcome to your new wiki.
- All wikis are supposed to have a <a href="../sandbox/">SandBox</a>,
- so this one does too.
- ----
- This wiki is powered by [ikiwiki](http://ikiwiki.info).
- EOF
- #ikiwiki --verbose $SRCDIR $DESTDIR --url=http://"$host"
- ## Create initial backend
- mkdir -p $CFGDIR
- cp /usr/share/doc/ikiwiki/html/ikiwiki.setup $CFGDIR
- ## Init content RCS
- (
- cd $SRCDIR
- git init
- echo /.ikiwiki > .gitignore
- git add .
- git commit -m "initial commit"
- git remote add origin $DESTSRCDIR/content.git
- git config branch.master.merge refs/heads/master
- git push --all
- )
- ## Init backend RCS
- (
- cd $CFGDIR
- git init
- echo /content > .gitignore
- git add .
- git commit -m "initial commit"
- git remote add origin $DESTSRCDIR/backend.git
- git config branch.master.merge refs/heads/master
- git push --all
- )
- ## Adjust backend to actual paths, and enable Git post-update wrapper
- perl -pi -e '
- s,^(\s*)#?(srcdir\s*=>\s*")[^"]*("\,\s*),$1$2'$SRCDIR'$3,;
- s,^(\s*)#?(destdir\s*=>\s*")[^"]*("\,\s*),$1$2'$DESTDIR'$3,;
- s,^(\s*)#?(url\s*=>\s*")[^"]*("\,\s*),$1$2http://'$host'$3,;
- s,^(\s*)#?(cgiurl\s*=>\s*")([^"]*)("\,\s*),$1#$2$3$4,;
- s,^(\s*)#?(rcs\s*=>\s*")(git)("\,\s*),$1$2$3$4,;
- ' $CFGDIR/ikiwiki.setup
- perl -0 -pi -e '
- s,#{([\s#]*The git post-update wrapper[^}]*\s*)#(\s*wrapper =>\s*")[^"]*("\,\s*[^}]*)#(\s*wrappermode =>[^}]*)#},{$1$2'$DESTSRCDIR/content.git/hooks/post-update-backend'$3$4},;
- ' $CFGDIR/ikiwiki.setup
- (
- cd $CFGDIR
- git add ikiwiki.setup
- git commit -m "Adjust ikiwiki.setup to use actual paths and enable Git post-update wrapper"
- )
- ## Add Makefile for further customization
- cat <<'EOF' >$CFGDIR/Makefile
- #underlays = basewiki smiley templates
- underlays = templates
- #locale = danish
- master = master
- #master = master-LOCALE
- all: $(underlays)
- $(underlays):
- mkdir $@
- cd $@ && git init
- cd $@ && git remote add -f -t $(master:LOCALE=$(locale)) -m $(master:LOCALE=$(locale)) origin http://source.jones.dk/ikiwiki_$@.git
- cd $@ && git merge origin
- EOF
- echo /Makefile >> $CFGDIR/.gitignore
- (
- cd $CFGDIR
- git add Makefile
- git commit -m "Setup local paths"
- )
- ikiwiki --verbose $SRCDIR $DESTDIR --url=http://"$host" --setup $CFGDIR/ikiwiki.setup
- (
- cd $CFGDIR
- git push
- )
|