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

Collapse All | Expand All

(-)/usr/portage/net-proxy/c-icap/files/c-icap.init.3 (-5 / +55 lines)
Lines 1-17 Link Here
1
#!/sbin/openrc-run
1
#!/sbin/openrc-run
2
# Copyright 1999-2012 Gentoo Foundation
2
# Copyright 1999-2017 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
3
# Distributed under the terms of the GNU General Public License v2
4
4
5
: ${configfile:=/etc/c-icap/c-icap.conf}
5
: ${configfile:=/etc/c-icap/${SVCNAME}.conf}
6
6
7
get_config() {
7
get_config() {
8
    local value=$(awk '$1 == "'$1'" { print $2 }' ${configfile})
8
    local value=$(awk '$1 == "'$1'" { print $2 }' ${configfile})
9
    echo ${value:-$2}
9
    echo ${value:-$2}
10
}
10
}
11
11
12
description="C-ICAP service"
13
description_checkconfig="Check config for ${SVCNAME}"
14
description_reload="Live config reload"
15
description_relog="Close and re-open all log files"
16
12
command="/usr/libexec/c-icap"
17
command="/usr/libexec/c-icap"
13
command_arguments="${EXTRA_OPTS} -f ${configfile}"
18
command_arguments="${EXTRA_OPTS} -f ${configfile}"
14
pidfile=$(get_config PidFile /var/run/c-icap/c-icap.pid)
19
extra_started_commands="relog reload"
20
extra_commands="checkconfig"
21
22
pidfile=$(get_config PidFile /var/run/c-icap/${SVCNAME}.pid)
23
cmdsocket=$(get_config CommandsSocket /var/run/c-icap/${SVCNAME}.ctl)
24
25
[[ -z "${MAXWAITONSTOP// }" ]] || stop_retry="--retry ${MAXWAITONSTOP}"
15
26
16
depend() {
27
depend() {
17
	need localmount
28
	need localmount
Lines 19-26 Link Here
19
	[ "$(get_config Logger file_logger)" = "sys_logger" ] && use logger
30
	[ "$(get_config Logger file_logger)" = "sys_logger" ] && use logger
20
}
31
}
21
32
22
start_pre() {
33
checkpidinfo() {
23
	local cmdsocket=$(get_config CommandsSocket /var/run/c-icap/c-icap.ctl)
34
	if [ ! -e ${pidfile} ]; then
35
		eerror "${SVCNAME} isn't running (${pidfile} not found)!"
36
		return 1
37
	else
38
		pidnum=$(cat ${pidfile})
39
		if [ ${#pidnum} -eq 0 ]; then
40
			eerror "Could not determine PID of ${SVCNAME} (${pidfile} empty)! Did the service ever start?"
41
			return 1
42
		fi
43
		pidcheck="$(ps -eo pid | grep -c ${pidnum})"
44
		if [ $((pidcheck)) -ne 1 ]; then
45
			eerror "Could not determine PID of ${SVCNAME}! Did the service crash?"
46
			return 1
47
		fi
48
	fi
49
}
24
50
51
start_pre() {
25
	checkpath -d "$(dirname "${cmdsocket}")" "$(dirname "${pidfile}")"
52
	checkpath -d "$(dirname "${cmdsocket}")" "$(dirname "${pidfile}")"
26
}
53
}
54
55
stop() {
56
	ebegin "Stopping ${SVCNAME}"
57
	start-stop-daemon --stop ${stop_retry} --quiet --pidfile ${pidfile} >/dev/null 2>&1
58
	eend $?
59
}
60
61
relog() {
62
	checkpidinfo || return 1
63
	start_pre || return 1
64
	ebegin "Sending relog command to ${SVCNAME} via ${cmdsocket}"
65
	echo -n "relog" > ${cmdsocket}
66
	eend $?
67
}
68
69
reload() {
70
	checkpidinfo || return 1
71
	start_pre || return 1
72
	ebegin "Sending reconfigure and relog commands to ${SVCNAME} via ${cmdsocket}"
73
	echo -n "reconfigure" > ${cmdsocket}
74
	echo -n "relog" > ${cmdsocket}
75
	eend $?
76
}

Return to bug 554488