#!/bin/sh # ################################################################################ # # Copyright (c) 2016-2017, Bryan Vyhmeister # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY # AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. # ################################################################################ # # Title: cell-setup # Version: 0.6.0 # ################################################################################ # # This script is designed to setup an LTE umb(4) connection and then, # when it comes online, add a default route and the carrier provided # DNS server. # ################################################################################ # # Set the APN variable to the proper variable for your provider. # 'broadband' is the correct value for AT&T Wireless in the United States. APN="broadband" ################################################################################ f_cell_activate() { ifconfig umb0 class LTE apn ${APN} up sleep 1 } f_cell_status() { _CELL_STATUS="" _CELL_STATUS=`ifconfig umb0 | grep status | awk '{ print $2 }'` if [ "${_CELL_STATUS}" == "active" ]; then CELL_STATUS=0 else CELL_STATUS=1 fi return ${CELL_STATUS} } f_set_route() { CELL_ROUTE=`ifconfig umb0 | grep inet | awk '{ print $2 }'` route add -ifp umb0 default ${CELL_ROUTE} if [ $? == 0 ]; then echo "Default route added" else echo "Default route failure" fi } f_set_dns() { CELL_DNS=`ifconfig umb0 | grep dns | awk '{ print $2 }'` if [ "${CELL_DNS}" == "" ]; then echo "Failure" else echo "nameserver ${CELL_DNS}" > /etc/resolv.conf echo "lookup file bind" >> /etc/resolv.conf fi } f_cell_activate while true ; do f_cell_status if [ $? == 0 ]; then f_set_route f_set_dns break fi done