File: fetchmail.postinst

package info (click to toggle)
fetchmail 6.3.6-1etch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 6,344 kB
  • ctags: 3,617
  • sloc: ansic: 26,507; sh: 4,967; perl: 3,180; python: 1,920; yacc: 448; makefile: 331; lex: 277; awk: 124; lisp: 84; sed: 16
file content (68 lines) | stat: -rw-r--r-- 1,850 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
#
# Postinst script for fetchmail
# $Id: fetchmail.postinst 333 2006-03-27 17:20:45Z nion-guest $
#

set -e

# Create fetchmail user and its homedir if we may need it
if ! getent passwd fetchmail >/dev/null; then
	adduser --system --ingroup nogroup --home /var/lib/fetchmail \
	--shell /bin/sh --disabled-password fetchmail
fi
if ! [ -d /var/lib/fetchmail ]; then
    mkdir -p /var/lib/fetchmail
fi
chmod 700 /var/lib/fetchmail
chown -h -R fetchmail:nogroup /var/lib/fetchmail

# Code to handle the upgrade to use /etc/default/fetchmail
case "$1" in
  configure)
    if dpkg --compare-versions "$2" lt 6.3.1
	then
		if [ -e /etc/fetchmailrc ]
		then
			if [ `grep -c poll /etc/fetchmailrc` ]
			then
				# If /etc/fetchmailrc exits and is defined a pool line
				# I assume is correctly configured and make the default to
				# run on boot
				FILE=`mktemp`
				cat /etc/default/fetchmail | sed 's/START_DAEMON=no/START_DAEMON=yes/' > $FILE
				mv $FILE /etc/default/fetchmail
			fi
		fi
		# update home directory for old installations because of #327250
		usermod -d /var/lib/fetchmail fetchmail

		# Removing old /var/run/fetchmail if empty
	    rm -f "/var/run/fetchmail/.fetchids" >/dev/null 2>&1 || true
		rm -f "/var/run/fetchmail/.fetchmail-UIDL-cache" >/dev/null 2>&1 || true
		if [ ! -f "/var/lib/fetchmail/.fetchmail.pid" ]
		then
			mv "/var/run/fetchmail/.fetchmail.pid" "/var/lib/fetchmail/.fetchmail.pid" >/dev/null 2>&1 || true
		fi
	    rmdir "/var/run/fetchmail" >/dev/null 2>&1 || true
	fi
    ;;
  abort-upgrade|abort-remove|abort-deconfigure)
    ;;
esac
 
if [ -x /etc/init.d/fetchmail ]; then
	update-rc.d fetchmail defaults 99 15 >/dev/null

	if [ -x /usr/sbin/invoke-rc.d ]; then
		invoke-rc.d --quiet fetchmail start || true
	else
		/etc/init.d/fetchmail start || true
	fi
fi

#DEBHELPER#

exit 0

# vim:ts=4:sw=4: