Port things from MSN to WLM plugin:
[kdenetwork.git] / kopete / protocols / winpopup / winpopup-send.sh
blob177325b98c2aa7d8841901117b4c9f2b7b3901dc
1 #!/bin/bash
2 PATH=/bin:/usr/bin/:/usr/local/bin
4 # Check input
5 [ -z "$1" -o -z "$2" ] && exit 1
7 # Check if file is indeed a file and readable
8 [ ! -f "$1" -o ! -r "$1" ] && exit 1
10 KOPETE_RUNNING=x`ps -A|grep -e "kopete$"`
12 if [ "$KOPETE_RUNNING" = "x" ]; then
14 if [ -z "$3" ]; then
15 THIS_SERVER=`uname -n`
16 else
17 THIS_SERVER="$3"
20 if [ "$2" != "$THIS_SERVER" ]; then
21 echo -e "Kopete is currently not running.\nYour message was not delivered!" \
22 | smbclient -N -M $2
25 else
27 # Create a unique filename
28 filename="/var/lib/winpopup/`date +%s_%N`"
30 # the time...
31 TIME=`date --iso-8601=seconds`
33 # the message
34 MESSAGE=`cat "$1"`
36 # Put it into the file
37 echo -e "$2\n$TIME\n$MESSAGE" > $filename
42 # Remove the message from samba
43 rm -f "$1"