You are not logged in.

#1 2007-11-07 10:52:11

p.navid
Member
Registered: 2007-11-03
Posts: 14

Adding some stuff to the startup

Hi
Well, I guess this is a newbie question. I need to run these lines after entering runlevel 5, to be more exact, after all the daemons are run. How am supposed to do it? And if possible, I don't want to be asked for any password.

su
route del default
route add default gw 81.91.128.10
export http_proxy="http://127.0.0.1:8118"

Offline

#2 2007-11-07 11:05:41

pressh
Developer/TU
From: Netherlands
Registered: 2005-08-14
Posts: 1,719

Re: Adding some stuff to the startup

I guess you can put the export line in /etc/profile.

About the route, why can't you just define it in /etc/rc.conf (there is an entry for defining your default route there) ?

Offline

#3 2007-11-07 11:19:41

pelle.k
Member
From: Åre, Sweden (EU)
Registered: 2006-04-30
Posts: 667

Re: Adding some stuff to the startup

/etc/rc.local?


"Your beliefs can be like fences that surround you.
You must first see them or you will not even realize that you are not free, simply because you will not see beyond the fences.
They will represent the boundaries of your experience."

SETH / Jane Roberts

Offline

#4 2007-11-07 12:06:23

p.navid
Member
Registered: 2007-11-03
Posts: 14

Re: Adding some stuff to the startup

Thanks for the replies. About the routing issue, I just did that but sounds like it doesn't work. The problem I got an ADSL connection which uses pppoe for authentication. Now since the ADSL daemon is run after the part which sets the route, it just doesn't work. Here's the part from my rc.conf:

#
# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
HOSTNAME="localhost"
#
# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available
# interfaces.
#
# Interfaces to start at boot-up (in this order)
# Declare each interface then list in INTERFACES
#   - prefix an entry in INTERFACES with a ! to disable it
#   - no hyphens in your interface names - Bash doesn't like it
#
# Note: to use DHCP, set your interface to be "dhcp" (eth0="dhcp")
#
lo="lo 127.0.0.1"
eth0="dhcp"
INTERFACES=(lo eth0)
#
# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#   - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 81.91.128.10"
ROUTES=(81.91.128.10)

Offline

#5 2007-11-07 12:21:15

pressh
Developer/TU
From: Netherlands
Registered: 2005-08-14
Posts: 1,719

Re: Adding some stuff to the startup

the correct syntax of the gateway/ROUTES part above should be

gateway="default gw 81.91.128.10"
ROUTES=(gateway)

If that does not work you can customize the adsl daemon of write a new daemon in /etc/rc.d (it's not hard if you take another daemon in /etc/rc.d as a template)

Offline

#6 2007-11-07 16:56:59

p.navid
Member
Registered: 2007-11-03
Posts: 14

Re: Adding some stuff to the startup

So I have to make a daemon to do it for me. I really have no idea how I should do it. I took a look at the adsl and sounds like it's a bash script. I have just heard about them, so can you give me a hint how to write one?
In case you need the information. My ifconfig output is:

eth0      Link encap:Ethernet  HWaddr 00:05:5D:C8:A5:AA
          inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::205:5dff:fec8:a5aa/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5638 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6099 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2530692 (2.4 Mb)  TX bytes:688072 (671.9 Kb)
          Interrupt:5 Base address:0xd000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:94 errors:0 dropped:0 overruns:0 frame:0
          TX packets:94 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:15861 (15.4 Kb)  TX bytes:15861 (15.4 Kb)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:91.184.74.73  P-t-P:81.91.128.10  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:5547 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5719 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:2402574 (2.2 Mb)  TX bytes:536629 (524.0 Kb)

Any help is appreciated indeed.

Offline

#7 2007-11-07 17:21:23

pressh
Developer/TU
From: Netherlands
Registered: 2005-08-14
Posts: 1,719

Re: Adding some stuff to the startup

no problems smile

I threw something together (I'm a bit in a hurry atm).
save the file as route in your home directory and place it with

chown -R root:root ./route
install -D -m755 ./route /etc/rc.d/route

in the correct place with correct permissions (note you have to be root to do this)

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
  start)
    stat_busy "Setting default route"
    /sbin/route add default gw 81.91.128.10
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon route
      stat_done
    fi
    ;;
  stop)
    stat_busy "Removing default route"
    /sbin/route del default
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon adsl
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac
exit 0

now make sure the particular line in /etc/rc.conf reads

ROUTES=(!gateway)

Hope I've everything correct

[edit]
various fixes

Last edited by pressh (2007-11-07 17:28:40)

Offline

Board footer

Powered by FluxBB