From 0fd809cb6fd98cb794f6193664bc73347f916c03 Mon Sep 17 00:00:00 2001 From: glen Date: Wed, 2 Dec 2020 12:34:40 -0500 Subject: [PATCH] Add 4G Mobile support --- config/mobile.sh | 16 ++++++++++++++++ installers/common.sh | 12 +++++++++--- installers/raspbian.sh | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 config/mobile.sh diff --git a/config/mobile.sh b/config/mobile.sh new file mode 100644 index 0000000..8b1a2b2 --- /dev/null +++ b/config/mobile.sh @@ -0,0 +1,16 @@ +!/bin/sh + +# 4G +sudo qmicli -d /dev/cdc-wdm0 --dms-set-operating-mode='online' # power on module +# configure raw-ip protocol +ip link set wwan0 down +echo 'Y' | sudo tee /sys/class/net/wwan0/qmi/raw_ip +sudo ip link set wwan0 up +# connect to carrier +sudo qmicli -p -d /dev/cdc-wdm0 --wds-start-network="apn='sp.koodo.com',ip-type$ +# set default rout and IP +sudo udhcpc -i wwan0 +# receive DHCP lease from network +ip a s wwan0 + +exit 0 diff --git a/installers/common.sh b/installers/common.sh index bdd44d2..f7d2480 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -256,19 +256,21 @@ function default_configuration() { sudo mv $webroot_dir/config/loki-whois /usr/local/bin/loki-whois || install_error "unable to move loki-whois binary" sudo mv $webroot_dir/config/loki-whois.service /etc/systemd/system/loki-whois.service || install_error "unable to move loki-whois.service to system" sudo systemctl enable --now loki-whois #start loki-whois as service - + sudo rm /etc/resolv.conf sudo ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf sudo resolvconf -u || install_error "Unable to update resolv.conf" - # LokiPAP Batch file relocation and permissions in user loki-network directory + # LokiPAP Batch files relocation and permissions in user loki-network directory sudo mv $webroot_dir/config/lokilaunch.sh /var/lib/lokinet/ || install error "Unable to move lokilaunch.sh, install Lokinet first" + sudo mv $webroot_dir/config/mobile.sh /var/lib/lokinet/ || install error "Unable to move mobile.sh, file not found" - #changes persmission on lokilaunch.sh + #changes persmission on lokilaunch.sh and mobile.sh sudo chmod 755 /var/lib/lokinet/lokilaunch.sh + sudo chmod 755 /var/lib/lokinet/mobile.sh # Generate required lines for Rasp AP to place into rc.local file. # #RASPAP is for removal @@ -280,6 +282,10 @@ function default_configuration() { #'fi' "$tablerouteA" "$tablerouteB" + "if ! [cat /sys/class/net/eth0/carrier] ; then" + "# Attempt 4G" + "/var/lib/lokinet/mobile.sh" + "fi" #'sudo \/var\/lib\/lokinet\/.\/lokilaunch.sh start #RASPAP' ) diff --git a/installers/raspbian.sh b/installers/raspbian.sh index cda1d72..3da9c32 100755 --- a/installers/raspbian.sh +++ b/installers/raspbian.sh @@ -14,7 +14,7 @@ function install_dependencies() { curl -s https://deb.imaginary.stream/public.gpg | sudo apt-key add - echo "deb https://deb.imaginary.stream $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/imaginary.stream.list sudo apt-get update - sudo yes | apt-get install whois lighttpd $php_package git resolvconf hostapd dnsmasq vnstat lokinet || install_error "Unable to install dependencies" + sudo yes | apt-get install whois lighttpd $php_package git resolvconf hostapd dnsmasq vnstat libqmi-utils udhcpc lokinet || install_error "Unable to install dependencies" } #Remove NetworkManager and install dhcpd if required Armbian.