#!/bin/bash
#
# checks unexpected readonly-mounts, i.e. certain /proc/mounts lines with " ro,"
#

# prepare

. /usr/lib/montools/mt-prepare

RESNAME="readonly-mounts"


# ^[^/]| filters out 'normal' filesystem mounts, like container paritions
# / and /boot need to be checked though
# cifs|fuse|nfs filter out remote mounts 
# /sys/fs/cgroup is a special case on older VVZs
ROMOUNTS=$(cat /proc/self/mounts |egrep "^[^/]| / | /boot " |egrep -v " (cifs|fuse|nfs|ramfs|smb|/sys/fs/cgroup) " |grep " ro,")

if [ -n "${ROMOUNTS}" ] ; then
  add2warnings \
    "Warning: We have unexpected readonly mounts on ${HOSTNAME}:" \
    "${ROMOUNTS}"
  . /usr/lib/montools/mt-notify-exit
fi  

# no notifications

#. /usr/lib/montools/mt-notify-exit

exit 0

