You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sitegen.sh 748B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #! /usr/bin/env sh
  2. dir="/etc/apache2/sites-available/"
  3. if [ $# -eq 0 ] || [ $# -gt 2 ]
  4. then
  5. echo "Usage:" $(basename $0) "hostname [config=def]" >&2
  6. exit 1
  7. fi
  8. host="$1"
  9. if [ $# -eq 2 ]
  10. then
  11. conf="$2"
  12. else
  13. conf="def"
  14. fi
  15. def="/etc/sitegen/${conf}"
  16. def_conf="/etc/sitegen/${conf}.conf"
  17. adef="${dir}/${host}"
  18. adef_conf="${dir}/${host}.conf"
  19. if [ ! -f "${def}" ] || [ ! -f "${def_conf}" ]
  20. then
  21. echo "Configuration file ${def} and/or ${def_conf} error: No such file" >&2
  22. exit 2
  23. fi
  24. if [ -f "${adef}" ] || [ -f "${adef_conf}" ]
  25. then
  26. echo "Host already exists: ${adef} and/or ${adef_conf}" >&2
  27. exit 3
  28. fi
  29. sed="s/%%HOST%%/${host}/g"
  30. sed "${sed}" "${def}" > "${adef}"
  31. sed "${sed}" "${def_conf}" > "${adef_conf}"
  32. mkdir -p "/var/${host}"