Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaume Miralles Isern committed Mar 5, 2021
0 parents commit 03f811c
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 0 deletions.
Binary file added circusdebianlib_1.1-1.deb
Binary file not shown.
12 changes: 12 additions & 0 deletions circusdebianlib_1.1-1/DEBIAN/control
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

11 changes: 11 additions & 0 deletions circusdebianlib_1.1-1/DEBIAN/control~
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
4 changes: 4 additions & 0 deletions circusdebianlib_1.1-1/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash


echo "Enjoy the Circus Of Things :)"
3 changes: 3 additions & 0 deletions circusdebianlib_1.1-1/DEBIAN/postinst~
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "Enjoy the Circus Of Things :)"
54 changes: 54 additions & 0 deletions circusdebianlib_1.1-1/usr/local/bin/circusreadsignal
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

65 changes: 65 additions & 0 deletions circusdebianlib_1.1-1/usr/local/bin/circuswritesignal
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
54 changes: 54 additions & 0 deletions original source files/circusreadsignal
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

65 changes: 65 additions & 0 deletions original source files/circuswritesignal
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

0 comments on commit 03f811c

Please sign in to comment.