11 Commits
v1.0 ... master

Author SHA1 Message Date
Bradley Richins
79ed3e4048 Update README.md 2020-05-19 18:01:43 +00:00
Bradley Richins
74946d1258 Added help info for scan function
added decription for -s|--scan argument usage
2020-05-18 14:51:52 -06:00
Bradley Richins
746e896b3e rokuc minor change 2020-05-18 12:41:11 -06:00
Bradley Richins
a4ad0bcb8b README.md minor change 2020-05-18 12:40:06 -06:00
Bradley Richins
8cc64d9cc0 README.md update 2020-05-18 11:57:51 -06:00
Bradley Richins
c2281de32a Updated for new function
Added new flags
   -i|--version
   -s|--scan

Added new example for -s|--scan flags
2020-05-18 03:53:56 -06:00
Bradley Richins
de2406057e Various Changes:
Added:
   Roku Search:
      function scan4dev:
         Uses nmap to scan network for Rokus ECP port (8060)
      check for nmap
      lanCIDR var for subnetmask
   function versionInfo:
      Displays version info
   vernum var for vserion number

Modified:
   function helpme:
      added version number
      added respective function flag info
      added URL gitlab repo
   Modified while loop responsible for managing flags:
      added -s|--scan
      added -i|--version
      Modified flag order (stand alone flags are now processed first)
2020-05-18 03:23:36 -06:00
Bradley Richins
e7c12c1012 Updated README.md 2020-05-16 19:45:19 -06:00
Bradley Richins
300a5c0f3e Updated README.md 2020-05-16 19:44:06 -06:00
Bradley Richins
2adec6a70d Updated README.md 2020-05-16 19:42:24 -06:00
Bradley Richins
239e918369 Merge branch 'bradley.richins-master-patch-66037' into 'master'
Update README.md

See merge request bradley.richins/rokuc!1
2020-05-17 01:40:20 +00:00
2 changed files with 102 additions and 31 deletions

View File

@@ -4,14 +4,20 @@
This bash script leverages cURL and roku's External Control Protocol ([ECP](https://developer.roku.com/docs/developer-program/debugging/external-control-api.md)), to aid in home automation.
Send simple remote commands to Roku devices using curl to interact with Rokus ECP (External Control Protocal) server on port 8060.
## Usage :
```
Usage: rokuc [[-a [ADDRESS]] [-s [IP SUBNET]]] [[-h] [-v] [-c [ARGS]] [-l [ARGS]]]
-a | --address IP address of roku device ** REQUIRED **
-c | --command Send remote commands to device
-l | --launch Launch Channel/Application on device
-v | --verbose Enable verbose mode
-h | --help Display this message
-i | --version Display version info and exit
-s | --scan Scan LAN for active Roku devices
Args for [-c|--command] flag
play | pause | | | p Pause and Play
@@ -44,6 +50,10 @@ Args for [-l|--launch] flag
hdmi4 Launch HDMI4
av1 Launch AV1
Argument for [-s|--scan [IP SUBNET]] flag
Input your LAN subnet
i.e. 192.168.11.0, 10.0.0.0, 192.168.0.0, etc...
```
### Usage Examples
@@ -68,7 +78,13 @@ $> ./rokuc -a 192.168.1.142 -c "# v- v-"
Launch plex, wait 5 seconds, move right, select:
```bash
$> /rokuc -a 192.168.11.142 -l plex -c "s5 > ."
$> ./rokuc -a 192.168.11.142 -l plex -c "s5 > ."
```
Scan network for devices
```bash
$> ./rokuc -s 192.168.0.0
```

115
rokuc
View File

