/[LeafOK_CVS]/pvpgn-1.7.4/scripts/announce.sh
ViewVC logotype

Annotation of /pvpgn-1.7.4/scripts/announce.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Tue Jun 6 03:41:37 2006 UTC (19 years, 9 months ago) by sysadm
CVS Tags: pvpgn_1-7-4-0_MIL
Branch point for: GNU, MAIN
Content type: text/x-sh
Initial revision

1 sysadm 1.1 #!/bin/sh
2     # This script is to announce a message on a server automatically
3     # and repeatedly. It is intended for server admin use.
4     # Here is an example:
5     #
6     # announce.sh localhost account password 30 "Attention: Here is an
7     # announcement\nAnd here is another announcement"
8     #
9     # The bnchat program can be obtained from the bnetd package.
10    
11     BNCHAT=bnchat
12     PIPE="/tmp/pipe-bnannounce-$$"
13    
14    
15     cleanup () {
16     kill -9 "${pid}" 2> /dev/null
17     rm -f "${PIPE}" 2> /dev/null
18     exit 0
19     }
20    
21    
22     if [ -z "$4" ]; then
23     echo -e "Usage: $0 server account password interval [msgs] ..."
24     echo -e " server server ip or hostname"
25     echo -e " account your server account"
26     echo -e " password password for your account"
27     echo -e " interval time intervals between announce in seconds"
28     echo -e " [msgs] messages you want to announce"
29     echo
30     echo -e "Notes: Your account should have announce or admin permissions"
31     echo -e " If interval is zero then bnannounce will only print"
32     echo -e " one copy of the announcement."
33     echo
34     exit
35     fi
36    
37     rm -f "${PIPE}"
38     mknod "${PIPE}" p > /dev/null
39     if [ $? -ne 0 ] ; then
40     echo "$0: failed to make pipe file ${PIPE}, check your permissions." >&2
41     exit 1
42     fi
43    
44     server="$1"
45     user="$2"
46     pass="$3"
47     interval="$4"
48     shift 4
49     msg="`echo -e "$*" | sed -e 's/^/\/announce /g'`"
50    
51     "${BNCHAT}" < "${PIPE}" > /dev/null 2>&1 &
52     pid="$!"
53     trap "eval cleanup" SIGINT SIGQUIT SIGTERM EXIT
54    
55     echo -e "${user}" > "${PIPE}"
56     echo -e "${pass}" > "${PIPE}"
57     echo "/join Support" > "${PIPE}"
58    
59     while kill -0 "${pid}" 2> /dev/null; do
60     echo "/announce ${msg}" > "${PIPE}"
61     if [ "${interval}" -lt "1" ]; then
62     exit
63     fi
64     sleep "${interval}"
65     done
66    
67     exit

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1