-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reboot device and pause camera utility scripts
- Loading branch information
Showing
13 changed files
with
175 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
if [[ $# -eq 1 ]] ; then | ||
NAME=$1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
hash jq 2>/dev/null || { | ||
echo >&2 "This script uses jq. Download at https://stedolan.github.io/jq/" | ||
exit 1 | ||
} | ||
|
||
choose_camera() { | ||
echo "Getting nodes..." | ||
INSTANCE_ID=$1 | ||
DEVICES=$(aws panorama list-application-instance-node-instances --application-instance-id $INSTANCE_ID) | ||
NODE_NAMES=($((echo ${DEVICES} | jq -r '[.NodeInstances[].PackageName] | @sh') | tr -d \'\")) | ||
NODE_STATUSES=($((echo ${DEVICES} | jq -r '[.NodeInstances[].CurrentStatus] | @sh') | tr -d \'\")) | ||
if [ -x ${NODE_NAMES} ]; then | ||
echo "No nodes found for application instance $INSTANCE_ID." | ||
exit | ||
fi | ||
for (( c=0; c<${#NODE_NAMES[@]}; c++ )) | ||
do | ||
printf "%s: %-24s %s\n" "${c}" "${NODE_NAMES[${c}]}" "${NODE_STATUSES[${c}]}" | ||
done | ||
echo "Choose a node" | ||
read D_INDEX | ||
echo "Signalling node ${NODE_NAMES[${D_INDEX}]}" | ||
COMMAND=PAUSE | ||
if [[ ${NODE_STATUSES[${D_INDEX}]} =~ "PAUSED" ]]; then | ||
COMMAND=RESUME | ||
fi | ||
CAMERA=${NODE_NAMES[${D_INDEX}]} | ||
} | ||
|
||
print_usage() { | ||
echo "Usage: ./pause-camera.sh (with application-id.txt in folder)" | ||
echo "Usage: ./pause-camera.sh <application-instance> <stream-name> <PAUSE|RESUME>" | ||
exit 1 | ||
} | ||
|
||
if [[ $# -eq 3 ]] ; then | ||
APPLICATION_ID=$1 | ||
CAMERA=$2 | ||
COMMAND=$3 | ||
elif [[ $# -eq 0 ]] ; then | ||
if [ -f "application-id.txt" ]; then | ||
APPLICATION_ID=$(cat application-id.txt) | ||
choose_camera $APPLICATION_ID | ||
else | ||
print_usage | ||
fi | ||
else | ||
print_usage | ||
fi | ||
SIGNAL='[{"NodeInstanceId": "MY_CAMERA", "Signal": "MY_COMMAND"}]' | ||
SIGNAL=${SIGNAL/MY_CAMERA/$CAMERA} | ||
SIGNAL=${SIGNAL/MY_COMMAND/$COMMAND} | ||
set -x | ||
aws panorama signal-application-instance-node-instances --application-instance-id ${APPLICATION_ID} --node-signals "${SIGNAL}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
if [[ $# -eq 1 ]] ; then | ||
DEVICE_NAME=$1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
if [[ $# -eq 1 ]] ; then | ||
if [[ $1 == "deploy" ]] ; then | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
hash jq 2>/dev/null || { | ||
echo >&2 "This script uses jq. Download at https://stedolan.github.io/jq/" | ||
exit 1 | ||
} | ||
|
||
choose_device() { | ||
echo "Getting devices..." | ||
DEVICES=$(aws panorama list-devices) | ||
DEVICE_NAMES=($((echo ${DEVICES} | jq -r '.Devices |=sort_by(.LastUpdatedTime) | [.Devices[].Name] | @sh') | tr -d \'\")) | ||
DEVICE_IDS=($((echo ${DEVICES} | jq -r '.Devices |=sort_by(.LastUpdatedTime) | [.Devices[].DeviceId] | @sh') | tr -d \'\")) | ||
if [ -x ${DEVICE_IDS} ]; then | ||
echo "No devices found. Provision a device with the management console or" | ||
echo "use the provision-device.sh script under util-scripts/ in this repository." | ||
exit | ||
fi | ||
for (( c=0; c<${#DEVICE_NAMES[@]}; c++ )) | ||
do | ||
echo "${c}: ${DEVICE_IDS[${c}]} ${DEVICE_NAMES[${c}]}" | ||
done | ||
echo "Choose a device" | ||
read D_INDEX | ||
DEVICE_ID=${DEVICE_IDS[${D_INDEX}]} | ||
} | ||
|
||
if [[ $# -eq 1 ]] ; then | ||
DEVICE_ID=${1} | ||
else | ||
choose_device | ||
fi | ||
while true; do | ||
read -p "Reboot device $DEVICE_ID? (y/n)" response | ||
case $response in | ||
[Yy]* ) aws panorama create-job-for-devices --device-ids ${DEVICE_ID} --job-type REBOOT; break;; | ||
[Nn]* ) exit;; | ||
* ) echo "Response must start with y or n.";; | ||
esac | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
if [[ $# -eq 3 ]] ; then | ||
NAME=$1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
if [[ $# -eq 2 ]] ; then | ||
OLD=$1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
CODE_PACKAGE=SAMPLE_CODE | ||
MODEL_PACKAGE=SQUEEZENET_PYTORCH | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters