PageRenderTime 35ms CodeModel.GetById 31ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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