/[vps]/baselayout-vserver/trunk/lib/rcscripts/net.modules.d/adsl
Gentoo

Contents of /baselayout-vserver/trunk/lib/rcscripts/net.modules.d/adsl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations) (download)
Sat Sep 3 16:10:27 2005 UTC (8 years, 10 months ago) by hollow
File size: 2378 byte(s)
import initial baselayout sources (1.12.0_pre8)
1 #!/bin/bash
2 # Copyright (c) 2004-2005 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 # Contributed by Roy Marples (uberlord@gentoo.org)
6
7 # char* adsl_provides(void)
8 #
9 # Returns a string to change module definition for starting up
10 adsl_provides() {
11 echo "adsl"
12 }
13
14 # void adsl_depend(void)
15 #
16 # Sets up the dependancies for the module
17 adsl_depend() {
18 after interface
19 before dhcp
20 }
21
22 # bool adsl_check_installed(void)
23 #
24 # Returns 1 if rp-pppoe is installed, otherwise 0
25 adsl_check_installed() {
26 [[ -x /usr/sbin/adsl-start ]] && return 0
27 ${1:-false} && eerror "For ADSL support, emerge net-dialup/rp-pppoe"
28 return 1
29 }
30
31 # bool adsl_check_depends(void)
32 #
33 # Checks to see if we have the needed functions
34 adsl_check_depends() {
35 return 0
36 }
37
38 # bool adsl_setup_vars(char *iface)
39 #
40 # Checks to see if the ADSL script has been created or not
41 adsl_setup_vars() {
42 local iface="$1"
43
44 # Decide which configuration to use. Hopefully there is an
45 # interface-specific one
46 cfgfile="/etc/ppp/pppoe-${iface}.conf"
47 [[ -f ${cfgfile} ]] || cfgfile="/etc/ppp/pppoe.conf"
48
49 if [[ ! -f ${cfgfile} ]]; then
50 eerror "no pppoe.conf file found!"
51 eerror "Please run adsl-setup to create one"
52 return 1
53 fi
54
55 return 0
56 }
57
58 # bool adsl_start(char *iface)
59 #
60 # Start ADSL on an interface by calling adsl-start
61 #
62 # Returns 0 (true) when successful, non-zero otherwise
63 adsl_start() {
64 local iface="$1" user ifvar=$( bash_variable "$1" ) cfgfile
65
66 adsl_setup_vars "${iface}" || return 1
67
68 # Might or might not be set in conf.d/net
69 eval user=\"\$\{adsl_user_${ifvar}\}\"
70
71 # Start ADSL with the cfgfile, but override ETH and PIDFILE
72 einfo "Starting ADSL for ${iface}"
73 /usr/sbin/adsl-start <(cat "${cfgfile}"; \
74 echo "ETH=${iface}"; \
75 echo "PIDFILE=/var/run/adsl-${iface}.pid"; \
76 [[ -n ${user} ]] && echo "USER=${user}") \
77 >/dev/null
78 eend $?
79 }
80
81 # bool adsl_stop(char *iface)
82 #
83 # Stop ADSL on an interface by calling adsl-stop
84 # Returns 0 when there is no ADSL to stop or we stop ADSL successfully
85 # Otherwise 1
86 adsl_stop() {
87 local iface="$1" cfgfile
88
89 adsl_check_installed || return 0
90 [[ ! -f "/var/run/adsl-${iface}.pid" ]] && return 0
91
92 adsl_setup_vars "${iface}" || return 0
93
94 einfo "Stopping ADSL for ${iface}"
95 /usr/sbin/adsl-stop <(cat "${cfgfile}"; \
96 echo "ETH=${iface}"; echo "PIDFILE=/var/run/adsl-${iface}.pid") \
97 >/dev/null
98 eend $?
99 }
100
101 # vim:ts=4

  ViewVC Help
Powered by ViewVC 1.1.20