Рукописный шрифт to Ресеиве Эмаиль Notification in Ubuntu 14.04 Вен Систем Сутс Даун and Boots up

I am using Ubuntu 14.04. I want to write в shell рукописный шрифт to get an электронная почта notification whenever my system shuts down and boots up. Please help я out.

I have tried the below соединение but with не luck.

http://www.netspective.com/knowledgebase/server-sops/2012/10/22/how-to-enable-e-mail-alert-while-server-shutdownrestart/

0
задан 27 November 2015 в 23:36

1 ответ

#!/bin/sh
# chkconfig: 2345 99 01
# Description: Sends an email at system start and shutdown

#############################################
#                                           #
# Send an email on system start/stop to     #
# a user.                                   #
#                                           #
#############################################

EMAIL="example@example.com"
RESTARTSUBJECT="["`hostname`"] - System Startup"
SHUTDOWNSUBJECT="["`hostname`"] - System Shutdown"
RESTARTBODY="This is an automated message to notify you that "`hostname`" started successfully.

Start up Date and Time: "`date`
SHUTDOWNBODY="This is an automated message to notify you that "`hostname`" is shutting down.
Shutdown Date and Time: "`date`
LOCKFILE=/var/lock/subsys/SystemEmail
RETVAL=0

# Source function library.
. /etc/init.d/functions

stop()
{
echo -n $"Sending Shutdown Email: "
echo "${SHUTDOWNBODY}" | mail -s "${SHUTDOWNSUBJECT}" ${EMAIL}
RETVAL=$?

if [ ${RETVAL} -eq 0 ]; then
rm -f ${LOCKFILE}
success
else
failure
fi
echo
return ${RETVAL}
}

start()
{
echo -n $"Sending Startup Email: "
echo "${RESTARTBODY}" | mail -s "${RESTARTSUBJECT}" ${EMAIL}
RETVAL=$?

if [ ${RETVAL} -eq 0 ]; then
touch ${LOCKFILE}
success
else
failure
fi
echo
return ${RETVAL}
}

case $1 in
stop)
stop
;;

start)
start
;;

*)

esac
exit ${RETVAL}
0
ответ дан 30 September 2019 в 02:49

Другие вопросы по тегам:

Похожие вопросы: