LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Need simple script to startup internet service? (https://www.linuxquestions.org/questions/programming-9/need-simple-script-to-startup-internet-service-614384/)

M$ISBS 01-17-2008 07:28 PM

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.

bsdunix 01-17-2008 08:19 PM

Quote:

Sometimes I turn off my modem ...
What type of modem? Dialup, Cable, ?

M$ISBS 01-17-2008 09:14 PM

DSL modem, and sometimes I turn off the router as well.

chrism01 01-18-2008 12:14 AM

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.

bsdunix 01-18-2008 07:58 AM

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.

M$ISBS 01-18-2008 08:22 PM

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?

bsdunix 01-18-2008 08:32 PM

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.

tonyfreeman 01-18-2008 11:20 PM

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


All times are GMT -5. The time now is 01:57 AM.