From ca001ed831e9ccf8076f7fea871439a9c6b23816 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 9 Dec 2019 17:11:54 -0700 Subject: [PATCH] Restrict hw-drive-info and hw-info to Linux --- scripts/hw-drive-info | 10 ++++++++++ scripts/hw-info | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/scripts/hw-drive-info b/scripts/hw-drive-info index a1c051d8..76a0aa27 100755 --- a/scripts/hw-drive-info +++ b/scripts/hw-drive-info @@ -5,6 +5,16 @@ BLUE='\033[34m' CLEAR='\033[0m' IFS=$'\n' +# Check if running under Linux +os_name="$(uname -s)" +if [[ "$os_name" == "Darwin" ]]; then + os_name="macOS" +fi +if [[ "$os_name" != "Linux" ]]; then + echo "This script is not supported under $os_name." 1>&2 + exit 1 +fi + # List devices for line in $(lsblk -do NAME,TRAN,SIZE,VENDOR,MODEL,SERIAL); do if [[ "${line:0:4}" == "NAME" ]]; then diff --git a/scripts/hw-info b/scripts/hw-info index 8a909c67..2cd5f848 100755 --- a/scripts/hw-info +++ b/scripts/hw-info @@ -25,6 +25,16 @@ function print_dmi_value() { print_in_columns "$name: $value" } +# Check if running under Linux +os_name="$(uname -s)" +if [[ "$os_name" == "Darwin" ]]; then + os_name="macOS" +fi +if [[ "$os_name" != "Linux" ]]; then + echo "This script is not supported under $os_name." 1>&2 + exit 1 +fi + # System echo -e "${BLUE}System Information${CLEAR}" print_dmi_value "Vendor" "sys_vendor"