Click to See Complete Forum and Search --> : how to write and execute a script so kubuntu would connect to internet at boot?


yhotg
11-22-2005, 07:56 AM
hi,
i use kubuntu and i want it to login to my internet connection in boot up.
i connect by typing in a console :

# sudo internet --connect=<connection-name>
#password:*******

and i want kubuntu to desconnect my internet connection when loging off the system

the command i use for closing my internet connection is:

#sudo internet --clearcurr
#password:*************

so how i write a script or something so the internet connection gets up in boot up and gets down when closing the computer?

thanks

bwkaz
11-22-2005, 08:20 PM
What's this "internet" script? (I assume it's a script, anyway. It's not a standard Linux utility.) What password is it prompting you for?

palsyboy
11-23-2005, 03:04 AM
I thought Kubuntu already connected to the Internet at boot...? I know it at least synchronizes with the Ubuntu server clock. Or is this something different?

yhotg
11-23-2005, 06:58 AM
bwkaz:
don't know if it is a script or a program - i believe it is a program.
I use it to connect to internet because in israel adsl is a kind of nightmare for linux, or at least for me.
the password that ask for is my user password , i mean it's necessary to be root to use the "internet" program.
so i gave to the users authorization on the sudoers. so each one can connect using sudo and their own password.

i don't have problems using it, my problems is that i would prefer for my wife to not have to use command line commands. and better yet, having kubuntu to connect on boot up....

& so....
palsyboy
yes kubuntu does it, kubuntu is amazing lol, but again, israel adsl connections are something , something..., weird i think lol.
so my kubuntu can't connect on boot or in no other way without that internet command.
unfortunately i don't know nothing of connections and internet and.. well...

but thanks anyway.

Sepero
11-23-2005, 04:07 PM
First thing, type:
whereis internet

then ls -l /path/to/internet

To bypass the "sudo", you may simply need to add yourself to the group "dialup".


After that, we can work on a script.

yhotg
11-23-2005, 04:42 PM
wow nice command that one!!!!
i should remember it, u wont believe that i did find file when i needed to find the path to a file
man already thank u!!!!

now,
path:
internet: /usr/bin/internet /etc/internet.conf /usr/bin/X11/internet

ls -l /usr/bin/internet
-rwxr-xr-x 1 root root 252408 2004-06-12 02:03 /usr/bin/internet

about the password i did add myself and the other user to the dialup and still we need to use sudo, but anyway that doesn't bother so much now, i did add the other user to sudoers with
username ALL=/usr/bin/internet

so there's no prob now, i mean, we need to sudo yet, but at least each user can connect and use internet .

but still i'll like to have the system to connect on boot up if it isn't complicated in extreme.

thanks anyway, that command is great, i should find a list of all commands lol

bwkaz
11-23-2005, 07:57 PM
I'm asking about the password prompt because it's hard to securely give a password to a process that's prompting for it. But if sudo is what's asking for the password, then it's no big deal: if you run this command at boot, you'll already be root (so the sudo part would be removed from the command).

Basically, you can probably just put the "internet --connect=<connection-name>" command into rc.local (or whatever kubuntu calls it).

yellowdog
11-24-2005, 12:49 AM
i have a router that signs in or
signs in when the router gets rebooted. It has done a hell of job for me.
I am using a linux router by the way, the name of my router is smoothwall.
It is an opensource linux distro accomadated to serve as a router.
if you can get your hands on an old computer that will do.
am running smoothwall on an old p166 with 32 megs of ram.
am happy has a dog with the results

yhotg
11-24-2005, 04:06 AM
bwkaz
u got me there, i don't know if it's sudo or the process that it's asking for the password, i just need to be root to use it, then sudo...,

so, to give a try i need to put the process into rc.local?
or i need to write a script with the command?

internet --connect=<connection's_name>

because i don't know how to write scrpts yet...

yellowdog:
i have just une box, it has kubuntu brezy (main system) and windows for the 2 or 3 programs that i still need to use.
the connection is adsl and the modem's "alcatel's speedtouch home"
somebody once told me that is possible to configure the alcatel to be a router and connect and disconnect automatically but i can't find any site in the net with a howto (i did find forother alcatel modems, but not mine and not with my bizarre connection) ....

