summaryrefslogtreecommitdiff
path: root/localikiwikirefreshsite
blob: 65c5cb0ad1e1b4bf3c0f40e93c863b8a63666f86 (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/bin/localikiwikirefreshsite
  4. # Copyright 2008 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: localikiwikirefreshsite,v 1.2 2008-06-03 12:10:52 jonas Exp $
  7. #
  8. # Refresh multipart ikiwiki site, aggregating only main part
  9. #
  10. set -e
  11. PRG=$(basename "$0")
  12. TEMP=$(getopt -s sh -o h -l help -n "$PRG" -- "$@")
  13. if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
  14. eval set -- "$TEMP"
  15. showhelp() {
  16. cat <<EOF
  17. Usage: $PRG PROJECT [MAIN [ADDON ...]]
  18. Examples:
  19. $PRG wiki admin . admin.dev dev
  20. Above example will --refresh the wiki project using the below configurations,
  21. and will also --aggregate using the first of them:
  22. ikiwiki.admin.setup
  23. ikiwiki.setup
  24. ikiwiki.admin.dev.setup
  25. ikiwiki.dev.setup
  26. EOF
  27. }
  28. exit1() {
  29. echo >&2 "Error: $1"
  30. echo >&2 "Exiting..."
  31. exit 1
  32. }
  33. ikiwikirefresh() {
  34. part="$1"
  35. shift || exit1 "Internal error: part not supplied!"
  36. case "$part" in
  37. ""|.) cfgpath=$CFGDIR/ikiwiki.setup;;
  38. *) cfgpath=$CFGDIR/ikiwiki.$part.setup;;
  39. esac
  40. ikiwiki --setup $cfgpath "$@"
  41. }
  42. while true ; do
  43. case "$1" in
  44. -h|--help) showhelp; exit 0;;
  45. --) shift; break;;
  46. *) exit1 "Internal error!";;
  47. esac
  48. done
  49. project="$1"
  50. [ -n "$project" ] || exit1 "Project name must be supplied!"
  51. shift
  52. mainpart="$1"
  53. shift || exit1 "Main part must be supplied (use \"\" if unnamed)!"
  54. CFGDIR=~/private_webdata/$project
  55. ikiwikirefresh "$mainpart" --aggregate --refresh
  56. for part in "$@"; do
  57. ikiwikirefresh "$part" --refresh
  58. done