Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
PPPoE startup script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
no usernames left
n00b
n00b


Joined: 09 Feb 2003
Posts: 72

PostPosted: Sun Feb 16, 2003 11:06 am    Post subject: PPPoE startup script Reply with quote

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

Code:
#!/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").
_________________
[img:39112bbc59]http://www.gamers-portal.de/images/yay.gif[/img:39112bbc59]
Back to top
View user's profile Send private message
friction
Tux's lil' helper
Tux's lil' helper


Joined: 16 Sep 2002
Posts: 109

PostPosted: Thu Mar 06, 2003 7:36 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
no usernames left
n00b
n00b


Joined: 09 Feb 2003
Posts: 72

PostPosted: Sat Mar 08, 2003 8:50 pm    Post subject: Reply with quote

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 ;)
_________________
[img:39112bbc59]http://www.gamers-portal.de/images/yay.gif[/img:39112bbc59]
Back to top
View user's profile Send private message
Chris W
l33t
l33t


Joined: 25 Jun 2002
Posts: 972
Location: Brisbane, Australia

PostPosted: Sun Mar 09, 2003 1:03 am    Post subject: Reply with quote

To determine what package installed a file:
Code:

$ qpkg -f /etc/init.d/net.ppp0
sys-apps/baselayout *

_________________
Cheers,
Chris W
"Common sense: The collection of prejudices acquired by age 18." -- Einstein
Back to top
View user's profile Send private message
jarealist
Apprentice
Apprentice


Joined: 07 Oct 2002
Posts: 228

PostPosted: Sun Mar 09, 2003 6:08 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
friction
Tux's lil' helper
Tux's lil' helper


Joined: 16 Sep 2002
Posts: 109

PostPosted: Fri Mar 14, 2003 10:11 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
friction
Tux's lil' helper
Tux's lil' helper


Joined: 16 Sep 2002
Posts: 109

PostPosted: Fri Mar 14, 2003 10:12 am    Post subject: Reply with quote

Chris W wrote:
To determine what package installed a file:
Code:

$ qpkg -f /etc/init.d/net.ppp0
sys-apps/baselayout *


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 ? :)
Back to top
View user's profile Send private message
Chris W
l33t
l33t


Joined: 25 Jun 2002
Posts: 972
Location: Brisbane, Australia

PostPosted: Fri Mar 14, 2003 10:22 pm    Post subject: Reply with quote

qpkg comes from:
Code:

# emerge gentoolkit

_________________
Cheers,
Chris W
"Common sense: The collection of prejudices acquired by age 18." -- Einstein
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum