Create directory if not existing
[mirror/dsa-nagios.git] / dsa-nagios-checks / sbin / dsa-update-unowned-file-status
index 45a8f89..cc4e812 100755 (executable)
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 CUTOFF=40
-STATUS=/var/cache/dsa/nagios/nouser
+STATUSDIR=/var/cache/dsa/nagios
+STATUS="${STATUSDIR}"/nouser
+
+if [ ! -d "${STATUSDIR}" ]; then
+        mkdir -p "${STATUSDIR}"
+fi
 
 tmp=`tempfile`
 trap "rm -f '$tmp'" exit
@@ -31,7 +36,7 @@ if command -v ionice >/dev/null 2>&1; then
        prefix="ionice -c 3 -t"  # idle priority, ignore errors
 fi
 
-$prefix find / -fstype proc -prune -o -nouser | head -n "$CUTOFF" > "$tmp"
+$prefix find / -ignore_readdir_race \( -fstype proc -o -fstype sysfs -o -fstype fdescfs -o -fstype autofs -o -fstype nfs4 \) -prune -o \( -nouser -print \) | head -n "$CUTOFF" > "$tmp"
 
 if [ -s "$tmp" ]; then
        echo "WARN"