File: postinst

package info (click to toggle)
mailscanner 4.79.11-2.2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,820 kB
  • ctags: 1,309
  • sloc: perl: 25,655; sh: 2,666; xml: 624; makefile: 242
file content (124 lines) | stat: -rw-r--r-- 3,519 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#! /bin/sh -e
# postinst script for mailscanner
#
# see: dh_installdeb(1)

statedir="/var/lib/MailScanner"

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see /usr/share/doc/packaging-manual/
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

. /usr/share/debconf/confmodule

install_default()
{
    if [ ! -f /etc/default/mailscanner ]; then
	cat > /etc/default/mailscanner <<-EOF
	#
	# This sets how many days files will remain in the "quarantine" area before
	# being automatically removed.
	#
	q_days=7

	#
	# This sets how much the priority of the mailscanner daemon should be
	# reduced by (i.e. "nice -X").  Since it is a batch oriented task,
	# there it can easily give up some CPU cycles to more interactive
	# tasks.
	#
	run_nice=2

	#
	# Uncomment this line once MailScanner has been fully configured.
	#
	#run_mailscanner=1
	EOF
    fi
}

#UCF#

case "$1" in
    configure)
				domain=`hostname -d`
				if [ -n "$domain" ]; then
						sed -e "s/put\.your\.domain\.name\.here/$domain/" \
								/etc/MailScanner/MailScanner.conf \
								> /etc/MailScanner/MailScanner.conf.new
						if cmp -s /etc/MailScanner/MailScanner.conf \
								/etc/MailScanner/MailScanner.conf.new
						then
								rm -f /etc/MailScanner/MailScanner.conf.new
						else
								mv -f /etc/MailScanner/MailScanner.conf.new \
										/etc/MailScanner/MailScanner.conf
						fi
				fi

				if [ -n "$2" ]; then
						if dpkg --compare-versions "$2" lt 4.40; then
								chown --reference=/var/spool/MailScanner \
										/var/lock/subsys/MailScanner
						fi
				fi

#	install_default
# currently a conffile, instead
# move files from any previously installed location
				for dir in  /var/spool/MailScanner /var/spool/mailscanner \
						/var/state/MailScanner /var/state/mailscanner \
						/var/lib/MailScanner   /var/lib/mailscanner   \
						~root/.spamassassin ~mail/.spamassassin; do
						if [ "$dir" = "$statedir" ]; then continue; fi
						if [ ! -d "$dir" ]; then continue; fi
						for file in auto-whitelist bayes_journal bayes_msgcount bayes_seen bayes_toks; do
								if [ -f $dir/$file ]; then
										if [ -f $statedir/$file ]; then
												if [ $dir/$file -nt $statedir/$file ]; then
														mv $dir/$file $statedir/$file
												else
														rm -f $dir/$file
												fi
										else
												mv $dir/$file $statedir/$file
										fi
								fi
						done
						rm -f $dir/bayes.* || true
						rmdir $dir >/dev/null 2>&1 || true
				done
				rm -rf /var/spool/mailscanner
				;;

    abort-upgrade|abort-remove|abort-deconfigure)

				;;

    *)
	echo "postinst called with unknown argument \`$1'" >&2
	exit 0
				;;
esac

db_stop

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0