View | Details | Raw Unified
Collapse All | Expand All

(-) functions-old.sh (+55 lines)
 Lines 121-126    Link Here 
	BRACKET=$'\e[34;01m'
	BRACKET=$'\e[34;01m'
fi
fi
# void sendmessages(void)
#
#	send any einfo, ewarn, or eerror messages that have collected
#	upon exit of this shell (part of the emergemail feature).
#
trap sendmessages EXIT
sendmessages() {
	for SEVERITY in "information" "warning" "error"; do
		BUFFER=${TMPDIR}/emergemail.buffer.${SEVERITY}
		if [ -f ${BUFFER} ]; then
			if [ -x /usr/sbin/sendmail ]; then
				/usr/sbin/sendmail root < ${BUFFER}
				unset ${EMESSAGES}
			else
				echo -e " ${WARN}*${NORMAL} the emergemail FEATURE "\
						"was unable to find /usr/sbin/sendmail.  "
				echo -e " ${WARN}*${NORMAL} You must have a Mail "\
						"Transfer Agent (MTA) such as postfix, exim,"
				echo -e " ${WARN}*${NORMAL} ssmtp, etc. to use this "\
						"feature."
			fi
			rm -f ${BUFFER}
		fi
	done
}
# void emergemail(char *severity, char *message)
#
#	send mail to root with the given message (if possible)
#	severity is either "information" (for einfo),
#					   "warning" (for ewarn),
#					or "error" (for eerror).
#
emergemail() {
	SEVERITY=$1
	MESSAGE=$2
	BUFFER=${TMPDIR}/emergemail.buffer.${SEVERITY}
	if echo ${FEATURES} | grep -iq emergemail; then
		if [ ! -f ${BUFFER} ]; then
			echo -e "Subject: ${SEVERITY} from emerge of ${P}\n\n" > ${BUFFER}
		fi
		echo -e ${MESSAGE} >> ${BUFFER}
	fi
}
# void esyslog(char* priority, char* tag, char* message)
# void esyslog(char* priority, char* tag, char* message)
#
#
#    use the system logger to log a message
#    use the system logger to log a message
 Lines 153-158    Link Here 
		echo -e " ${GOOD}*${NORMAL} ${*}"
		echo -e " ${GOOD}*${NORMAL} ${*}"
	fi
	fi
	emergemail information "${*}"
	return 0
	return 0
}
}
 Lines 166-171    Link Here 
		echo -ne " ${GOOD}*${NORMAL} ${*}"
		echo -ne " ${GOOD}*${NORMAL} ${*}"
	fi
	fi
	emergemail information "${*}"
	return 0
	return 0
}
}
 Lines 181-186    Link Here 
		echo -e " ${WARN}*${NORMAL} ${*}"
		echo -e " ${WARN}*${NORMAL} ${*}"
	fi
	fi
	emergemail warning "${*}"
	# Log warnings to system log
	# Log warnings to system log
	esyslog "daemon.warning" "rc-scripts" "${*}"
	esyslog "daemon.warning" "rc-scripts" "${*}"
 Lines 199-204    Link Here 
		echo -e " ${BAD}*${NORMAL} ${*}"
		echo -e " ${BAD}*${NORMAL} ${*}"
	fi
	fi
	emergemail error "${*}"
	# Log errors to system log
	# Log errors to system log
	esyslog "daemon.err" "rc-scripts" "${*}"
	esyslog "daemon.err" "rc-scripts" "${*}"