sitify 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. [ ! -n "$1" ] && echo "$0: no orig dir specified" 1>&2 && exit 1
  3. [ ! -n "$2" ] && echo "$0: no dest dir specified" 1>&2 && exit 1
  4. [ ! -d "$1" ] && echo "$0: $1 is not a directory" 1>&2 && exit 1
  5. [ ! -d "$2" ] && echo "$0: $2 is not a directory" 1>&2 && exit 1
  6. ORIG=$(readlink -e $1)
  7. DEST=$(readlink -e $2)
  8. LIB_PATH="$(dirname $0)/lib/sitify"
  9. RC_PATH="${ORIG}/.sitify/rc"
  10. LS=$(which ls)
  11. IFS='
  12. '
  13. [ ! -d "${LIB_PATH}" ] && exit 1
  14. for i in $(${LS} -1 "${LIB_PATH}"); do
  15. . "${LIB_PATH}/${i}"
  16. done
  17. [ -f "${RC_PATH}" ] && . "${RC_PATH}"
  18. RecurseDir () {
  19. PushDir "$1" 2>&1 >/dev/null
  20. DIR=$(echo -n "$(pwd)" | sed "s?^${ORIG}??")/
  21. for i in ${DIR_HOOKS}; do "${i}"; done
  22. for i in $(${LS} -1); do
  23. FILE="${i}"
  24. [ ! -d "${i}" ] && for j in ${FILE_HOOKS}; do
  25. "${j}" "$(pwd)/${i}" "${CURR_DEST}/${i}"
  26. done
  27. done
  28. for i in $(${LS} -1); do
  29. [ -d "${i}" ] && RecurseDir "${i}"
  30. done
  31. PopDir 2>&1 >/dev/null
  32. }
  33. for i in ${INIT_HOOKS}; do "${i}"; done
  34. RecurseDir "${ORIG}"
  35. for i in ${STOP_HOOKS}; do "${i}"; done
  36. unset IFS