WizardKit/archlive/airootfs/usr/local/bin/hw-diags-network
Alan Mason d8952ed26f 2017-01: Retroactive Updates
* Disabled gputest
  * The package is failing to install.

* Now using Midori GTK3 build
  * GTK2 was pulled from main repos for security reasons

* Removed warnings about missing UFD
  * For use with live sessions

* Wallpaper updated for live sessions
  * Wallpaper is now set at startup
  * Checks for UFD source but defaults to included file
  * Bugfix: Wallpaper is now set for multiple monitor/workspace setups

* Disabled choose-mirror service

* Better permission handling
  * build-wk now checks if running as root
  * build-wk now sets permissions before calling build.sh
    * Should prevent build failues as build.sh expects files to be owned by root
    * build-wk sets ownership back to builduser.builduser during cleanup

* Better menu for HW-Diags
  * The script now returns to the menu after running a selection
    * Unless the mode was set directly by passing a valid argument
    * NOTE: This allows for easier use in CLI mode

* Add delay before removing /media/wktech

* Adjusted TMP_DIR in build-wk

* Fixed path to custom repo

* Trimming the fat
  * hostname / hosts now configured by customize_airootfs.sh
  * removed files from etc that were at default settings
  * removed grml zsh config since oh-my-zsh/lean is used

* Defined a LOG_DIR for build-wk

* Introducing libinput
  * Switched to libinput over synaptics as it has been deprecated.
    * Should restore touchpad functionality going forward.
* Full mount path SHOULD now be displayed for mount-all-volumes.

* Added CLI Screensavers

* diag-network works now
  * network connection tests now passes all ipv4 private ip ranges
    * 10.0.0.0/8, 172.16.0.0/12, & 192.168.0.0/24
    * need to add ipv6 at some point
  * hw-diag menu flow adjusted

* New hostname and more bugfixes
  * hostname switched to wk-arch
  * ufw package is now installed
  * adjusted upload section of hw-diags

* Added alias for start-wifi

* Booting to CLI mode will autologin wktech
  * When booting to the CLI the motd shows some avail commands
  * Adjusted HW-Diags menu for use in CLI mode
2017-12-06 17:56:10 -08:00

73 lines
1.5 KiB
Bash

#!/bin/bash
#
## WK HW diagnostics - Network
function test_connection() {
cmd="a"
if [[ -e "/sys/class/net/$1" ]]; then
cmd="a show $1"
fi
if ip $cmd | grep -Eq '(10.[0-9]+|172.(1[6-9]|2[0-9]|3[0-1]).[0-9]+|192.168).[0-9]+.[0-9]+'; then
return 0
else
return 1
fi
}
CLEAR="\e[0m"
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
BLUE="\e[34m"
# Header
echo "WK HW Diagnostics - Network"
echo ""
# Start Wifi if necessary
echo "Initializing..."
connect-to-network >/dev/null 2>&1
# Check network connection
echo -n "Network connection: "
if test_connection; then
echo -e "${GREEN}OK${CLEAR}"
else
echo -e "${RED}No access${CLEAR}"
exit 1
fi
# Check IP addresses
for d in /sys/class/net/*; do
device="$(basename $d)"
if [ "$device" != "lo" ]; then
if test_connection $device; then
ip="$(ip a show $device | egrep 'inet [0-9]' | sed -r 's#.*inet (.*?/[0-9]+).*#\1#')"
echo "$device: $ip" | awk '{printf " %-16s %s\n", $1, $2}'
fi
fi
done
# Check internet connection
echo -n "Internet connection: "
if ping -c 2 -q 8.8.8.8 >/dev/null 2>&1; then
echo -e "${GREEN}OK${CLEAR}"
else
echo -e "${RED}No access${CLEAR}"
exit 1
fi
# Check DNS
echo -n "DNS Resolution: "
if ping -c 2 -q google.com >/dev/null 2>&1; then
echo -e "${GREEN}OK${CLEAR}"
else
echo -e "${RED}Unable to resolve google.com${CLEAR}"
exit 1
fi
# Check speed
echo "Speedtest:"
speedtest-cli --simple | awk '{printf " %-16s %6.2f %s\n", $1, $2, $3}'