diff options
-rwxr-xr-x | localikiwikicreatesite | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/localikiwikicreatesite b/localikiwikicreatesite index 9ab367e..7589aea 100755 --- a/localikiwikicreatesite +++ b/localikiwikicreatesite @@ -7,9 +7,17 @@ set -e host=$1 [ -z "$host" ] && echo "ERROR: Hostname must be supplied!" && exit 1 -SRCDIR=~/private_webdata/"$host"/content -DESTDIR=~/public_websites/"$host" +SRCDIR=~/private_webdata/$host/content +CFGDIR=~/private_webdata/$host/backend +DESTDIR=~/public_websites/$host +DESTSRCDIR=~/public_websites/source.$host +## 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. @@ -19,4 +27,48 @@ so this one does too. This wiki is powered by [ikiwiki](http://ikiwiki.info). EOF -ikiwiki --verbose $SRCDIR $DESTDIR --url=http://"$host" +#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 +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 +perl -pi -e ' + s,^(\s*)#?(srcdir\s*=>\s*\")(.*)(\"\,\s*),$1$2'$SRCDIR'$4,; + s,^(\s*)#?(destdir\s*=>\s*\")(.*)(\"\,\s*),$1$2'$DESTDIR'$4,; + s,^(\s*)#?(url\s*=>\s*\")(.*)(\"\,\s*),$1$2http://'$host'$4,; + s,^(\s*)#?(cgiurl\s*=>\s*\")(.*)(\"\,\s*),$1#$2$3$4,; + s,^(\s*)#?(rcs\s*=>\s*\")(git)(\"\,\s*),$1$2$3$4,; + ' $CFGDIR/ikiwiki.setup +( +cd $CFGDIR +git add ikiwiki.setup +git commit -m "Setup local paths" +git push +) + +ikiwiki --verbose $SRCDIR $DESTDIR --url=http://"$host" --setup $CFGDIR/ikiwiki.setup |