summaryrefslogtreecommitdiff
blob: d3f3891cd7a06eb83e700e9c423ae2f3e7d1feb4 (plain)
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
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Id$

extra_started_commands="reload"

depend() {
	need net
}

check_dir() {
# Check for directory existance, try to create it(if it's not exist yet)
# and throw error if it can not be done.
# Parameters:
# $1 - directory to check
# $2 - error message
	if [[ ! -d $1 ]]; then
		mkdir "$1" 2>/dev/null
		if [[ $? != 0 ]]; then
			eerror "$2"
			exit 1
		fi
	fi
}

start() {
	# Create directory for PID file
	local piddir=$(dirname ${PID})
	check_dir "${piddir}" "Can not create directory $piddir for PID file"
	# Create default directory for radius attributes
	check_dir "${RADATTR_DIR}" "Can not create directory ${RADATTR_DIR} for radius attributes"

	ebegin "Starting accel-pppd"
	start-stop-daemon --start --quiet --exec /usr/sbin/accel-pppd -- ${ACCEL_PPPD_OPTS} -p ${PID}
	eend $?
}

stop() {
	ebegin "Stopping accel-pppd"
	start-stop-daemon --stop --quiet --pidfile ${PID}
	eend $?
}

reload() {
	if [ ! -f ${PID} ]; then
		eerror "accel-pppd isn't running"
		return 1
	fi
	ebegin "Reloading configuration"
	start-stop-daemon --signal USR1 --pidfile ${PID}
	eend $?
}