[1241] | 1 | #! /bin/sh |
---|
| 2 | # |
---|
[3260] | 3 | # PyKota : Print Quotas for CUPS |
---|
[1241] | 4 | # |
---|
[3275] | 5 | # (c) 2003, 2004, 2005, 2006, 2007, 2008 Jerome Alet <alet@librelogiciel.com> |
---|
[3260] | 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. |
---|
[3413] | 10 | # |
---|
[3260] | 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. |
---|
[3413] | 15 | # |
---|
[3260] | 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/>. |
---|
[1241] | 18 | # |
---|
| 19 | # $Id$ |
---|
| 20 | # |
---|
[1527] | 21 | PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/opt/bin |
---|
| 22 | # |
---|
[1241] | 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 |
---|
[1527] | 33 | UTF8MESSAGE=`echo "$MESSAGE" | iconv --to-code utf-8 --from-code iso-8859-15` |
---|
[1241] | 34 | # |
---|
| 35 | # Send original message to user |
---|
[1527] | 36 | mail -s "Print Quota problem" $RECIPIENT <<EOF1 |
---|
[1241] | 37 | $MESSAGE |
---|
| 38 | EOF1 |
---|
[3413] | 39 | # |
---|
[1241] | 40 | # Send some information to root as well |
---|
[1527] | 41 | mail -s "Print Quota problem on printer $PNAME" root <<EOF2 |
---|
[1241] | 42 | Print Quota problem for user $UNAME |
---|
| 43 | EOF2 |
---|
| 44 | # |
---|
[3413] | 45 | # Launch WinPopup on user's host (may need a real Samba or NT domain) |
---|
[1697] | 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: |
---|
[2588] | 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 ; |
---|
[1697] | 52 | done |
---|