16
16
if [ ! -e /etc/fetchmailrc ]; then
20
test -f /etc/default/fetchmail || exit 0
21
. /etc/default/fetchmail
22
if [ ! "x$START_DAEMON" = "xyes" ]; then
23
echo "Edit /etc/default/fetchmail to start fetchmail"
20
28
PATH=/sbin:/bin:/usr/sbin:/usr/bin
21
29
DAEMON=/usr/bin/fetchmail
24
32
CONFFILE=/etc/fetchmailrc
25
33
OPTIONS="-f $CONFFILE"
26
34
PIDFILE="`getent passwd $USER | awk -F: '{ print $6 }'`/.fetchmail.pid"
27
UIDL=/var/mail/.fetchmail-UIDL-cache
35
UIDL=/var/lib/fetchmail/.fetchmail-UIDL-cache
29
37
test -f $DAEMON || exit 0
30
38
test -r $CONFFILE || exit 0
48
56
# package is purged. We have to re-add it here so the system-wide
51
adduser --system --ingroup nogroup --home /var/run/fetchmail \
59
adduser --system --ingroup nogroup --home /var/lib/fetchmail \
52
60
--shell /bin/sh --disabled-password fetchmail >/dev/null 2>&1 || true
53
61
# work around possible adduser bug, see #119366
54
[ -d /var/run/fetchmail ] || mkdir -p /var/run/fetchmail
55
chmod 700 /var/run/fetchmail
56
chown -h -R fetchmail:nogroup /var/run/fetchmail
62
[ -d /var/lib/fetchmail ] || mkdir -p /var/lib/fetchmail
63
chmod 700 /var/lib/fetchmail
64
chown -h -R fetchmail:nogroup /var/lib/fetchmail
58
66
log_failure_msg "$USER user does not exist!"
65
73
OPTIONS="$OPTIONS -d 300"
68
# add syslog option if user hasn't already specified it
76
# add syslog option unless user specified "set no syslog".
69
77
if ! grep -qs '^[[:space:]]*set[[:space:]]\+no[[:space:]]\+syslog' "$CONFFILE"; then
70
78
OPTIONS="$OPTIONS --syslog"
73
81
# support for ephemeral /var/run
74
if [ "${PIDFILE%/*}" = "/var/run/fetchmail" ] && [ ! -d ${PIDFILE%/*} ]; then
75
mkdir /var/run/fetchmail
76
chown -h $USER:nogroup /var/run/fetchmail
77
chmod 700 /var/run/fetchmail
82
#if [ "${PIDFILE%/*}" = "/var/run/fetchmail" ] && [ ! -d ${PIDFILE%/*} ]; then
83
# mkdir /var/run/fetchmail
84
# chown -h $USER:nogroup /var/run/fetchmail
85
# chmod 700 /var/run/fetchmail
81
if [ ! -d ${PIDFILE%/*} ]; then
82
log_failure_msg "Directory ${PIDFILE%/*} does not exist!"
89
#if [ ! -d ${PIDFILE%/*} ]; then
90
# echo "$0: directory ${PIDFILE%/*} does not exist!"
86
94
# If the user is going to use a UIDL cache, try to find a better place for the
87
95
# UIDL cache than root's homedir. Also create $UIDL if it doesn't exist,
88
96
# because the daemon won't have the permission.
89
if ! grep -qs idfile "$CONFFILE" && [ -d /var/mail ]; then
97
if ! grep -qs idfile "$CONFFILE" && [ -d /var/lib/fetchmail ]; then
90
98
OPTIONS="$OPTIONS -i $UIDL"
92
100
chown -h $USER $UIDL