summaryrefslogtreecommitdiff
path: root/localikiwikicreatesite
blob: abcb063d2a12a57f0db6174ba8b0d3bc63a0b8c7 (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 and add Makefile for further customization
  51. perl -pi -e '
  52. s,^(\s*)#?(srcdir\s*=>\s*\")(.*)(\"\,\s*),$1$2'$SRCDIR'$4,;
  53. s,^(\s*)#?(destdir\s*=>\s*\")(.*)(\"\,\s*),$1$2'$DESTDIR'$4,;
  54. s,^(\s*)#?(url\s*=>\s*\")(.*)(\"\,\s*),$1$2http://'$host'$4,;
  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. (
  59. cd $CFGDIR
  60. git add ikiwiki.setup
  61. cat <<EOF >$CFGDIR/Makefile
  62. #underlays = basewiki smiley templates
  63. underlays = templates
  64. #locale = danish
  65. master = master
  66. #master = master-LOCALE
  67. all: $(underlays)
  68. $(underlays):
  69. mkdir $@
  70. cd $@ && git init
  71. cd $@ && git remote add -f -t $(master:LOCALE=$(locale)) -m $(master:LOCALE=$(locale)) origin http://source.jones.dk/ikiwiki_$@.git
  72. cd $@ && git merge origin
  73. EOF
  74. echo /Makefile > .gitignore
  75. git add Makefile
  76. git commit -m "Setup local paths"
  77. git push
  78. )
  79. ikiwiki --verbose $SRCDIR $DESTDIR --url=http://"$host" --setup $CFGDIR/ikiwiki.setup