LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-17-2008, 07:28 PM   #1
M$ISBS
Member
 
Registered: Aug 2003
Posts: 834

Rep: Reputation: 30
Need simple script to startup internet service?


Slackware, KDE.
Sometimes I turn off my modem when I reboot and I forget to turn it back on during bootup, SO I have to do

cd /etc/rc.d
then
./rc.inet1
to startup the internet service.

Is there a simple script I can create and run on my desktop or from command line I can do to startup the internet instead of having to login as root and change to the directory then issue ./rc.inet1 evertime?

Thanks.
 
Old 01-17-2008, 08:19 PM   #2
bsdunix
Senior Member
 
Registered: May 2006
Distribution: BeOS, BSD, Caldera, CTOS, Debian, LFS, Mac, Mandrake, Red Hat, Slackware, Solaris, SuSE
Posts: 1,761

Rep: Reputation: 80
Quote:
Sometimes I turn off my modem ...
What type of modem? Dialup, Cable, ?
 
Old 01-17-2008, 09:14 PM   #3
M$ISBS
Member
 
Registered: Aug 2003
Posts: 834

Original Poster
Rep: Reputation: 30
DSL modem, and sometimes I turn off the router as well.
 
Old 01-18-2008, 12:14 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If your distro has/uses

/etc/rc.local

that's the place to add it.
Just append the cmds you'd normally use. It's run by root as the last thing at boot up.
 
Old 01-18-2008, 07:58 AM   #5
bsdunix
Senior Member
 
Registered: May 2006
Distribution: BeOS, BSD, Caldera, CTOS, Debian, LFS, Mac, Mandrake, Red Hat, Slackware, Solaris, SuSE
Posts: 1,761

Rep: Reputation: 80
Quote:
DSL modem, and sometimes I turn off the router as well.
Your probably getting a dynamic assigned IP address, dhcpcd is run from /etc/rc.d/rc.inet1 file.

Reading the man dhcpcd, the -t timeout is defaulted to 60 seconds, which means it will try for 60 seconds to get an address. Setting -t timeout to 0 seconds will keep trying forever to get an address. So when you turn your modem and router back on, dhcpcd should pick up an address. Edit /etc/rc.d/rc.inet1, look for
Code:
/sbin/dhcpcd -d -t ${DHCP_TIMEOUT[$i]:-60}
and change -60 to -0, then restart. See if that helps you.

Last edited by bsdunix; 01-18-2008 at 09:56 AM.
 
Old 01-18-2008, 08:22 PM   #6
M$ISBS
Member
 
Registered: Aug 2003
Posts: 834

Original Poster
Rep: Reputation: 30
I would like to be able to either click on an icon on the desktop or type in a command in the console to start up the internet service.
Is there a way to do that?
 
Old 01-18-2008, 08:32 PM   #7
bsdunix
Senior Member
 
Registered: May 2006
Distribution: BeOS, BSD, Caldera, CTOS, Debian, LFS, Mac, Mandrake, Red Hat, Slackware, Solaris, SuSE
Posts: 1,761

Rep: Reputation: 80
Setting dhcpcd timeout to 0 not working? Did you try it?

Networking requires root permission, so clicking an icon or running a script will require root's permission. So if your set to use mouse clicks or running a script, then you might as well stick with what your did before posting the question.

Last edited by bsdunix; 01-18-2008 at 08:34 PM.
 
Old 01-18-2008, 11:20 PM   #8
tonyfreeman
Member
 
Registered: Sep 2003
Location: Fort worth, TX
Distribution: Debian testing 64bit at home, EL5 32/64bit at work.
Posts: 196

Rep: Reputation: 30
In a shell type the following commands:

cd
mkdir bin
cd bin
touch start_dsl.sh



Edit the 'start_dsl.sh' file so that it looks like this:

Code:
#!/bin/bash
/etc/rc.d/rc.inet1

Type the following commands so that the script is executable and runs with root permission:

chmod 775 start_dsl.sh
sudo chown root start_dsl.sh
sudo chmod u+s start_dsl.sh



Now create a desktop icon. Type the following in your shell:

cd
cd Desktop
touch start_dsl.desktop


Edit the 'start_dsl.desktop' file so that it looks like this (you have to replace <username> with your login username):

Code:
[Desktop Entry]
Version=1.0
Name=Start DSL
Name[en_US]=Start DSL
Exec=/home/<username>/bin/start_dsl.sh
Comment=Manually Start DSL
Comment[en_US]=Manually Start DSL
Icon=/usr/share/pixmaps/ekiga.png
Type=Application
Terminal=false
Encoding=UTF-8

Good luck!

-- Tony

Last edited by tonyfreeman; 01-18-2008 at 11:22 PM. Reason: correct spelling
 
  


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
Need help getting started simple simple shell script dhonnoll78 Programming 6 12-17-2007 05:34 PM
Network service startup imurch01 Linux - Networking 6 01-16-2005 10:37 PM
Simple "service" script for dealing with rc files arobinson74 Slackware 0 09-06-2004 11:43 PM
disable simple service on RedHat9... pablovschby Linux - Software 4 10-20-2003 02:58 PM
Simple script to be executed on startup. Korff Linux - General 2 06-03-2003 09:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:07 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