~ubuntu-branches/debian/jessie/tsdecrypt/jessie

« back to all changes in this revision

Viewing changes to notify-script.example

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2012-04-04 09:42:43 UTC
  • Revision ID: package-import@ubuntu.com-20120404094243-qsc40h18oolnxw5r
Tags: upstream-7.0
ImportĀ upstreamĀ versionĀ 7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# Example tsdecrypt notify script
 
3
# Written by Georgi Chorbadzhiyski
 
4
#
 
5
# *** Released as PUBLIC DOMAIN ***
 
6
# *** Do whatever you want with this code ***
 
7
 
 
8
EMAIL_ENABLED="yes"
 
9
EMAIL_TO="georgi@unixsol.org" # !!! Change this !!!
 
10
EMAIL_FROM="georgi@unixsol.org" # !!! Change this !!!
 
11
EMAIL_SUBJECT_PREFIX="[tsdecrypt]"
 
12
EMAIL_PROGRAM="/usr/sbin/sendmail -t -i"
 
13
 
 
14
LOG_ENABLED="yes"
 
15
LOG_DIR="."
 
16
LOG_FILE="$LOGDIR/notify.${_IDENT}.notify.log"
 
17
 
 
18
# Environmental vars that are set by the calling process (tsdecrypt):
 
19
#   _TS             Unix timestamp of the event.
 
20
#   _IDENT          tsdecrypt ident (--ident parameter).
 
21
#   _MESSAGE_ID     Event message id (For example START, STOP, etc...).
 
22
#   _MESSAGE_TEXT   Event message text. Human readable event message.
 
23
#   _MESSAGE_MSG    Event message id lower cased and "_" is replaced with " "
 
24
 
 
25
export PATH="/bin:/usr/bin:/usr/local/bin"
 
26
export LC_ALL=C
 
27
 
 
28
if [ -z "${_IDENT}" -o -z "${_TS}" ]
 
29
then
 
30
        echo "This script must be run from tsdecrypt."
 
31
        echo "In order for tsdecrypt to run this script use --ident and --notify-prg options."
 
32
        echo
 
33
        echo "Example:"
 
34
        echo "   tsdecrypt --ident SOURCE/CHANNEL --notify-program ./notify-script.example --camd-server x.x.x.x"
 
35
        echo
 
36
        exit 1
 
37
fi
 
38
 
 
39
if [ "$LOG_ENABLED" = "yes" ]
 
40
then
 
41
        LOG_DATE="$(date +%F\ %T\ %z -d @${_TS})"
 
42
        printf "%s | %s | %-16s | %s\n" \
 
43
                "$LOG_DATE" \
 
44
                "${_IDENT}" \
 
45
                "${_MESSAGE_ID}" \
 
46
                "${_MESSAGE_TEXT}" \
 
47
                  >> $LOG_DIR/$LOG_FILE
 
48
fi
 
49
 
 
50
if [ "$EMAIL_ENABLED" = "yes" ]
 
51
then
 
52
        (
 
53
                echo "To: <$EMAIL_TO>"
 
54
                echo "From: <$EMAIL_FROM>"
 
55
                echo "Return-Path: <$EMAIL_FROM>"
 
56
                echo "Subject: $EMAIL_SUBJECT_PREFIX ${_IDENT} ${_MESSAGE_MSG}"
 
57
                echo "X-IDENT: ${_IDENT}"
 
58
                echo "X-MSG-ID: ${_MESSAGE_ID}"
 
59
                echo "X-Mailer: tsdecrypt"
 
60
                echo
 
61
                echo "${_IDENT} ${_MESSAGE_TEXT}"
 
62
        ) | $EMAIL_PROGRAM
 
63
fi