@@ -4,18 +4,41 @@ if ! hash curl 2>/dev/null; then
echo "curl is not installed"
exit
fi
if ! hash nmap 2>/dev/null; then
devscan=0
else
devscan=1
fi
# Default subnet mask
lanCIDR=24
script=`basename "$0"`
vernum="1.1"
function versionInfo()
{
echo -e "rokuc (Roku CLI Remote) ${vernum}"
echo -e ''' Copyright (C) 2020 Bradley Richins II
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
'''
exit
}
function helpme()
{
echo -e "rokuc ver. ${vernum}"
echo "Send simple remote commands to Roku devices using curl to interact with Rokus ECP (External Control Protocal) server on port 8060."
echo "Usage: ${script} -a [ADDRESS] [ [-h] [-v] [-c [ARGS]] [-l [ARGS]] ]"
echo "Usage: ${script} [[-a [ADDRESS]] [-s [IP SUBNET]]] [[-h] [-v] [-c [ARGS]] [-l [ARGS]]]"
echo -e ''' -a | --address\tIP address of roku device ** REQUIRED **
-c | --command\tSend remote commands to device
-c | --command\tSend remote commands to device.
-l | --launch \tLaunch Channel/Application on device
-v | --verbose \tEnable verbose mode
-h | --help \tDisplay this message
-h | --help \tDisplay this message and exit
-i | --version\tDisplay version info and exit
-s | --scan \tScan LAN for active Roku devices
Args for [-c|--command] flag
play | pause | | | p \t Pause and Play
@@ -47,13 +70,45 @@ Args for [-l|--launch] flag
hdmi3 \t Launch HDMI3
hdmi4 \t Launch HDMI4
av1 \t Launch AV1
'''
echo -e "Examples:\nLaunch Netflix\n\t./${script} -a 192.168.11.142 -l netflix\n"
echo -e "Pause Roku \n\t./${script} -a 192.168.11.142 -c pause\n"
echo -e "Go Home & turn down volume\n\t./${script} -a 192.168.11.142 -c \"# v- v-\"\n"
echo -e "Launch plex, wait 5 seconds, move right, select \n\t./${script} -a 192.168.11.142 -l plex -c \"s5 > .\""
echo -e "ECP documentation:\n\thttps://developer.roku.com/docs/developer-program/debugging/external-control-api.md"
Argument for [-s|--scan [IP SUBNET]] flag
Input your LAN subnet
i.e. 192.168.11.0, 10.0.0.0, 192.168.0.0, etc...
'''
echo -e "Examples:\nLaunch Netflix\n\t${script} -a 192.168.11.142 -l netflix\n"
echo -e "Pause Roku \n\t${script} -a 192.168.11.142 -c pause\n"
echo -e "Go Home & turn down volume\n\t${script} -a 192.168.11.142 -c \"# v- v-\"\n"
echo -e "Launch plex, wait 5 seconds, move right, select \n\t${script} -a 192.168.11.142 -l plex -c \"s5 > .\""
echo -e "ECP documentation:\n\thttps://developer.roku.com/docs/developer-program/debugging/external-control-api.md"
echo -e "\nCheck for updates at https://gitlab.com/bradley.richins/rokuc"
exit
}
# IP address validation
function valid_ip()
{
local ip=$1
local stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
IFS='.'
ip=($ip)
IFS=$OIFS
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
stat=$?
fi
return $stat
}
function scan4dev()
{
if valid_ip $1; then
nmap -p8060 -Pn $1/$lanCIDR -oG - | grep 8060/open
else
echo -e "Invalid address: $1"
fi
}
VERBOS=0
@@ -62,6 +117,26 @@ while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-s|--scan)
SUBNET="$2"
if [[ $devscan == 1 ]]; then
scan4dev $SUBNET
exit
else
echo "Scaning requires nmap, please install nmap to continue"
exit
fi
shift
shift
;;
-h|--help)
helpme
shift
;;
-i|--version)
versionInfo
shift
;;
-a|--address)
ADDRESS="$2"
shift
@@ -82,10 +157,7 @@ do
shift
shift
;;
-h|--help)
helpme
shift
;;
*)
POSITIONAL+=($1)
shift
@@ -101,23 +173,6 @@ if [[ $VERBOS == 1 ]]; then
echo -e " positional args\t${POSITIONAL[@]}"
fi
# IP address validation
function valid_ip()
{
local ip=$1
local stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
IFS='.'
ip=($ip)
IFS=$OIFS
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 && ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
stat=$?
fi
return $stat
}
# kill script if args are invalid
if [[ -n $1 ]]; then
if (( $VERBOS == 1 )); then