1 | #! /bin/sh |
---|
2 | # |
---|
3 | # PyKota : Print Quotas for CUPS |
---|
4 | # |
---|
5 | # (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet <alet@librelogiciel.com> |
---|
6 | # This program is free software: you can redistribute it and/or modify |
---|
7 | # it under the terms of the GNU General Public License as published by |
---|
8 | # the Free Software Foundation, either version 3 of the License, or |
---|
9 | # (at your option) any later version. |
---|
10 | # |
---|
11 | # This program is distributed in the hope that it will be useful, |
---|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | # GNU General Public License for more details. |
---|
15 | # |
---|
16 | # You should have received a copy of the GNU General Public License |
---|
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
18 | # |
---|
19 | # $Id$ |
---|
20 | # |
---|
21 | PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/opt/bin |
---|
22 | # |
---|
23 | # user's name |
---|
24 | UNAME=$1 |
---|
25 | # printer's name |
---|
26 | PNAME=$2 |
---|
27 | # message's recipient |
---|
28 | RECIPIENT=$3 |
---|
29 | # message's body |
---|
30 | MESSAGE=$4 |
---|
31 | # |
---|
32 | # Convert message body to UTF8 for WinPopup |
---|
33 | UTF8MESSAGE=`echo "$MESSAGE" | iconv --to-code utf-8 --from-code iso-8859-15` |
---|
34 | # |
---|
35 | # Send original message to user |
---|
36 | mail -s "Print Quota problem" $RECIPIENT <<EOF1 |
---|
37 | $MESSAGE |
---|
38 | EOF1 |
---|
39 | # |
---|
40 | # Send some information to root as well |
---|
41 | mail -s "Print Quota problem on printer $PNAME" root <<EOF2 |
---|
42 | Print Quota problem for user $UNAME |
---|
43 | EOF2 |
---|
44 | # |
---|
45 | # Launch WinPopup on user's host (may need a real Samba or NT domain) |
---|
46 | # In some cases the username does not suffice for smbclient to send a message; |
---|
47 | # we must also supply the IP address. This will use smbstatus to get all IPs |
---|
48 | # where the user is logged in and send the message there: |
---|
49 | IPS=`smbstatus -b -u "$UNAME" | grep "$UNAME" | cut -d '(' -f 2,2 | cut -d ')' -f 1,1` |
---|
50 | for i in $IPS ; do |
---|
51 | echo "$UTF8MESSAGE" | smbclient -M "$UNAME" -I $i 2>&1 ; |
---|
52 | done |
---|