misc/122170: New feature: Page admin on startup and shutdown
Leif Pedersen
bilbo at hobbiton.org
Thu Mar 27 16:30:01 PDT 2008
>Number: 122170
>Category: misc
>Synopsis: New feature: Page admin on startup and shutdown
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Thu Mar 27 23:30:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Leif Pedersen
>Release: FreeBSD 7
>Organization:
>Environment:
>Description:
I think it would be appropriate for FreeBSD to include a way
of notifying an administrator when a server starts up or shuts down.
Attached is an rc.d script I currently add to all my machines.
>How-To-Repeat:
>Fix:
Add /etc/rc.d/sendpage.sh containing the file below. The file is also
available temporarily from http://bilbo.hobbiton.org/sendpage.sh
#!/bin/sh
#
# Copyright (c) 2008 Leif Pedersen
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#
# PROVIDE: sendpage
# REQUIRE: LOGIN
# BEFORE:
# KEYWORD: shutdown
# Sends a page to admins when the machine boots or shuts down. Example:
# sendpage_enable="YES"
# sendpage_command="qpage -f '' -p root"
sendpage_enable=${sendpage_enable-"NO"}
sendpage_command=${sendpage_command-'read subj; echo $subj | mail -s "$subj" root'}
. /etc/rc.subr
name="sendpage"
rcvar=`set_rcvar`
load_rc_config $name
start_cmd="sendpage_start"
stop_cmd="sendpage_stop"
timestamp=`date "+%Y-%m-%d %H:%M"`
sendpage_start()
{
echo "Sending startup page."
echo "`hostname -s` coming up at $timestamp" | eval "$sendpage_command"
}
sendpage_stop()
{
echo "Sending shutdown page."
echo "`hostname -s` going down at $timestamp" | eval "$sendpage_command"
}
run_rc_command "$1"
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list