#! /bin/sh
#
# Copyright 2017 Cumulus Networks, Inc.  All rights reserved.
#

# Check for files in the /run/problems directory, and if any are present
# display the contents of the files on stderr

# This allows system components to report major problems during boot (or
# during operation), and then have the problems reported by commands 
# that otherwise wouldn't know about them.

# This script can be run directly, but it's normally run via aliases
# from /etc/profile.d

probdir=/run/problems

exval=0

exec 1>&2

[ -d $probdir ] && for f in $probdir/*; do
	case "$f" in
	$probdir/'*') ;; # no files
	* ) sed -e 's/^/***  /' "$f"
	    exval=1  ;;
	esac
done
[ $exval -ne 0 ] && echo '***'
exit $exval
