Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 387009 | Differences between
and this patch

Collapse All | Expand All

(-)fetchmail (-9 / +54 lines)
Lines 2-19 Link Here
2
2
3
piddir=${pid_dir:-/var/run/fetchmail}
3
piddir=${pid_dir:-/var/run/fetchmail}
4
pid_file=${piddir}/${RC_SVCNAME}.pid
4
pid_file=${piddir}/${RC_SVCNAME}.pid
5
rcfile=/etc/${RC_SVCNAME}rc
5
6
# Need to define this variable here to make it global instead of local
7
rcfile=""
6
8
7
depend() {
9
depend() {
8
	need net
10
	need net
9
	use mta
11
	use mta
10
}
12
}
11
13
14
getrc() {
15
# This function  accepts a single (optional) parameter: quiet
16
	if [ -z "${fetchmail_config}" ]; then
17
		# Config is not explicitly set in the relevant conf.d file
18
		if [ -z "${fetchmail_rc}" ]; then
19
			# User does not specify which file to use. Let's go find the right one
20
			if   [ -f /etc/${RC_SVCNAME}.rc ]; then
21
				# Newer naming system
22
				rcfile="/etc/${RC_SVCNAME}.rc"
23
			elif [ -f /etc/${RC_SVCNAME}rc ]; then
24
				# Older naming system
25
				rcfile="/etc/${RC_SVCNAME}rc"
26
			else
27
				[ "x$1" != "xquiet" ] && eerror "Can't find any proper configuration for ${RC_SVCNAME}"
28
				return 1
29
			fi
30
		else
31
			if [ -f ${fetchmail_rc} ]; then
32
				rcfile="${fetchmail_rc}"
33
			else
34
				[ "x$1" != "xquiet" ] && eerror "Can't find ${fetchmail_rc} configuration file for ${RC_SVCNAME}"
35
				return 1
36
			fi
37
		fi
38
		[ "x$1" != "xquiet" ] && einfo "Using configuration file: ${rcfile}"
39
	else
40
		[ "x$1" != "xquiet" ] && einfo "Using provided configuration in /etc/conf.d/${RC_SVCNAME}"
41
		# Config is explicitly specified. Let's dump it into a file to be read back by fetchmail
42
		# Why dumping it into a file instead of other methods (e.g., named pipe)? This allows
43
		# troubleshooting.
44
		rcfile=${piddir}/${RC_SVCNAME}.rc
45
		echo "${fetchmail_config}" > $rcfile
46
	fi
47
	# Ensure ownership and permissions to prevent fetchmail from complaining
48
	# Only the user needs to be changed; fetchmail is okay with any group
49
	chown fetchmail $rcfile
50
	chmod 0700 $rcfile
51
}
52
12
checkconfig() {
53
checkconfig() {
13
	if [ ! -f ${rcfile} ]; then
54
	if [ ! -d ${piddir} ]; then
14
		eerror "Configuration file ${rcfile} not found"
55
		checkpath -q -d -o fetchmail:fetchmail -m 0755 ${piddir} || return 1
15
		return 1
16
	fi
56
	fi
57
	getrc || return 1
17
	local fetchmail_instance
58
	local fetchmail_instance
18
	fetchmail_instance=${RC_SVCNAME##*.}
59
	fetchmail_instance=${RC_SVCNAME##*.}
19
	if [ -n "${fetchmail_instance}" -a "${RC_SVCNAME}" != "fetchmail" ]; then
60
	if [ -n "${fetchmail_instance}" -a "${RC_SVCNAME}" != "fetchmail" ]; then
Lines 21-33 Link Here
21
	else
62
	else
22
		fidfile=/var/lib/fetchmail/.fetchids
63
		fidfile=/var/lib/fetchmail/.fetchids
23
	fi
64
	fi
24
	if [ ! -d ${piddir} ]; then
25
		checkpath -q -d -o fetchmail:fetchmail -m 0755 ${piddir} || return 1
26
	fi
27
}
65
}
28
66
29
start() {
67
start() {
30
        checkconfig || return 1
68
	checkconfig || return 1
31
	ebegin "Starting ${RC_SVCNAME}"
69
	ebegin "Starting ${RC_SVCNAME}"
32
	start-stop-daemon --start --pidfile ${pid_file} \
70
	start-stop-daemon --start --pidfile ${pid_file} \
33
		--user fetchmail --exec /usr/bin/fetchmail \
71
		--user fetchmail --exec /usr/bin/fetchmail \
Lines 40-44 Link Here
40
	ebegin "Stopping ${RC_SVCNAME}"
78
	ebegin "Stopping ${RC_SVCNAME}"
41
	start-stop-daemon --stop --quiet --pidfile ${pid_file}
79
	start-stop-daemon --stop --quiet --pidfile ${pid_file}
42
	eend ${?}
80
	eend ${?}
43
}
44
81
82
	# To assist troubleshooting (e.g., starting from shell using
83
	# 'fetchmail -v -f $rcfile'), we do the courtesy of changing
84
	# $rcfile's owner.
85
	if getrc ; then
86
		chown root $rcfile
87
		chmod 0700 $rcfile
88
	fi
89
}

Return to bug 387009