[SOLVED]How do I get a USB modem to connect on startup?
[SOLVED]How do I get a USB modem to connect on startup?
Puppy Precise 5.7.1 usually connects on startup to the last successful internet connection I think.
I find that when it is set to GPRS it does not do this and you must use either the connect icon or the tray icon to start the negotiation .
Is there a way to get the negotiation to start on boot up ?
Perhaps a script or something .
I would also like the Openvpn program to run thereafter if possible.
EDIT- Turns out the software install script is on the device when first plugged in. Follow the readme on the device and when properly installed it will show as an optical device for about 10 seconds and then that will disappear and the modem will connect as normal. No modeswitching needed these days.
I find that when it is set to GPRS it does not do this and you must use either the connect icon or the tray icon to start the negotiation .
Is there a way to get the negotiation to start on boot up ?
Perhaps a script or something .
I would also like the Openvpn program to run thereafter if possible.
EDIT- Turns out the software install script is on the device when first plugged in. Follow the readme on the device and when properly installed it will show as an optical device for about 10 seconds and then that will disappear and the modem will connect as normal. No modeswitching needed these days.
Last edited by april on Sun 24 Apr 2016, 17:50, edited 2 times in total.
Hi, April!
I don't have a gprs modem to work with, but I would be tempted to use a udev rule to automatically connect the modem up whenever it was plugged in. The udev rule would execute the script when the modem was inserted.
The problem is that there are many steps to get there.
First we would need to look in dmesg to see how the usb device is identified.
Second we would need to "udevadm" to dump the device stack for it.
Third would be to create the udev rule from the info we got in step 2
Fourth, we would write the connect script.
So, lots of steps, no? But once done, from then on, when you plug it in, it's all automatic.
This kinda demonstrates the end-to-end process to build it. Keep in mind you aren't interested in pppd/pptp, you will use OpenVPN. Near the bottom is all the techie stuff on how we would use udev to automate the proceess:
https://wiki.archlinux.org/index.php/3G ... _with_pppd
How bold do you feel today? So what brand of gprs modem is it? Maybe we can find some breadcrumbs on the googles.
I don't have a gprs modem to work with, but I would be tempted to use a udev rule to automatically connect the modem up whenever it was plugged in. The udev rule would execute the script when the modem was inserted.
The problem is that there are many steps to get there.
First we would need to look in dmesg to see how the usb device is identified.
Second we would need to "udevadm" to dump the device stack for it.
Third would be to create the udev rule from the info we got in step 2
Fourth, we would write the connect script.
So, lots of steps, no? But once done, from then on, when you plug it in, it's all automatic.
This kinda demonstrates the end-to-end process to build it. Keep in mind you aren't interested in pppd/pptp, you will use OpenVPN. Near the bottom is all the techie stuff on how we would use udev to automate the proceess:
https://wiki.archlinux.org/index.php/3G ... _with_pppd
How bold do you feel today? So what brand of gprs modem is it? Maybe we can find some breadcrumbs on the googles.
Its a Huawei E160E
Bus 001 Device 005: ID 12d1:140c Huawei Technologies Co., Ltd.
I take it the udev rule you are pointing to is
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="0421", ATTRS{idProduct}=="0612", DEVPATH=="*/ttyACM0", RUN+="pon"
which I should change to
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="140c", DEVPATH=="*/ttyUSB0", RUN+="pon"
Not sure what the last bit is "pon" ?
Bus 001 Device 005: ID 12d1:140c Huawei Technologies Co., Ltd.
I take it the udev rule you are pointing to is
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="0421", ATTRS{idProduct}=="0612", DEVPATH=="*/ttyACM0", RUN+="pon"
which I should change to
SUBSYSTEM=="net", ACTION=="add", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="140c", DEVPATH=="*/ttyUSB0", RUN+="pon"
Not sure what the last bit is "pon" ?
atm when I click connect it comes up as ppp0 connects to ttyUSB0
little script I'm trying gets it connected with THIS GETS CONNECTION UP but no VPN
But not so good . Just wondering why I cant start pgprs-connect in the start menu . Hmm
Certainly first you must setup the Internet connection using GPRS Connect
Then choose "Wireless GPRS Modem" and fill in the details needed.
Then in the Startup folder there must simply be a way to make the "Connect" icon on the desktop, or ,in the tray , run . How to do that?
The desktop icon has " /usr/local/apps/Connect" as a program to run so I tried that in a script and it does not work . I also tried creating a link to it directly in the Startup folder but again no luck. I think I need some delay to give the modem enough time to configure itself on bootup.
little script I'm trying gets it connected with
Code: Select all
#! /bin/bash
sleep 10
pgprs-connect
# script to start OpenVPN on startup
openvpn --config /vpnbook-ca1-tcp443.ovpn
But not so good . Just wondering why I cant start pgprs-connect in the start menu . Hmm
Certainly first you must setup the Internet connection using GPRS Connect
Then choose "Wireless GPRS Modem" and fill in the details needed.
Then in the Startup folder there must simply be a way to make the "Connect" icon on the desktop, or ,in the tray , run . How to do that?
The desktop icon has " /usr/local/apps/Connect" as a program to run so I tried that in a script and it does not work . I also tried creating a link to it directly in the Startup folder but again no luck. I think I need some delay to give the modem enough time to configure itself on bootup.
Last edited by april on Wed 20 Apr 2016, 09:33, edited 7 times in total.
Hi, April
My HOWTO here: http://www.murga-linux.com/puppy/viewtopic.php?t=105455 may be of interest to you. To make an automatic connection at startup, you can copy the connection script to your Startup folder in /root. Edit: I see you have already been to that link, it wasn't of any use?
My HOWTO here: http://www.murga-linux.com/puppy/viewtopic.php?t=105455 may be of interest to you. To make an automatic connection at startup, you can copy the connection script to your Startup folder in /root. Edit: I see you have already been to that link, it wasn't of any use?
OK got the connect to run OK and probably the vpn with this script in the Startup folder
It runs in the background and I would like it to run in a terminal window so I have to work that bit out yet.
Now the problem becomes VPN has a username "vpnbook" which has to go in and then it asks for a password which is "Suwrav4P" atm see the above line for entry .Those are placed on separate lines in the file "upfile" which is the User/Password file
That password changes and the current one is available from the web site http://www.vpnbook.com/ under the OpenVPN tab on that page .
So now how to get that automatically and how to get it into the upfile above?
It runs in the background and I would like it to run in a terminal window so I have to work that bit out yet.
Code: Select all
#! /bin/bash
# script to start pgprs-connect on startup
sleep 05
pgprs-connect
# script to start OpenVPN on startup
openvpn --config /mnt/home/TempSave/OpenVPN/vpnbook-ca1-tcp443.ovpn --auth-user-pass [/mnt/home/Tempsave/OpenVPN/upfile]
That password changes and the current one is available from the web site http://www.vpnbook.com/ under the OpenVPN tab on that page .
So now how to get that automatically and how to get it into the upfile above?
Last edited by april on Wed 20 Apr 2016, 10:20, edited 3 times in total.
I would like to understand this more . jafadminjafadmin wrote:Hi, April!
I don't have a gprs modem to work with, but I would be tempted to use a udev rule to automatically connect the modem up whenever it was plugged in. The udev rule would execute the script when the modem was inserted.
So, lots of steps, no? But once done, from then on, when you plug it in, it's all automatic.
The glaring inadequacy of my above is that the modem must be plugged in already as it wont connect otherwise and must then be done manually anyway..
Once the udev rule is installed, it gets invoked whenever the device is plugged in. So ...april wrote:I would like to understand this more . jafadminjafadmin wrote:Hi, April!
I don't have a gprs modem to work with, but I would be tempted to use a udev rule to automatically connect the modem up whenever it was plugged in. The udev rule would execute the script when the modem was inserted.
So, lots of steps, no? But once done, from then on, when you plug it in, it's all automatic.
The glaring inadequacy of my above is that the modem must be plugged in already as it wont connect otherwise and must then be done manually anyway..
Code: Select all
RUN+="ConnectScript"
Well I f/mucked around with udev rules like this
and could not get it to work whatever.
By placing the script as a link in "/root/Startup" folder the connect part works every time .
Don't see what I have wrong pretty sure the device ID is OK as thats what I get on an "lsusb" but maybe I need the product ID before its switched . ie the default product ID
Code: Select all
ATTR{idVendor}=="12d1", ATTR{idProduct}=="140c", RUN+="/mnt/home/TempSave/Scripts/openvpn.sh"
By placing the script as a link in "/root/Startup" folder the connect part works every time .
Don't see what I have wrong pretty sure the device ID is OK as thats what I get on an "lsusb" but maybe I need the product ID before its switched . ie the default product ID
I usually create a test script that will just confirm the udev rule is working first.
Something like:
call it "ruletester" or whatever and use that in the RUN+="ruletester"
once you get it to where it adds a time/date stamp every time you plug in the device, you can work with debugging your connect script.
Also: http://cafim.sssup.it/~giulio/other/huawei-E1692.html
Something like:
Code: Select all
date >> /root/mydocuments/ruletest.out
once you get it to where it adds a time/date stamp every time you plug in the device, you can work with debugging your connect script.
Also: http://cafim.sssup.it/~giulio/other/huawei-E1692.html
Thanks . Thats a handy one for any situation . It goes into my script folder .
I am not getting a response however when I plug the modem in and it must be that I have the product ID wrong somehow .
lsusb only gives the product number after modeswitch has done the switch so now I have to find the ID before the switch . It seems to be switching so I assume its being done by a udev rule but perhaps thats not the case in newer hardware.
I'm studying that site you gave me atm.
I am not getting a response however when I plug the modem in and it must be that I have the product ID wrong somehow .
lsusb only gives the product number after modeswitch has done the switch so now I have to find the ID before the switch . It seems to be switching so I assume its being done by a udev rule but perhaps thats not the case in newer hardware.
I'm studying that site you gave me atm.
I have a Vodaphone Huawei USB Modem K4203 too.
So I decided to try that one and again looked up the "lsusb" ID's for it and put that ruletester in as below . It did not register a date as it should if the command is executed so I don't know where to turn next on that one?
Running the ruletester directly works every time.
So I decided to try that one and again looked up the "lsusb" ID's for it and put that ruletester in as below . It did not register a date as it should if the command is executed so I don't know where to turn next on that one?
Running the ruletester directly works every time.
Code: Select all
# Vodafone / Huawei Kxxxx
ATTR{idVendor}=="12d1", ATTR{idProduct}=="1f1c", RUN+="usb_modeswitch '%b/%k'"
ATTR{idVendor}=="12d1", ATTR{idProduct}=="1f1c", RUN+="/mnt/home/TempSave/Scripts/ruletester.sh"
Forgive me I don't understand .nic007 wrote:Hi, April. Just as a matter of interest. How long does it take to setup your connection using pupdial?
I set up under Menu->setup->Internet Connection Wizard . Choose GPRS Connect, and Wireless or wired LAN, and then SNS. it comes up as WWAN0 and I DHCP it and then whenever I hit the connect icon or network icon in tray it does the terminal negotiation thing which only takes 3 or 4 seconds to actually connect. Happens everytime on boot direct from icons now.
I like for that to happen every time on bootup and with the script it does without my involvement . Now I just experiment to have it better when I plug it in . Its not a time problem rather a convenience one