Author: Not specified Language: text
Description: Not specified Timestamp: 2012-10-28 11:20:59 -0400
View raw paste Reply
  1. #!/bin/sh
  2. # Mobile Broadband Startup Service script v0.1 alpha by The Fan Club - April 2012
  3. # acts as startup service script for nmcli to fire up Mobile Broadband Connections
  4. # NOTE: Use the name of the Mobile Connection in the Network Manager as the 'id'
  5. # USAGE: start|stop|status
  6. #
  7. ### BEGIN INIT INFO
  8. # Provides: mobile-broadband-connect
  9. # Required-Start: $remote_fs $syslog
  10. # Required-Stop: $remote_fs $syslog
  11. # Should-Start: $network
  12. # Should-Stop: $network
  13. # Default-Start: 3 4 5
  14. # Default-Stop: 0 1 6
  15. # Short-Description: Autoconnect 3G GSM
  16. ### END INIT INFO
  17.  
  18. NAME="mobile-broadband-connect"
  19. DESC="Autoconnect 3G/4G GSM USB modem at startup"
  20.  
  21. test -x $DAEMON || exit 0
  22.  
  23. case "$1" in
  24.         start)
  25.            echo "Starting Mobile Broadband Connection."
  26.  
  27.            while true; do
  28.               # testing...
  29.               LC_ALL=C nmcli -t -f TYPE,STATE dev | grep -q "^gsm:disconnected$"
  30.               if [ $? -eq 0 ]; then
  31.                  break
  32.               else
  33.                  # no GSM modem detected yet, sleeping for a second
  34.                  sleep 1
  35.               fi
  36.            done
  37.  
  38.            # Once GSM modem detected, run the script
  39.            nmcli -t con up id YourMobileBroadbandConnectionNameHere
  40.         ;;
  41.         stop)
  42.            echo "Stopping Mobile Broadband Connection."
  43.            nmcli -t con down id YourMobileBroadbandConnectionNameHere
  44.            nmcli -t nm wwan off
  45.         ;;
  46.         status)
  47.            # Check to see if the process is running with nmcli
  48.        nmcli -p dev
  49.         ;;
  50.        
  51.         *)
  52.            echo "Mobile Broadband Startup Service"
  53.            echo $"Usage: $0 {start|stop|status}"
  54.            exit 1
  55. esac
  56. exit 0
View raw paste Reply