3 # I somehow ended up with an empty crypttab, and had to rescue my
4 # system. So, lets check for some basic validity.
6 if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi
7 shopt -s inherit_errexit
2>/dev
/null ||
: # ignore fail in bash < 4.4
9 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR
21 metric_dir
=/var
/lib
/prometheus
/node-exporter
22 mnt
="$(findmnt -fn -o SOURCE /)"
24 /dev
/mapper
/crypt_dev_
*)
25 tmp
=${mnt#/dev/mapper/}
27 if ! grep -qF $dev /etc
/crypttab
; then
29 if [[ -e $metric_dir ]]; then
30 echo "crypttab_check 1" > $metric_dir/crypttab_check.prom
36 if [[ -e $metric_dir ]]; then
37 echo "crypttab_check 0" > $metric_dir/crypttab_check.prom