summaryrefslogtreecommitdiff
path: root/localeztemplateget
blob: 320f1f4fa89b1cea8bb263756d282bf0c1aaadd7 (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/bin/localeztemplategrab
  4. # Copyright 2003 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: localeztemplateget,v 1.1 2003-01-11 19:12:35 jonas Exp $
  7. #
  8. # Extract template from eZ Publish 2.2.x site and save as separate tarball
  9. #
  10. #set -e
  11. prg=`basename $0`
  12. if [ -z "$1" -o -z "$2" ]; then
  13. echo "$prg: Extract template from eZ Publish 2.2.x site"
  14. echo " and save as separate tarball"
  15. echo
  16. echo "Usage: $prg template origdir [targetfile]"
  17. echo
  18. echo "Options:"
  19. echo " template: name of template to extract"
  20. echo " origdir: Base directory for eZ Publish website"
  21. echo " targetfile: Where to store template tarball"
  22. echo
  23. echo
  24. echo "If targetfile not provided, it is named after the template and saved in"
  25. echo "current directory."
  26. exit 1
  27. fi
  28. template=$1
  29. origdir=$2
  30. targetfile=${3:-$template.tar.gz}
  31. if [ ! -d "$origdir" ]; then
  32. echo "ERROR: eZ directory \"$origdir\" doesn't exist!"
  33. echo "Aborting..."
  34. exit 1
  35. fi
  36. if echo "$targetfile" | egrep -vq '\.(tar\.gz|tgz$)' ; then
  37. targetfile="$targetfile.tar.gz"
  38. echo "WARNING: appending extensions to targetfile. New name: \"$targetfile\""
  39. fi
  40. if [ -f "$targetfile" ]; then
  41. echo "ERROR: targetfile \"$targetfile\" already exists!"
  42. echo "Aborting...!"
  43. exit 1
  44. fi
  45. tar --create --to-stdout --mode='a=r,u+w,a+X' --directory=$origdir `cd $origdir && find * -type f | grep -v cache | grep "/$template/"` | gzip --best > $targetfile
  46. echo "Done! Templates are in \"$targetfile\""