~ubuntu-branches/ubuntu/natty/amavisd-new/natty

« back to all changes in this revision

Viewing changes to debian/amavisd-new-cronjob

  • Committer: Bazaar Package Importer
  • Author(s): Christian Perrier
  • Date: 2007-02-24 19:27:53 UTC
  • mfrom: (3.1.7 feisty)
  • Revision ID: james.westby@ubuntu.com-20070224192753-fvvima53q1jrp34x
Tags: 1:2.4.2-6.1
* Non-maintainer upload to fix pending l10n issues.
* Debconf translations
  - Remove extra debian/po/de.po~
  - Convert all translation files to UTF-8
  - Russian. Closes: #405243
  - Spanish. Closes: #408734
  - Italian. Closes: #409831
* Add very simple LSB headers to init scripts

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# amavisd-new cronjob helper
 
4
#
 
5
# Run it as root or as the amavis user
 
6
#
 
7
# First parameter specifies which cronjob routine to run:
 
8
#               sa-sync:        spamassassin fast sync
 
9
#               sa-clean:       spamassassin cleanup
 
10
 
 
11
test -e /usr/bin/sa-learn || exit 0
 
12
test -e /usr/sbin/amavisd-new || exit 0
 
13
 
 
14
SUUSER="amavis"
 
15
unset IFS
 
16
 
 
17
set -e
 
18
umask 022
 
19
 
 
20
# WATCH OUT FOR PROPER QUOTING LEVEL WHEN CALLING THIS!
 
21
do_amavis_cmd() {
 
22
        if [ "$(id -u -n)" != "${SUUSER}" ]; then
 
23
                exec /bin/su -s /bin/sh - "${SUUSER}" -c "$*"
 
24
        else
 
25
                # to get the same quoting level as the su path
 
26
                eval exec "$*"
 
27
        fi
 
28
}
 
29
 
 
30
case $1 in
 
31
        sa-sync)
 
32
                do_amavis_cmd "/usr/bin/sa-learn --sync" '>/dev/null'
 
33
                ;;
 
34
        sa-clean)
 
35
                do_amavis_cmd "/usr/bin/sa-learn --sync --force-expire" '>/dev/null'
 
36
                ;;
 
37
        *)
 
38
                echo "$0: unknown cron routine $1" >&2
 
39
                exit 1
 
40
                ;;
 
41
esac
 
42
 
 
43
exit 0