summaryrefslogtreecommitdiff
blob: 0280ea6ec699a80d31f6139df18d21634121b1c1 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# Copyright (c) 2004-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

# Contributed by Roy Marples (uberlord@gentoo.org)

# void ipppd_depend(void)
#
# Sets up the dependancies for the module
ipppd_depend() {
	after macnet
	before interface
	provide isdn
	functions interface_exists interface_type
	variables ipppd
}

# bool ipppd_check_installed(void)
#
# Returns 1 if isnd4k-utils is installed, otherwise 0
ipppd_check_installed() {
	[[ -x /usr/sbin/ipppd ]] && return 0
	${1:-false} && eerror "For ISDN (ipppd) support, emerge net-dialup/isdn4k-utils"
	return 1
}

# bool ipppd_start(char *iface)
#
# Start isdn on an interface
#
# Returns 0 (true) when successful, non-zero otherwise
ipppd_pre_start() {
	local iface="$1" opts itype="$(interface_type "$1")"
	local pidfile="/var/run/ipppd-${iface}.pid"

	# Check that we are a valid isdn interface
	[[ ${itype} != "ippp" && ${itype} != "isdn" ]] && return 0

	# Check that the interface exists
	interface_exists "${iface}" true || return 1

	local ifvar="$(bash_variable "${iface}")"
	# Might or might not be set in conf.d/net
	opts="ipppd_${ifvar}"

	einfo "Starting ipppd for ${iface}"
	start-stop-daemon --start --exec /usr/sbin/ipppd \
		--pidfile "${pidfile}" \
		-- ${!opts} pidfile "${pidfile}" \
		file "/etc/ppp/options.${iface}" >/dev/null
	eend $? || return $?

	return 0
}

# bool ipppd_stop(char *iface)
#
# Stop isdn on an interface
# Returns 0 (true) when successful, non-zero otherwise
ipppd_stop() {
	local iface="$1" pidfile="/var/run/ipppd-$1.pid"

	[[ ! -f ${pidfile} ]] && return 0

	einfo "Stopping ipppd for ${iface}"
	start-stop-daemon --stop --exec /usr/sbin/ippd \
		--pidfile "${pidfile}"
	eend $?
}

# vim:ts=4
# vim: set ft=sh ts=4 :