install_subst 979 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. # install_subst: install a script while doing path substitution
  3. # install_subst [-d] source destination
  4. #
  5. # -d: file is data (rather than script)
  6. install_args=
  7. if [ "$1" = '-d' ]; then
  8. install_args="-m 644"
  9. shift
  10. fi
  11. set -e
  12. tmp=`mktemp install_subst_XXXXXX`
  13. cleanup_tmp() {
  14. rm -f "$tmp"
  15. }
  16. # Delete it on exit
  17. trap cleanup_tmp 0
  18. src="$1"
  19. dst="$2"
  20. sed <"$src" \
  21. -e "s|__ASTERISK_DATA_DIR__|$ASTDATADIR|g" \
  22. -e "s|__ASTERISK_DB_DIR__|$ASTDBDIR|g" \
  23. -e "s|__ASTERISK_ETC_DIR__|$ASTETCDIR|g" \
  24. -e "s|__ASTERISK_HEADER_DIR__|$ASTHEADERDIR|g" \
  25. -e "s|__ASTERISK_LIB_DIR__|$ASTLIBDIR|g" \
  26. -e "s|__ASTERISK_LOG_DIR__|$ASTLOGDIR|g" \
  27. -e "s|__ASTERISK_MOD_DIR__|$ASTMODDIR|g" \
  28. -e "s|__ASTERISK_MAN_DIR__|$ASTMANDIR|g" \
  29. -e "s|__ASTERISK_SBIN_DIR__|$ASTSBINDIR|g" \
  30. -e "s|__ASTERISK_SPOOL_DIR__|$ASTSPOOLDIR|g" \
  31. -e "s|__ASTERISK_VARLIB_DIR__|$ASTVARLIBDIR|g" \
  32. -e "s|__ASTERISK_VARRUN_DIR__|$ASTVARRUNDIR|g" \
  33. > "$tmp"
  34. install $install_args "$tmp" "$dst"