# PPPoE startup script

## no usernames left

Hi, here's a (changed) startup script for PPPoE connections (e.g. T-DSL or other kinds of DSL) I want to share  :Very Happy: 

```
#!/sbin/runscript

# Copyright 1999-2002 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License v2

# 

# Internal variables

FUNCT="$2"

depend() {

   need net.eth*

}

checkconfig() {

   if [ ! -x "$(which pppd)" -o ! -x "$(which chat)" -o ! -x "$(which pppoe)" ]

   then

      eerror "pppd, chat and rp-pppoe need to be installed"

      return 1

   fi

   if [ -e "/var/run/pppoe.conf-adsl.pid" -a "${FUNCT}" = "start" ]

   then

      eerror "pppoe connection is already up"

      return 1

   fi

   if [ ! -e "/var/run/pppoe.conf-adsl.pid" -a "${FUNCT}" = "stop" ]

   then

      eerror "pppoe connection not up"

      

      # Do our own cleanup

      # Note: This doesn't work for reasons I don't know. :)

      if [ -L ${svcdir}/started/net.${IFACE} ]

      then

         rm -f ${svcdir}/started/net.${IFACE}

      fi

      return 1

   fi

                  

}

start() {

   checkconfig || return 1

   ebegin "Bringing pppoe connection up"

   if [ -x "$(which route)" -a -x "$(which adsl-start)" ]

   then

      if [ "${DEFROUTE}" = "yes" ]

      then

         [ -n "$(/sbin/route | egrep 'default')" ] && route del default

      fi

      /usr/sbin/adsl-start > /dev/null

   fi

   eend

}

stop() {

   checkconfig || return 1

   ebegin "Bringing pppoe connection down"

   if [ -x "$(which ifconfig)" -a -x "$(which adsl-stop)" ]

   then

      if [ -z "$(/sbin/ifconfig | egrep "${IFACE}")" ]

      then

         eerror "Interface seems to be down already"

         return 1

      fi

      /usr/sbin/adsl-stop > /dev/null

      # kill $(cat /var/run/ppp-${IFACE}.pid | egrep -v "${IFACE}")

   fi

   eend

}

restart() {

   svc_stop

   svc_start

}

# vim:ts=4
```

Just c&p it in a file named "net.pppX" (where X is the number of your next unused ppp interface), mark it as executable ("chmod +x net.pppX") and put it in /etc/init.d. The connection is still configured using adsl-setup and you can connect at startup by adding the script to the default runlevel ("rc-update add net.pppX default").

----------

## friction

Thanks mate, worked like a charm.

Quick question that just shows how much of a n00b I am...where do the other rc-scripts come from? I mean, net.ppp0 wasn't written by me, was it installed when I emerged ppp??

If so, why doesn't a net.ppp script get installed when you emerge rp-pppe?

----------

## no usernames left

 *friction wrote:*   

> where do the other rc-scripts come from? I mean, net.ppp0 wasn't written by me, was it installed when I emerged ppp??

 

I guess they get installed when you extract the stage-x tarball or by emerging the system ebuild.

 *friction wrote:*   

> If so, why doesn't a net.ppp script get installed when you emerge rp-pppe?

 

That's a good question  :Wink: 

----------

## Chris W

To determine what package installed a file:

```

$ qpkg -f /etc/init.d/net.ppp0

sys-apps/baselayout *

```

----------

## jarealist

I found that after installing rp-pppoe and running adsl-setup all I had to do was add "adsl-start" to /etc/conf.d/local.start and "adsl-stop" to /etc/conf.d/local.stop.  Works everytime.

----------

## friction

 *jarealist wrote:*   

> I found that after installing rp-pppoe and running adsl-setup all I had to do was add "adsl-start" to /etc/conf.d/local.start and "adsl-stop" to /etc/conf.d/local.stop.  Works everytime.

 

The problem is that I want to run the firewall script after the net link is up, and I want to run adsl after I've started bind, so depend and things like that makes life easier.

Its also handy to not have to worry about local.start and local.stop, I mean theoretically everything could be started and stopped through it but the rc-scripts serve a very useful purpose.

----------

## friction

 *Chris W wrote:*   

> To determine what package installed a file:
> 
> ```
> 
> $ qpkg -f /etc/init.d/net.ppp0
> ...

 

I don't have that command, and emerge search qpkg returns nothing. Can you use that command on itself and tell me where it comes from?zero ?  :Smile: 

----------

## Chris W

qpkg comes from:

```

# emerge gentoolkit

```

----------

