1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
https://kya.8ta.com/onnet/public/mobileData?sid=3721357273565007113
open with root permission:
sudo nano /etc/rc.local

Now add this line above exit 0

(while :; do nmcli -t nm wwan on; sleep 1; done)&

Save the file and exit.

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

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

. 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





#!/bin/sh
# Mobile Broadband Startup Service script v0.1 alpha by The Fan Club - April 2012
# acts as startup service script for nmcli to fire up Mobile Broadband Connections
# NOTE: Use the name of the Mobile Connection in the Network Manager as the 'id' 
# 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
	start)
	   echo "Starting Mobile Broadband Connection."

	   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
	         sleep 1
 	      fi
	   done

	   # Once GSM modem detected, run the script
	   nmcli -t con up id 8ta
	;;
	stop)
	   echo "Stopping Mobile Broadband Connection."
	   nmcli -t con down id 8ta
	   nmcli -t nm wwan off 
	;;
	status)
	   # Check to see if the process is running with nmcli
       nmcli -p dev
	;;
	
	*)
	   echo "Mobile Broadband Startup Service"
	   echo $"Usage: $0 {start|stop|status}"
	   exit 1
esac
exit 0




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

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

. 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
____________________________________________________________________________________




#!/bin/sh
# Mobile Broadband Autoconnect Service script v2.0 alpha by The Fan Club - May 2012
# acts as startup service script for nmcli to autoconnect Mobile Broadband Connections
# NOTE: use the name of the Mobile Connection in the Network Manager as the 'id' 
# 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
	start)
	   echo "[MBC] *** Starting Mobile Broadband Connection."  
	   while true; do
 	      # Waiting for GSM modem adaptor...
          LC_ALL=C nmcli -t -f TYPE,STATE dev | grep -q "^gsm:disconnected$"
          if [ $? -eq 0 ]; then 	 
	         # now gsm detected, run the script
             echo "[MBC] GSM Modem Detected - attempting auto connect" 
		     nmcli -t con up id 8ta
	         echo "[MBC] GSM Modem connecting ....."
             # we want the script to loop forever and 
             # check if the connection is down
             # but we need to give it a chance to connect or 
             # the modem will attempt to connect in an endless loop so we 
             # give a 30 second break to make sure it is not connected	
	         echo "[MBC] Hopefully connected now... sleeping for 30sec"            
	         sleep 30
	      else
	         # GSM device not detected yet or GMS device already connected - sleep 
	         echo "[MBC] MBC still running - sleeping for 10....." 
	         sleep 10
 	      fi
       done
	;;
	stop)
       echo "[MBC] Stopping Mobile Broadband Connection."  
       nmcli -t con down id 8ta
       ps aux | grep "mobile-connection-connect-2.0.sh start" | grep -v grep | awk '{print $2}' | xargs kill -9
       #nmcli -t nm wwan off 
	;;
	status)
       # Check network status with nmcli 
       nmcli -p dev
	;;
	
	*)
	   echo "[MBC] Mobile Broadband Startup Service"
       echo $"Usage: $0 {start|stop|status}"
       exit 1
esac
exit 0



Simplest solution to this problem:

open with root permission:
 sudo gedit /etc/rc.local

Now add this line above exit 0

(while :; do nmcli -t nm wwan on; sleep 1; done)&

Save the file and exit.

This is the best solution i have tried, it works in all situations.