1 | #! /bin/sh |
---|
2 | # |
---|
3 | # PyKota - Print Quotas for CUPS and LPRng |
---|
4 | # |
---|
5 | # (c) 2003, 2004, 2005 Jerome Alet <alet@librelogiciel.com> |
---|
6 | # You're welcome to redistribute this software under the |
---|
7 | # terms of the GNU General Public Licence version 2.0 |
---|
8 | # or, at your option, any higher version. |
---|
9 | # |
---|
10 | # You can read the complete GNU GPL in the file COPYING |
---|
11 | # which should come along with this software, or visit |
---|
12 | # the Free Software Foundation's WEB site http://www.fsf.org |
---|
13 | # |
---|
14 | # $Id$ |
---|
15 | # |
---|
16 | PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/opt/bin |
---|
17 | # |
---|
18 | # user's name |
---|
19 | UNAME=$1 |
---|
20 | # printer's name |
---|
21 | PNAME=$2 |
---|
22 | # message's recipient |
---|
23 | RECIPIENT=$3 |
---|
24 | # message's body |
---|
25 | MESSAGE=$4 |
---|
26 | # |
---|
27 | # Convert message body to UTF8 for WinPopup |
---|
28 | UTF8MESSAGE=`echo "$MESSAGE" | iconv --to-code utf-8 --from-code iso-8859-15` |
---|
29 | # |
---|
30 | # Send original message to user |
---|
31 | mail -s "Print Quota problem" $RECIPIENT <<EOF1 |
---|
32 | $MESSAGE |
---|
33 | EOF1 |
---|
34 | # |
---|
35 | # Send some information to root as well |
---|
36 | mail -s "Print Quota problem on printer $PNAME" root <<EOF2 |
---|
37 | Print Quota problem for user $UNAME |
---|
38 | EOF2 |
---|
39 | # |
---|
40 | # Launch WinPopup on user's host (may need a real Samba or NT domain) |
---|
41 | # In some cases the username does not suffice for smbclient to send a message; |
---|
42 | # we must also supply the IP address. This will use smbstatus to get all IPs |
---|
43 | # where the user is logged in and send the message there: |
---|
44 | IPS=`smbstatus -b -u $UNAME | grep '(' | cut -d'(' -f 2 | cut -d')' -f 1` |
---|
45 | for i in $IPS; do |
---|
46 | echo $UTF8MESSAGE | smbclient -M "$UNAME" -I $i 2>&1 >/dev/null; |
---|
47 | done |
---|