Sepero
11-24-2005, 05:44 AM
wow nice command that one!!!!:p (it's replies like this keep me coming back here.) :p
I couldn't barely understand what you said, but your welcome.


Now run this:
sudo chown root:dialout /usr/bin/internet

Next question:
Do you want the script to stop when a user logs off, or when the computer is turned off?

yhotg
11-24-2005, 06:26 AM
:p (it's replies like this keep me coming back here.) :p
I couldn't barely understand what you said, but your welcome.


Now run this:
sudo chown root:dialup /usr/bin/internet

Next question:
Do you want the script to stop when a user logs off, or when the computer is turned off?

you are welcome friend, now, what exactly did you barely understand? I can try and make it in plastiline for you :D , or a map maybe? lol.

now getting serious, if i change the group perms that means that anybody in that group can run the process without sudoing? How can it be i didn't think about that one alone???!!!! goDs!!!!

the script to stop when the user logs off or the computer is turned off.... mmhhh, don't really know. looks like better when the computer is turned off, but maybe are there security issues if the system stay a while in the prompt and connected to the net? (anyway i didn't configure yet my firewall :( :rolleyes: so..)
mmhh i think when turning off the computer, yeah,.

edit:
errr......
can it be that there isn't no dialup group? i have dialout group
and i don't know yet how to get info about each group (like what it does. eg: what exactly dialout does? )
and can i create dialup like i created normal users?

Sepero
11-24-2005, 08:18 AM
Sorry!
You are correct, it is "dialout".

Now that I think about it, shouldn't Kubuntu have the program kppp? Why aren't you using that to dial the internet?

Anyway, if you still want to go with the script:
#!/bin/bash
# autointernet.sh - A script to automatically stay connected to the internet.

count=8 # Number of seconds between checking internet connection.
while true
do
# "connected" will equal to "pppX" if connected to the internet.
connected=`ifconfig -a | grep -e "ppp" | cut -d " " -f 1`
# If connected is equal to "", then we are NOT connected to the internet and need to connect.
if [ -z $connected ]
then
internet --connect=<connection-name> # Insert connection name here.
fi
# Sleep for $count (8) seconds, then check that we are still connected. (loops forever)
sleep $count
done

You can save that as ~/autointernet.sh, and add at the bottom of your ~/.xinitrc file this:
/home/user/autointernet.sh &

That script runs infinitely, looping every 8 seconds(you can change that part). If it notices you are offlne, it will immediately try to reconnect you. If you want to ever kill it, just run:
killall -9 autointernet.sh

PS.
Don't forget to set the script as executable:
chmod 755 autointernet.sh

yhotg
11-24-2005, 10:52 AM
i tried many time to configure kppp, problm is that i have ADSL connection and kppp continues asking for a phone number and the modem connection port, and i can't find the modem any where, i mean, i know where it is, lol, over the computer box, connected to the eth0 over the phone plug,
i'll try later at night that script...., it looks very complicated, (lol, can't find yet a place where to learn bash scripting)

and i'll search and ask a little again in the kde and kubuntu forum if anybody knows some info about kppp and adsl in israel.

thanks for now, i'll tell u how it goes with the script....

:D

Sepero
11-24-2005, 01:22 PM
The script is really Very simple. If you take out the comments, it's only _10_ lines. When you have a script that is 100 lines or more, THEN is when things start to get complicated. :)

Here is a bash scripting resource that will take you from newbie to Pro:
http://www.tldp.org/LDP/abs/abs-guide.pdf
http://www.tldp.org/LDP/abs/

bwkaz
11-24-2005, 10:33 PM
u got me there, i don't know if it's sudo or the process that it's asking for the password, From your description earlier, it's sudo:

the password that ask for is my user password , i mean it's necessary to be root to use the "internet" program.
so i gave to the users authorization on the sudoers. so each one can connect using sudo and their own password. I took this to mean that you had configured sudo to allow the appropriate users to run this command, if they gave sudo their password (i.e., not root's password).

That would mean that sudo is what's asking you for the password here.

I think Sepero got you started with the rest, at least. Though I'll probably keep reading this thread, just in case. :)