#!/bin/sh # # Resource script for sending WinPopups using smbclient # derived from Alan Robertson's MailTo script # # Author: Sandro Poppi <spoppi@gmx.de> # # Description: sends WinPopups to a sysadmin's workstation # whenever a takeover occurs. # # Note: This command requires an argument, unlike normal init scripts. # # This can be given in the haresources file as: # # WinPopup::hosts # # where "hosts" is a file containing the IPs/Workstation names # one by line to be sent WinPopups # # License: GPL ARGS="$0 $*" # Source function library. . /etc/ha.d/shellfuncs us=`uname -n` usage() { echo "Usage: $0 [workstationfile] {start|stop|status}" echo "$Id: WinPopup.in,v 1.2 2002/03/14 04:28:51 alan Exp $" exit 1 } sendWinPopup() { # if workstation file exists and is not zero if [ -s "$hostfile" ] ; then subject=$1 shift for i in `cat $hostfile` ; do echo "$subject $*" | smbclient -M $i >/dev/null 2>&1 done else logger -is -t HA-WinPopup "ERROR: Workstation file $hostfile missing or corrupt!" exit 2 fi } SubjectLine() { case $1 in ??*) echo $1;; *) echo "Resource Group";; esac } WinPopupStart() { Subject="`SubjectLine $2` Takeover in progress on $us" sendWinPopup "$Subject" $1 } WinPopupStop () { Subject="`SubjectLine $2` Reestablishing original master connection in progress on $us" sendWinPopup "$Subject" $1 } # max. 2 parameters allowed if [ $# -gt 2 ] ; then echo "Additional parameters found: $# but only 2 are allowed!" usage fi # See how we were called. if [ "$1" != "start" -a "$1" != "stop" ] ; then # optional parameter found cmd=$2 hostfile=$1 else cmd=$1 hostfile="hosts" fi case "$cmd" in start) WinPopupStart ;; stop) WinPopupStop ;; # Not quite sure what to do with this one... status) echo "status not implemented yet" ;; *) usage esac exit 0