/cron.daily/mlocate

http://github.com/brinkman83/bashrc · #! · 36 lines · 26 code · 10 blank · 0 comment · 0 complexity · dacff83a18b83a8762c82db7c778139c MD5 · raw file

  1. #! /bin/bash
  2. set -e
  3. [ -x /usr/bin/updatedb.mlocate ] || exit 0
  4. if which on_ac_power >/dev/null 2>&1; then
  5. ON_BATTERY=0
  6. on_ac_power >/dev/null 2>&1 || ON_BATTERY=$?
  7. if [ "$ON_BATTERY" -eq 1 ]; then
  8. exit 0
  9. fi
  10. fi
  11. ##
  12. LOCKFILE="/var/lib/mlocate/daily.lock"
  13. trap "rm -f $LOCKFILE" EXIT
  14. if [ -e "$LOCKFILE" ]; then
  15. echo >&2 "Warning: $LOCKFILE present, not running updatedb."
  16. exit 1
  17. else
  18. touch "$LOCKFILE"
  19. fi
  20. ##
  21. # See ionice(1)
  22. if [ -x /usr/bin/ionice ] &&
  23. /usr/bin/ionice -c3 true 2>/dev/null; then
  24. IONICE="/usr/bin/ionice -c3"
  25. fi
  26. $IONICE /usr/bin/updatedb.mlocate