Sie sind auf Seite 1von 4

How to auto connect Ubuntu 12.04 USB GSM Mobile Br...

http://www.thefanclub.co.za/how-to/how-auto-connect-u...

The Fan Club


dynamic design solutions

How to auto connect Ubuntu 12.04 USB GSM Mobile Broadband Connection on Boot as startup service without user login using Network Manager CLi
Submitted by The Fan Club on 15 April 2012

This guide is intended as a relatively easy step by step guide to:


Create a auto start bash script to start the mobile broadband connection at boot time as a startup service without needing to log in as a user. * Update: Added version 2 of the script that will also auto re-connect the mobile broadband connection if the connection is dropped, disconnected or lost for some reason.

Requirements:
Ubuntu 12.04 LTS machine with a USB GSM 3G Modem

1. Setup a new Mobile Broadband Connection and connect.


After you have set up a new Mobile Broadband Connection it will appear in the network connections (click on taskbar network icon). In this case our new connection name is : 8ta Connection 'name' should contain only alpha-numerical characters and no spaces to avoid problems. Make sure the "Enable Mobile Broadband" is activated. (see below) Connect to the internet with your Mobile Broadband connection by clicking on the connection name. In this case 8ta

2. Create a Network Manager CLi startup script for your connection.


Open the Terminal Window and enter :

sudo gedit /etc/init.d/mobile-broadband-connect

Add the following into the startup script file and save: Note: Replace the YourMobileBroadbandConnectionNameHere with the name of your connection. In this case our service provider is: 8ta Note: If you want the script to also auto re-connect the connection if lost rather use version 2. Note: If you do not see a codeblock right below this text or see a small empty box before step 3 please reload this page. 27 28 29 30 31 32 33

while true; do # testing... LC_ALL=C nmcli -t -f TYPE,STATE dev | grep -q "^gsm:disconnected$ if [ $? -eq 0 ]; then break else # no GSM modem detected yet, sleeping for a second

1 of 4

Sunday 21 October 2012 07:11 PM

How to auto connect Ubuntu 12.04 USB GSM Mobile Br...

http://www.thefanclub.co.za/how-to/how-auto-connect-u...

3. Change the startup script file permissions.


By default a new file is not allowed to be executed - so we need to modify the permissions to allow us to run the script at startup.. Open the Terminal Window and enter :

sudo chmod +x /etc/init.d/mobile-broadband-connect

4. Update system startup defaults to include your new script as a service.


To update the startup services, open the Terminal Window and enter :

sudo update-rc.d mobile-broadband-connect defaults

The script is registered as a system startup service so you can start, stop, or check the status of the script with :

sudo service mobile-broadband-connect start

sudo service mobile-broadband-connect stop

sudo service mobile-broadband-connect status

5. Reboot to complete installation and auto connect.


Reboot your system to complete the installation. After reboot it takes up to 60 seconds before the USB device is active. When active - The Mobile Broadband Connection will be activated and auto connected.

6. Troubleshooting.
If it does not connect on startup the most likely problem is that the connection is not available to all users at startup. Click on "Edit Connections..." in the Network Connections Manager dialog window, select Mobile Broadband, select your connection, and click on "Edit". Make sure that the "Available to all users" is selected and click on Save

* Version 2: How to Auto Re-Connect the Mobile Broadband Connection.


The script in step 2 is only to establish a connection once the GSM modem becomes available on the system, usually during boot, but can also be in the form of a USB modem that is plugged into the computer. If the connection is dropped for whatever reason the script does not automatically re-connect the modem. The script was updated in version 2 below to allow for this event. It will keep running in the backgroud and keep trying to establish a GSM

2 of 4

Sunday 21 October 2012 07:11 PM

How to auto connect Ubuntu 12.04 USB GSM Mobile Br...

http://www.thefanclub.co.za/how-to/how-auto-connect-u...
connection if it finds the modem disconnected for some reason. Edit the script file created in step 2, by opening a terminal window and entering:

sudo gedit /etc/init.d/mobile-broadband-connect

Then replace the original code with the code below and save: Note: Replace the YourMobileBroadbandConnectionNameHere with the name of your connection. In this case our service provider is: 8ta 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

#!/bin/sh # Mobile Broadband Autoconnect Service script v2.0 alpha # acts as startup service script for nmcli to autoconnect # NOTE: use the name of the Mobile Connection in the Netw # USAGE: start|stop|status # ### BEGIN INIT INFO # Provides: mobile-broadband-connect # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Should-Start: $network # Should-Stop: $network # Default-Start: 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Autoconnect 3G GSM ### END INIT INFO NAME="mobile-broadband-connect" DESC="Autoconnect 3G/4G GSM USB modem at startup" test -x $DAEMON || exit 0 case "$1" in

Download:
Attachment mobile-broadband-connect-0.1.tar.gz mobile-broadband-connect-2.0.tar.gz Size 854 bytes 1.06 KB

Tags: Ubuntu GSM Mobile Broadband Mobile Broadband Connection nmcli Network Manager 3G USB 3G Modem Auto connect Startup Script BASH Ubuntu 12.04
3
Like

1
Tweet share

to post comments

7259 reads

All Rights Reserved. Copyright The Fan Club 2001-2012.

(http://www.ubuntu.com/)

3 of 4

Sunday 21 October 2012 07:11 PM

How to auto connect Ubuntu 12.04 USB GSM Mobile Br...

http://www.thefanclub.co.za/how-to/how-auto-connect-u...

4 of 4

Sunday 21 October 2012 07:11 PM

Das könnte Ihnen auch gefallen