summaryrefslogtreecommitdiff
path: root/localikiwikicreatesite
blob: 27cc00a91a38ae576fcf4ba158b01ae4c6e27ff8 (plain)
  1. #!/bin/sh
  2. # Origin: http://ikiwiki.info/setup/
  3. set -e
  4. host=$1
  5. [ -z "$host" ] && echo "ERROR: Hostname must be supplied!" && exit 1
  6. srchost=${2:-source.$host}
  7. SRCDIR=~/private_webdata/$host/content
  8. CFGDIR=~/private_webdata/$host
  9. DESTDIR=~/public_websites/$host
  10. DESTSRCDIR=~/public_websites/$srchost
  11. ## Init public RCS repositories
  12. mkdir -p $DESTSRCDIR
  13. GIT_DIR=$DESTSRCDIR/content.git git --bare init --shared
  14. GIT_DIR=$DESTSRCDIR/backend.git git --bare init --shared
  15. ## Create initial content
  16. mkdir -p $SRCDIR
  17. cat <<'EOF' >$SRCDIR/index.mdwn
  18. Welcome to your new wiki.
  19. All wikis are supposed to have a <a href="../sandbox/">SandBox</a>,
  20. so this one does too.
  21. ----
  22. This wiki is powered by [ikiwiki](http://ikiwiki.info).
  23. EOF
  24. #ikiwiki --verbose $SRCDIR $DESTDIR --url=http://"$host"
  25. ## Create initial backend
  26. mkdir -p $CFGDIR
  27. cp /usr/share/doc/ikiwiki/html/ikiwiki.setup $CFGDIR
  28. ## Init content RCS
  29. (
  30. cd $SRCDIR
  31. git init
  32. echo /.ikiwiki > .gitignore
  33. git add .
  34. git commit -m "initial commit"
  35. git remote add origin $DESTSRCDIR/content.git
  36. git config branch.master.merge refs/heads/master
  37. git push --all
  38. )
  39. ## Init backend RCS
  40. (
  41. cd $CFGDIR
  42. git init
  43. echo /content > .gitignore
  44. git add .
  45. git commit -m "initial commit"
  46. git remote add origin $DESTSRCDIR/backend.git
  47. git config branch.master.merge refs/heads/master
  48. git push --all
  49. )
  50. ## Adjust backend to actual paths, and enable Git post-update wrapper
  51. perl -pi -e '
  52. s,^(\s*)#?(srcdir\s*=>\s*")[^"]*("\,\s*),$1$2'$SRCDIR'$3,;
  53. s,^(\s*)#?(destdir\s*=>\s*")[^"]*("\,\s*),$1$2'$DESTDIR'$3,;
  54. s,^(\s*)#?(url\s*=>\s*")[^"]*("\,\s*),$1$2http://'$host'$3,;
  55. s,^(\s*)#?(cgiurl\s*=>\s*")([^"]*)("\,\s*),$1#$2$3$4,;
  56. s,^(\s*)#?(rcs\s*=>\s*")(git)("\,\s*),$1$2$3$4,;
  57. ' $CFGDIR/ikiwiki.setup
  58. perl -0 -pi -e '
  59. 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},;
  60. ' $CFGDIR/ikiwiki.setup
  61. (
  62. perl -0 -pi -e 's,\n(exec\s[^\n]*),\nhooks/post-update-ikiwiki\n\n$1,' $DESTSRCDIR/content.git/hooks/post-update
  63. chmod +x $DESTSRCDIR/content.git/hooks/post-update
  64. cd $CFGDIR
  65. git add ikiwiki.setup
  66. git commit -m "Adjust ikiwiki.setup to use actual paths, and add+enable Git post-update hooks"
  67. )
  68. ## Add Makefile for further customization
  69. cat <<'EOF' >$CFGDIR/Makefile
  70. #underlays = basewiki smiley templates
  71. underlays = templates
  72. #locale = danish
  73. master = master
  74. #master = master-LOCALE
  75. all: $(underlays)
  76. $(underlays):
  77. mkdir $@
  78. cd $@ && git init
  79. cd $@ && git remote add -f -t $(master:LOCALE=$(locale)) -m $(master:LOCALE=$(locale)) origin http://source.jones.dk/ikiwiki_$@.git
  80. cd $@ && git merge origin
  81. EOF
  82. echo /Makefile >> $CFGDIR/.gitignore
  83. (
  84. cd $CFGDIR
  85. git add Makefile
  86. git commit -m "Setup local paths"
  87. )
  88. ikiwiki --verbose $SRCDIR $DESTDIR --url=http://"$host" --setup $CFGDIR/ikiwiki.setup
  89. (
  90. cd $CFGDIR
  91. git push
  92. )