From b33f8db3dce57fde351a8991fc66c3c0c0a38c44 Mon Sep 17 00:00:00 2001 From: Sarah Ramazani Date: Wed, 1 Jul 2020 13:20:05 -0700 Subject: [PATCH 1/3] "usb.sh refactored" --- modules/usb.sh | 101 +++++++++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 45 deletions(-) diff --git a/modules/usb.sh b/modules/usb.sh index 5caa2c0372..080bdd92f7 100644 --- a/modules/usb.sh +++ b/modules/usb.sh @@ -14,56 +14,67 @@ function usb { command="$1" if [[ $(detectrpi) =~ 'RPI3' ]]; then - if [ "$command" = "on" ]; then - /usr/local/bin/hub-ctrl -h 1 -P 2 -p 1 + case $command in + "on") + /usr/local/bin/hub-ctrl -h 1 -P 2 -p 1 - echo "usb ports turned on" - elif [ "$command" = "off" ]; then - /usr/local/bin/hub-ctrl -h 1 -P 2 -p + echo "usb ports turned on" + ;; + "off") + /usr/local/bin/hub-ctrl -h 1 -P 2 -p - echo "usb ports turned off" - elif [ "$command" = "" ]; then - lsusb -t - else - echo "Error: unknown command" - usb_help - exit 1 - fi + echo "usb ports turned off" + ;; + "") + lsusb -t + ;; + *) + echo "Error: unknown command" + usb_help + exit 1 + ;; + esac + fi elif [[ $(detectrpi) =~ 'RPI4' ]]; then - if [ "$command" = "on" ]; then - /usr/local/bin/hub-ctrl -h 2 -P 1 -p 1 - /usr/local/bin/hub-ctrl -h 2 -P 2 -p 1 - /usr/local/bin/hub-ctrl -h 2 -P 3 -p 1 - /usr/local/bin/hub-ctrl -h 2 -P 4 -p 1 - /usr/local/bin/hub-ctrl -h 1 -P 1 -p 1 + case $command in + "on") + /usr/local/bin/hub-ctrl -h 2 -P 1 -p 1 + /usr/local/bin/hub-ctrl -h 2 -P 2 -p 1 + /usr/local/bin/hub-ctrl -h 2 -P 3 -p 1 + /usr/local/bin/hub-ctrl -h 2 -P 4 -p 1 + /usr/local/bin/hub-ctrl -h 1 -P 1 -p 1 - echo "usb ports turned on" - elif [ "$command" = "off" ]; then - # check for connected ethernet - if [ "$( Date: Thu, 2 Jul 2020 04:01:25 +0000 Subject: [PATCH 2/3] usb.sh updated --- modules/usb.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/usb.sh b/modules/usb.sh index 080bdd92f7..6174e422ad 100644 --- a/modules/usb.sh +++ b/modules/usb.sh @@ -33,8 +33,7 @@ function usb { usb_help exit 1 ;; - esac - fi + esac elif [[ $(detectrpi) =~ 'RPI4' ]]; then case $command in "on") From 737d43b009348e4b812f06555694d5da60971191 Mon Sep 17 00:00:00 2001 From: dogi Date: Thu, 2 Jul 2020 23:52:45 -0400 Subject: [PATCH 3/3] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c7a5fb6d1e..b1311b3a4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@treehouses/cli", - "version": "1.22.40", + "version": "1.22.48", "remote": "2346", "description": "Thin command-line interface for Raspberry Pi low level configuration.", "main": "cli.sh",