summaryrefslogtreecommitdiff
path: root/tools/zsubscriptions
blob: b9a9e79265176586e939db332bcce9b46407ae56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
#
# author: "Jr" Spidell
# date  : 4/25/92
#
USAGE="zsubscriptions <user>"
DBFILE=/usr/tmp/zephyr.db       # where zephyrd dumps its data after a kill -FPE

# test for root
if test "`whoami`" != root
 then
   echo "you must be root to run this script"
   exit
fi

# test for no options
if test $# -eq 0
then USAGE="yes"
     echo "no options given."
     echo $USAGE
     echo ""
     exit
fi

# test for server node
if test -z "`ps aux | grep zephyrd | grep -v grep | awk '{print $2}'`"
 then echo "you must be on a zephyr server (ie cap, fred)"
      exit
fi

# root doesn't have this in its path
path=$PATH
PATH=$path":/usr/local/bin:/bin:/usr/athena:"

# dump the database
kill -FPE `ps aux | grep zephyrd | grep -v grep | awk '{print $2}'`

user=$1

nawk ' BEGIN {user=""}
      {if ((NF > 1) && (NF < 4))
       {
        if (NF == 2)
         {
          user=$2
          next
         }
        print user,$0
       }
      }' /net/cap/usr/tmp/zephyr.db  | \
sed s/.cca.cr.rockwell.com//g | sed s/"("//g | sed s/")"//g |\
sed s/"'"//g | sed s/":"//g > /tmp/users

echo ""
echo "$user is subscribed to recieve the following message types:"
echo ""

nawk ' {if ($1 == uname)
       {printf ("%-20s%-20s%-20s\n",$2,$3,$4)}}' uname=$user /tmp/users

echo ""