From d9f95bba5ab71cfb84d9bdc4d0a2499d9d6da015 Mon Sep 17 00:00:00 2001 From: UTkarsh Date: Mon, 20 Feb 2017 12:03:56 +0530 Subject: [PATCH] Improve device selection and dependency check --- bitsnet | 7 +------ install | 12 +++++++++++- util.sh | 4 ++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/bitsnet b/bitsnet index de4d6ea..96b3f65 100755 --- a/bitsnet +++ b/bitsnet @@ -1,6 +1,5 @@ #!/bin/bash - # Load util functions source ~/.local/lib/bitsnet/util.sh @@ -77,14 +76,10 @@ if [[ "$dev" == "0" ]]; then fi -# Select correct login page according to IP -# and load corresponding login_url -# Nothing to do here for now - - # Login debug_msg "" debug_msg "Logging in" +# If dev is wifi and IP is not library IP if [[ "$dev" == "2" && "$(hostname -I)" != "10.20"* ]]; then # Log into the router debug_msg "Connected to wifi. Sending request to cisco router form" diff --git a/install b/install index fc8af6e..c648d69 100755 --- a/install +++ b/install @@ -1,10 +1,20 @@ #!/bin/sh -# Check if curl and wget installed +# Check if wget installed if ! which wget > /dev/null ; then echo "wget not installed" exit fi +# Check if git installed for update +if ! which git > /dev/null ; then + echo "git not installed" + exit +fi +# Check if nmcli installed +if ! which nmcli > /dev/null ; then + echo "nmcli not installed" + exit +fi # Copy config file to the right place if ! which bitsnet > /dev/null ; then diff --git a/util.sh b/util.sh index 6906c54..46a96ae 100644 --- a/util.sh +++ b/util.sh @@ -69,6 +69,10 @@ function log_out { function get_device { devInfo="$(nmcli dev | grep " connected" | cut -d " " -f1)" + if [[ $devInfo == "virbr"* ]]; then + # If the connection is through a virtual bridge, select the next device + devInfo=$(echo "$devInfo" | sed 1,1d) + fi; if [[ $devInfo == "en"* ]]; then # ethernet dev=1