| 1 | #!/bin/bash |
| 2 | |
| 3 | # this defines regexps for LVM variables that do not need root |
| 4 | # the 10_aide_lvm_needsroot is executed as root from a different |
| 5 | # timer with root privileges and writes another snippet that overwrites |
| 6 | # those variables with real data from the system |
| 7 | |
| 8 | CACHE_FILE="/var/lib/aide/10_aide_rootrules_cache" |
| 9 | MAX_AGE_HOURS=6 |
| 10 | if [[ -f "${CACHE_FILE}" ]]; then |
| 11 | NOW=$(date +%s) |
| 12 | MOD_TIME="$(stat --format %Y "${CACHE_FILE}")" |
| 13 | |
| 14 | AGE=$(( (NOW - MOD_TIME) / 3600 )) |
| 15 | |
| 16 | if [[ "${AGE}" -le "${MAX_AGE_HOURS}" ]]; then |
| 17 | # File is not older than 6 hours |
| 18 | cat "${CACHE_FILE}" |
| 19 | else |
| 20 | printf "# Cache File %s is older than %s hours, silently ignored\n" "${CACHE_FILE}" "${MAX_AGE_HOURS}" |
| 21 | fi |
| 22 | printf "!%s$ f\\n" "${CACHE_FILE}" |
| 23 | else |
| 24 | printf "# Cache File %s does not exist, silently ignored\n" "${CACHE_FILE}" |
| 25 | fi |
| 26 | |
| 27 | # vim:tabstop=4:expandtab:shiftwidth=4 |