File: remind-all.sh

package info (click to toggle)
remind 03.00.19-2
  • links: PTS
  • area: non-free
  • in suites: potato
  • size: 1,452 kB
  • ctags: 1,712
  • sloc: ansic: 14,190; sh: 2,496; perl: 314; makefile: 165; csh: 14
file content (54 lines) | stat: -rw-r--r-- 1,704 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
# Shell script to mail all users reminders.

# This file is part of REMIND
#
# $Id: remind-all.sh,v 1.2 1998/02/14 03:56:27 dfs Exp $
#
# REMIND is Copyright (C) 1992-1998 by David F. Skoll        
# This file is Copyright (C) 1990 by Bill Aten

# Thanks to Bill Aten for this script.

# Run it AFTER MIDNIGHT so that date is correct!
# On our system, we have the following in our crontab:
# 02 00 * * * /usr/local/adm/remind-all >/dev/null 2>&1

# This script must be run by root.  The -u option MUST be supplied
# to Remind, or a severe security hole will exist.  Note that Remind
# must be compiled to support the -u option for this script to work.
# Also, the -r and -q options must be used.

# The following line gets a list of users for systems using SUN's
# NIS service:
# USERS=`ypcat passwd | awk -F: '{print $1}'`

# The following line gets a list of users by examining /etc/passwd:
USERS=`awk -F: '{print $1}' /etc/passwd`

# If neither of the above methods works, you must come up with some
# way of getting a list of users on the system

# Set the following variables as appropriate for your system
REMIND=/usr/local/bin/remind
MAIL=/usr/bin/mail
RM="/bin/rm -f"

REMFILE=/tmp/RemFile.$$

# Scan each user's directory for a .reminders file
for i in $USERS
do
HOME=`grep \^$i: /etc/passwd | awk -F: '{print $6}'`
   if [ -r $HOME/.reminders ]; then

#     echo "$i has a .reminders file."     DEBUGGING PURPOSES ONLY

      $REMIND -u$i -h -r -q -iremind_all=1 $HOME/.reminders < /dev/null > $REMFILE
      if [ -s $REMFILE ]; then
#        echo "Sending mail to $i"         DEBUGGING PURPOSES ONLY
         $MAIL -s "Reminders" $i < $REMFILE
      fi
      $RM $REMFILE
   fi
done