Permalink
Browse files

Better md5/md5sum switching & error handling

  • Loading branch information...
1 parent 8ca1041 commit c5f306cb4ba0445c52af2e50e2079de918d42c15 @kvz committed Jun 30, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 cronlock
View
@@ -69,12 +69,20 @@ if [ -n "${CRONLOCK_CONFIG}" ]; then
source "${CRONLOCK_CONFIG}"
fi
+md5="$(which md5)"
+if [ ! -x "${md5}" ]; then
+ md5="$(which md5sum)"
+fi
+if [ ! -x "${md5}" ]; then
+ fatal "Unable to find md5"
+fi
+
# Defaults
[ -z "${CRONLOCK_HOST}" ] && CRONLOCK_HOST="localhost"
[ -z "${CRONLOCK_PORT}" ] && CRONLOCK_PORT=6379
[ -z "${CRONLOCK_GRACE}" ] && CRONLOCK_GRACE=40
[ -z "${CRONLOCK_RELEASE}" ] && CRONLOCK_RELEASE=86400
-[ -z "${CRONLOCK_KEY}" ] && CRONLOCK_KEY="$(echo "$@" | md5 2>/dev/null || echo "$@" | md5sum | awk '{print $1}')"
+[ -z "${CRONLOCK_KEY}" ] && CRONLOCK_KEY="$(echo "$@" | $md5 | awk '{print $1}')"
[ -z "${CRONLOCK_PREFIX}" ] && CRONLOCK_PREFIX="cronlock."
[ -z "${CRONLOCK_VERBOSE}" ] && CRONLOCK_VERBOSE="no"
[ -z "${CRONLOCK_RESET}" ] && CRONLOCK_RESET="no"

0 comments on commit c5f306c

Please sign in to comment.