LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 09-09-2004, 12:37 PM   #1
psytae
LQ Newbie
 
Registered: Sep 2004
Location: Kansas City
Posts: 3

Rep: Reputation: 0
trying to write a startup script


Ok here is the deal I am fairly new to Linux but have found Debian to be a great OS to use.

Im in college and right now Im using Debian in a Lab environment as a server, with about 7 other groups using different server OSes including Win 2003 server and Win 2000 server, and we are setting up a mini internet in the lab.

We got routing to work on the Debian Server using static routes in the lab using the route add command, but everyday we come into the lab to get the routing table back up we have to do the following commands to get the routing table up and running agian between the networks.

Code:
route add -net 192.168.1.0 netmask 255.255.255.0 gw 10.9.64.101
route add -net 192.168.3.0 netmask 255.255.255.0 gw 10.9.64.103
route add -net 192.168.4.0 netmask 255.255.255.0 gw 10.9.64.104
route add -net 192.168.5.0 netmask 255.255.255.0 gw 10.9.64.105
route add -net 192.168.6.0 netmask 255.255.255.0 gw 10.9.64.160
route add -net 192.168.7.0 netmask 255.255.255.0 gw 10.9.64.107
route add -net 192.168.8.0 netmask 255.255.255.0 gw 10.9.64.108
and we get the following Routing Table

Code:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.7.0     10.9.64.107     255.255.255.0   UG    0      0        0 eth0
192.168.6.0     10.9.64.160     255.255.255.0   UG    0      0        0 eth0
192.168.5.0     10.9.64.105     255.255.255.0   UG    0      0        0 eth0
192.168.4.0     10.9.64.104     255.255.255.0   UG    0      0        0 eth0
192.168.3.0     10.9.64.103     255.255.255.0   UG    0      0        0 eth0
192.168.2.0     *               255.255.255.0   U     0      0        0 eth1
192.168.1.0     10.9.64.101     255.255.255.0   UG    0      0        0 eth0
192.168.8.0     10.9.64.108     255.255.255.0   UG    0      0        0 eth0
10.9.64.0       *               255.255.252.0   U     0      0        0 eth0
default         10.9.64.1       0.0.0.0         UG    0      0        0 eth0
Im wanting to write and implement a start up script that will input the route commands into the kernel on boot up instead of us having to do it everytime we reboot the server. Can anyone help me out with this?
 
Old 09-09-2004, 01:00 PM   #2
m_yates
Senior Member
 
Registered: Aug 2003
Location: Upstate
Distribution: Debian, Mint, Mythbuntu
Posts: 1,249

Rep: Reputation: 101Reputation: 101
There is a guide to creating a startup script here: http://www.desktop-linux.net/debian-rclocal.htm
 
Old 09-09-2004, 01:06 PM   #3
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Should be as easy as adding a file like this in the /etc/init.d directory called say routes.
Code:
#!/bin/sh
echo "Adding routes ..."
route add -net 192.168.1.0 netmask 255.255.255.0 gw 10.9.64.101
route add -net 192.168.3.0 netmask 255.255.255.0 gw 10.9.64.103
route add -net 192.168.4.0 netmask 255.255.255.0 gw 10.9.64.104
route add -net 192.168.5.0 netmask 255.255.255.0 gw 10.9.64.105
route add -net 192.168.6.0 netmask 255.255.255.0 gw 10.9.64.160
route add -net 192.168.7.0 netmask 255.255.255.0 gw 10.9.64.107
route add -net 192.168.8.0 netmask 255.255.255.0 gw 10.9.64.108
echo "Done adding routes ..."
Then chmod +x /etc/init.d/routes and now edit the file /etc/init.d/bootmisc.sh and near the bottom add this.

Code:
if [ -f /etc/init.d/routes ]; then
    ./etc/init.d/routes
fi
All steps as root of course.

Last edited by HappyTux; 09-09-2004 at 01:07 PM.
 
Old 09-09-2004, 07:01 PM   #4
psytae
LQ Newbie
 
Registered: Sep 2004
Location: Kansas City
Posts: 3

Original Poster
Rep: Reputation: 0
Im curious what the difference is between what HappyTux's suggested with:

Quote:
edit the file /etc/init.d/bootmisc.sh and near the bottom add this.
Code:
 if [ -f /etc/init.d/routes ]; then
    ./etc/init.d/routes
fi
and what the link m_yates' led me to said to do with
Quote:
Next, link the new local file by running:

update-rc.d local defaults 80
to add the script to the runlevel startups?
 
Old 09-09-2004, 07:31 PM   #5
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally posted by psytae
Im curious what the difference is between what HappyTux's suggested with:



and what the link m_yates' led me to said to do with

to add the script to the runlevel startups?
Not much really they both should achieve the same result. The only thing being you are not really making a true startup script for that to be true you would have to have sections in the file for a start, stop, restart that you could use with say a /etc/init.d/routes start command that a normal startup script has. That is the reason I suggested the bootmisc.sh file because it is a place for miscellaneous items you want started on boot so seems like the perfect place to put it and since it is one of the last scripts run the networking is going to be up already.
 
Old 09-09-2004, 09:17 PM   #6
zuralin
Member
 
Registered: Sep 2003
Distribution: Debian testing/unstable
Posts: 229

Rep: Reputation: 32
Shouldn't this all be done by editing /etc/network/interfaces?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'cannot stat' script in /etc/rc.d/, try to run script at startup quintan Linux - Software 1 11-21-2005 02:53 AM
How to call a script from a system startup script? jonatito Linux - Newbie 7 11-11-2005 09:40 PM
How to write startup script to run NTFS neosirex Linux - Newbie 4 05-31-2005 07:25 PM
where to write a startup script bnj Linux - Newbie 6 05-27-2005 08:10 AM
Auto mounting drives with write access at startup hongman Linux - Newbie 7 02-27-2005 11:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 06:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration