-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jaume Miralles Isern
committed
Mar 5, 2021
0 parents
commit 03f811c
Showing
9 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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,12 @@ | ||
Package: circusdebianlib | ||
Version: 1.1-1 | ||
Section: Libraries | ||
Priority: optional | ||
Name: Circus Of Things Debian Library | ||
Description: Commands for Linux CLI that implement the circusofthings.com API v1 | ||
Author: Jaume Miralles Isern <[email protected]> | ||
Maintainer: Jaume Miralles Isern <[email protected]> | ||
Architecture: all | ||
Homepage: https://circusofthings.com | ||
Website: https://circusofthings.com | ||
|
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,11 @@ | ||
Package: circusofthings | ||
Name: Circus Debian Library | ||
Description: Linux commands/libraries that implement the circusofthings.com API | ||
Author: Jaume Miralles Isern <[email protected]> | ||
Maintainer: Jaume Miralles Isern <[email protected]> | ||
Version: 0.1 | ||
Section: Libraries | ||
Architecture: all | ||
Homepage: https://circusofthings.com | ||
Website: https://circusofthings.com | ||
Priority: optional |
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,4 @@ | ||
#!/bin/bash | ||
|
||
|
||
echo "Enjoy the Circus Of Things :)" |
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,3 @@ | ||
#!/bin/bash | ||
|
||
echo "Enjoy the Circus Of Things :)" |
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,54 @@ | ||
#!/bin/bash | ||
|
||
usage() { | ||
echo "" | ||
echo "Usage: $0 [ options ] [ -k SIGNALKEY ]" 1>&2 | ||
echo "" | ||
echo "Options:" | ||
echo " -v: verbose" | ||
echo "" | ||
exit 1 | ||
} | ||
|
||
k_flag=0 | ||
while getopts :vhk: option | ||
do | ||
case "${option}" | ||
in | ||
k) k_flag=1;key=${OPTARG};; | ||
v) verbose=1;; | ||
h) usage;exit;; | ||
:) echo "Missing option argument for -$OPTARG" >&2; exit 1;; | ||
esac | ||
done | ||
|
||
if [ $k_flag -eq 0 ] | ||
then | ||
echo "" | ||
echo "A signal key must be specified" | ||
usage | ||
exit 2 | ||
fi | ||
|
||
if ((verbose)); then | ||
if [[ -z "$CIRCUSTOKEN" ]]; then | ||
echo "Note: Your environment variable CIRCUSTOKEN is empty. Did you set it? Did you set it for the same user that is executing this command?" | ||
fi | ||
echo "Reading signal (key: $key) from circusofthings.com" | ||
fi | ||
|
||
response=$( curl --silent "https://circusofthings.com/ReadValue?Key=$key&Token=$CIRCUSTOKEN" ) | ||
value=$( echo $response | jq -r '.Value' ) | ||
message=$( echo $response | jq -r '.Message' ) | ||
|
||
if ((verbose)); then | ||
echo "$message" | ||
fi | ||
|
||
if [ "$message" = "Success." ]; then | ||
echo "$value" | ||
exit 0 | ||
else | ||
exit 1 | ||
fi | ||
|
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,65 @@ | ||
#!/bin/bash | ||
|
||
usage() { | ||
echo "" | ||
echo "Usage: $0 [ options ] [ -k SIGNALKEY ] [ -n NUMERICVALUE ]" 1>&2 | ||
echo "" | ||
echo "Options:" | ||
echo " -v: verbose" | ||
echo "" | ||
exit 1 | ||
} | ||
|
||
k_flag=0 | ||
n_flag=0 | ||
while getopts :vhk:n: option | ||
do | ||
case "${option}" | ||
in | ||
k) k_flag=1;key=${OPTARG};; | ||
n) n_flag=1;value=${OPTARG};; | ||
v) verbose=1;; | ||
h) usage;exit;; | ||
:) echo "Missing option argument for -$OPTARG" >&2; exit 1;; | ||
esac | ||
done | ||
|
||
if [ $k_flag -eq 0 ] | ||
then | ||
echo "" | ||
echo "A signal key must be specified" | ||
usage | ||
exit 2 | ||
fi | ||
|
||
if [ $n_flag -eq 0 ] | ||
then | ||
echo "" | ||
echo "A numeric value must be specified" | ||
usage | ||
exit 2 | ||
fi | ||
|
||
if [[ -z "${CIRCUSTOKEN}" ]]; then | ||
echo "Note: Your environment variable CIRCUSTOKEN is empty. Did you set it? Did you set it for the same user that is executing this command?" | ||
exit 2 | ||
fi | ||
|
||
if ((verbose)); then | ||
echo "Writing signal (key: $key) at circusofthings.com" | ||
fi | ||
|
||
#echo "Token: $CIRCUSTOKEN" | ||
#message=$( curl -H "Accept: application/json" -H "Content-Type: application/json" -X GET "https://circusofthings.com/WriteValue?Token=$CIRCUSTOKEN&Value=$value&Key=$key" | jq -r '.Message') | ||
response=$( curl --silent "https://circusofthings.com/WriteValue?Token=$CIRCUSTOKEN&Value=$value&Key=$key" ) | ||
message=$( echo $response | jq -r '.Message' ) | ||
|
||
if ((verbose)); then | ||
echo "$message" | ||
fi | ||
|
||
if [[ "$message" != Success.* ]]; then | ||
exit 1 | ||
else | ||
exit 0 | ||
fi |
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,54 @@ | ||
#!/bin/bash | ||
|
||
usage() { | ||
echo "" | ||
echo "Usage: $0 [ options ] [ -k SIGNALKEY ]" 1>&2 | ||
echo "" | ||
echo "Options:" | ||
echo " -v: verbose" | ||
echo "" | ||
exit 1 | ||
} | ||
|
||
k_flag=0 | ||
while getopts :vhk: option | ||
do | ||
case "${option}" | ||
in | ||
k) k_flag=1;key=${OPTARG};; | ||
v) verbose=1;; | ||
h) usage;exit;; | ||
:) echo "Missing option argument for -$OPTARG" >&2; exit 1;; | ||
esac | ||
done | ||
|
||
if [ $k_flag -eq 0 ] | ||
then | ||
echo "" | ||
echo "A signal key must be specified" | ||
usage | ||
exit 2 | ||
fi | ||
|
||
if ((verbose)); then | ||
if [[ -z "$CIRCUSTOKEN" ]]; then | ||
echo "Note: Your environment variable CIRCUSTOKEN is empty. Did you set it? Did you set it for the same user that is executing this command?" | ||
fi | ||
echo "Reading signal (key: $key) from circusofthings.com" | ||
fi | ||
|
||
response=$( curl --silent "https://circusofthings.com/ReadValue?Key=$key&Token=$CIRCUSTOKEN" ) | ||
value=$( echo $response | jq -r '.Value' ) | ||
message=$( echo $response | jq -r '.Message' ) | ||
|
||
if ((verbose)); then | ||
echo "$message" | ||
fi | ||
|
||
if [ "$message" = "Success." ]; then | ||
echo "$value" | ||
exit 0 | ||
else | ||
exit 1 | ||
fi | ||
|
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,65 @@ | ||
#!/bin/bash | ||
|
||
usage() { | ||
echo "" | ||
echo "Usage: $0 [ options ] [ -k SIGNALKEY ] [ -n NUMERICVALUE ]" 1>&2 | ||
echo "" | ||
echo "Options:" | ||
echo " -v: verbose" | ||
echo "" | ||
exit 1 | ||
} | ||
|
||
k_flag=0 | ||
n_flag=0 | ||
while getopts :vhk:n: option | ||
do | ||
case "${option}" | ||
in | ||
k) k_flag=1;key=${OPTARG};; | ||
n) n_flag=1;value=${OPTARG};; | ||
v) verbose=1;; | ||
h) usage;exit;; | ||
:) echo "Missing option argument for -$OPTARG" >&2; exit 1;; | ||
esac | ||
done | ||
|
||
if [ $k_flag -eq 0 ] | ||
then | ||
echo "" | ||
echo "A signal key must be specified" | ||
usage | ||
exit 2 | ||
fi | ||
|
||
if [ $n_flag -eq 0 ] | ||
then | ||
echo "" | ||
echo "A numeric value must be specified" | ||
usage | ||
exit 2 | ||
fi | ||
|
||
if [[ -z "${CIRCUSTOKEN}" ]]; then | ||
echo "Note: Your environment variable CIRCUSTOKEN is empty. Did you set it? Did you set it for the same user that is executing this command?" | ||
exit 2 | ||
fi | ||
|
||
if ((verbose)); then | ||
echo "Writing signal (key: $key) at circusofthings.com" | ||
fi | ||
|
||
#echo "Token: $CIRCUSTOKEN" | ||
#message=$( curl -H "Accept: application/json" -H "Content-Type: application/json" -X GET "https://circusofthings.com/WriteValue?Token=$CIRCUSTOKEN&Value=$value&Key=$key" | jq -r '.Message') | ||
response=$( curl --silent "https://circusofthings.com/WriteValue?Token=$CIRCUSTOKEN&Value=$value&Key=$key" ) | ||
message=$( echo $response | jq -r '.Message' ) | ||
|
||
if ((verbose)); then | ||
echo "$message" | ||
fi | ||
|
||
if [[ "$message" != Success.* ]]; then | ||
exit 1 | ||
else | ||
exit 0 | ||
fi |