summaryrefslogtreecommitdiff
path: root/localikiwikicreatesite
blob: c49942ecb1f6dc239d57c31437172fc0c8b3631d (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/backend
  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. git add .
  44. git commit -m "initial commit"
  45. git remote add origin $DESTSRCDIR/backend.git
  46. git config branch.master.merge refs/heads/master
  47. git push --all
  48. )
  49. ## Adjust backend
  50. perl -pi -e '
  51. s,^(\s*)#?(srcdir\s*=>\s*\")(.*)(\"\,\s*),$1$2'$SRCDIR'$4,;
  52. s,^(\s*)#?(destdir\s*=>\s*\")(.*)(\"\,\s*),$1$2'$DESTDIR'$4,;
  53. s,^(\s*)#?(url\s*=>\s*\")(.*)(\"\,\s*),$1$2http://'$host'$4,;
  54. s,^(\s*)#?(cgiurl\s*=>\s*\")(.*)(\"\,\s*),$1#$2$3$4,;
  55. s,^(\s*)#?(rcs\s*=>\s*\")(git)(\"\,\s*),$1$2$3$4,;
  56. ' $CFGDIR/ikiwiki.setup
  57. (
  58. cd $CFGDIR
  59. git add ikiwiki.setup
  60. git commit -m "Setup local paths"
  61. git push
  62. )
  63. ikiwiki --verbose $SRCDIR $DESTDIR --url=http://"$host" --setup $CFGDIR/ikiwiki.setup