5 collect-reminders - collect email reminders to be sent out
9 Collect emails reminders set by users for special occasions and move
10 them to the email-reminder spool directory.
14 Email-reminder allows users to define events that they want to be
17 This script is meant to be invoked everyday by a cron job or as the
18 root user. It collects the reminder files from each user.
26 Displays basic usage message.
30 Prints out information about what the program is doing, including the
31 full emails being sent out.
35 Displays the version number.
41 F<~/.email-reminders>, F</etc/email-reminder.conf>
45 Francois Marier <francois@email-reminder.org.nz>
49 email-reminder-editor, send-reminders
53 Copyright (C) 2004-2009 by Francois Marier
55 Email-Reminder is free software; you can redistribute it and/or
56 modify it under the terms of the GNU General Public License as
57 published by the Free Software Foundation; either version 3 of the
58 License, or (at your option) any later version.
60 Email-Reminder is distributed in the hope that it will be useful,
61 but WITHOUT ANY WARRANTY; without even the implied warranty of
62 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
63 General Public License for more details.
65 You should have received a copy of the GNU General Public License
66 along with Email-Reminder; if not, write to the Free Software
67 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
79 use EmailReminder
::Utils
;
81 # Command-line parameters
86 GetOptions
( "verbose" => \
$verbose,
87 "version" => \
$version,
96 my $file = "$homedir/" . $EmailReminder::Utils
::USER_CONFIG_FILE
;
98 my $destination = $EmailReminder::Utils
::SPOOL_DIRECTORY
. '/' . $uid;
99 print "==> Copying $file to $destination\n" if $verbose;
101 # Delete existing file for the user if necessary
102 if (-e
$destination) {
103 if (unlink($destination)) {
104 print "A file for uid $uid was already present and has been removed.\n" if $verbose;
106 die "Could not remove $destination\n";
110 # Copy the file to the spool directory
111 unless (copy
($file, $destination)) {
112 die "Could not copy $file\n";
118 print "No reminders in '$homedir'.\n" if $verbose;
126 my $running_uid = $>;
127 if ($running_uid != 0) {
128 die "This script must be run as root\n";
131 # Iterate through all local users
132 while (my (undef, undef, $uid, undef, undef, undef, undef,
133 $homedir, $shell, undef) = getpwent) {
136 if ($uid =~ /^([0-9]+)$/i) {
139 die "Error: got a non-numeric uid\n";
142 # Try to skip non-human users
143 if (($uid < 1000) || ($uid >= 60000) || ($shell eq '/bin/false')) {
144 print "Skipped non-human uid $uid\n" if $verbose;
149 if ($homedir =~ /^([A-Za-z0-9_\-\/.]+)$/) {
152 die "Error: home directory for uid $uid contains invalid characters\n";
155 copy_reminders
($uid, $homedir);
160 if ($help || $version) {
161 print "collect-reminders $EmailReminder::Utils::VERSION\n";