summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-scripts/net.modules.d/adsl')
-rw-r--r--net-scripts/net.modules.d/adsl62
1 files changed, 28 insertions, 34 deletions
diff --git a/net-scripts/net.modules.d/adsl b/net-scripts/net.modules.d/adsl
index 87bf6ab..dbf6be7 100644
--- a/net-scripts/net.modules.d/adsl
+++ b/net-scripts/net.modules.d/adsl
@@ -4,18 +4,10 @@
# Contributed by Roy Marples (uberlord@gentoo.org)
-# char* adsl_provides(void)
-#
-# Returns a string to change module definition for starting up
-adsl_provides() {
- echo "adsl"
-}
-
# void adsl_depend(void)
#
# Sets up the dependancies for the module
adsl_depend() {
- after interface
before dhcp
}
@@ -23,23 +15,24 @@ adsl_depend() {
#
# Returns 1 if rp-pppoe is installed, otherwise 0
adsl_check_installed() {
- [[ -x /usr/sbin/adsl-start ]] && return 0
+ [[ -x /usr/sbin/adsl-start || -x /usr/sbin/pppoe-start ]] && return 0
${1:-false} && eerror "For ADSL support, emerge net-dialup/rp-pppoe"
return 1
}
-# bool adsl_check_depends(void)
-#
-# Checks to see if we have the needed functions
-adsl_check_depends() {
- return 0
-}
-
# bool adsl_setup_vars(char *iface)
#
# Checks to see if the ADSL script has been created or not
adsl_setup_vars() {
- local iface="$1"
+ local iface="$1" startstop="$2" cfgexe
+
+ if [[ -x /usr/sbin/pppoe-start ]]; then
+ exe="/usr/sbin/pppoe-${startstop}"
+ cfgexe=pppoe-setup
+ else
+ exe="/usr/sbin/adsl-${startstop}"
+ cfgexe=adsl-setup
+ fi
# Decide which configuration to use. Hopefully there is an
# interface-specific one
@@ -48,7 +41,7 @@ adsl_setup_vars() {
if [[ ! -f ${cfgfile} ]]; then
eerror "no pppoe.conf file found!"
- eerror "Please run adsl-setup to create one"
+ eerror "Please run ${cfgexe} to create one"
return 1
fi
@@ -61,41 +54,42 @@ adsl_setup_vars() {
#
# Returns 0 (true) when successful, non-zero otherwise
adsl_start() {
- local iface="$1" user ifvar=$( bash_variable "$1" ) cfgfile
+ local iface="$1" exe cfgfile user ifvar=$( bash_variable "$1" )
- adsl_setup_vars "${iface}" || return 1
+ adsl_setup_vars "${iface}" start || return 1
# Might or might not be set in conf.d/net
eval user=\"\$\{adsl_user_${ifvar}\}\"
# Start ADSL with the cfgfile, but override ETH and PIDFILE
einfo "Starting ADSL for ${iface}"
- /usr/sbin/adsl-start <(cat "${cfgfile}"; \
- echo "ETH=${iface}"; \
- echo "PIDFILE=/var/run/adsl-${iface}.pid"; \
- [[ -n ${user} ]] && echo "USER=${user}") \
- >/dev/null
+ ${exe} <(cat "${cfgfile}"; \
+ echo "ETH=${iface}"; \
+ echo "PIDFILE=/var/run/rp-pppoe-${iface}.pid"; \
+ [[ -n ${user} ]] && echo "USER=${user}") \
+ >/dev/null
eend $?
}
# bool adsl_stop(char *iface)
#
-# Stop ADSL on an interface by calling adsl-stop
# Returns 0 when there is no ADSL to stop or we stop ADSL successfully
# Otherwise 1
adsl_stop() {
- local iface="$1" cfgfile
+ local iface="$1" exe cfgfile
- adsl_check_installed || return 0
- [[ ! -f "/var/run/adsl-${iface}.pid" ]] && return 0
+ adsl_check_installed || return 1
+ [[ ! -f "/var/run/rp-pppoe-${iface}.pid" ]] && return 0
- adsl_setup_vars "${iface}" || return 0
+ adsl_setup_vars "${iface}" stop || return 1
einfo "Stopping ADSL for ${iface}"
- /usr/sbin/adsl-stop <(cat "${cfgfile}"; \
- echo "ETH=${iface}"; echo "PIDFILE=/var/run/adsl-${iface}.pid") \
- >/dev/null
+ ${exe} <(cat "${cfgfile}"; \
+ echo "ETH=${iface}"; echo "PIDFILE=/var/run/rp-pppoe-${iface}.pid") \
+ >/dev/null
eend $?
+
+ return 0
}
-# vim:ts=4
+# vim: ts=4