File: fetchmail.postinst

package info (click to toggle)
fetchmail 6.4.0~beta4-3%2Bdeb10u1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 9,552 kB
  • sloc: ansic: 29,999; sh: 6,119; perl: 3,181; python: 1,957; yacc: 459; lex: 275; makefile: 229; awk: 124; lisp: 84; exp: 43; sed: 16
file content (65 lines) | stat: -rw-r--r-- 1,817 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
#!/bin/sh
#
# Postinst script for fetchmail
# $Id: fetchmail.postinst 469 2008-05-18 12:47:05Z nion $
#

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/false --disabled-password fetchmail
fi

# if the login shell is not /bin/false, change this, see #481727
LOGINSH=$(getent passwd fetchmail | cut -d ':' -f 7)
if [ "x$LOGINSH" != "x/bin/false" ]; then
	chsh -s /bin/false 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
 
#DEBHELPER#

exit 0

# vim:ts=4:sw=4: