Moving roku helper commands to _roku.sh

This commit is contained in:
2023-01-30 19:33:23 +00:00
parent 4ff39435b9
commit 123616f767
4 changed files with 389 additions and 56 deletions

View File

@@ -7,64 +7,189 @@ export ROKU_NFS_ROOT=$HOME/roku/nfs
export ROKU_NFS_IP=192.168.0.64
export EXPORTROOT=${ROKU_NFS_ROOT}
export DEVPASSWORD=aaaa
_roku_device()
{
if [ "$1" != "" ]; then
export ROKU_DEV_TARGET="$1"
fi
echo $ROKU_DEV_TARGET
}
roku()
{
if [ "$1" = "device" ]; then
shift
_roku_device "$@"
else
_roku.sh "$@"
fi
}
###############################################################################
#
# Work with device.
# Build Completion
#
export DEVPASSWORD=aaaa
install_auth_token()
__roku_completion_contains()
{
[ ! -f "$1" ] && echo "usage: install_auth_toke <auth token file> \n ROKU_DEV_TARGET=${ROKU_DEV_TARGET}" && return 0
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
curl --data-binary @$1 http://${ROKU_DEV_TARGET}:8060/token/install
# Platforms
for WORD in "$@"; do
if [[ "${COMP_WORDS[*]}" =~ "$WORD" ]]; then
return 1
fi
done
return 0
}
sideload()
__roku_completion_add_if()
{
[ ! -f "$1" ] && echo "usage: sideload <file> \n ${ROKU_DEV_TARGET}=${ROKU_DEV_TARGET}" && return 0
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
curl --anyauth --user "rokudev:${DEVPASSWORD}" -F "mysubmit=Install_Netflix" -F "archive=@$1" http://${ROKU_DEV_TARGET}/plugin_install
__roku_completion_contains "$@"
if [[ $? == 0 ]]; then
CANDIDATES+=" $@"
fi
}
__netcat()
# complete -F __build_completion roku
# __build_completion()
# {
# local CANDIDATES="help clobber tests addon-checksums"
# # Docker
# __build_completion_add_if docker make
# # Build hosts
# __build_completion_add_if icecc local
# # Port dir
# __build_completion_add_if port-only
# # Platforms
# __build_completion_add_if native marlin bailey loggan lockhart porting-kit streambar stb
# COMPREPLY=($(compgen -W "$CANDIDATES" "${COMP_WORDS[${COMP_CWORD}]}"))
# }
complete -F __roku_completion roku
__roku_completion()
{
netcat -t $ROKU_DEV_TARGET 23
local CANDIDATES="device get log flash telnet reboot audcap san_update sideload token_install"
# # Docker
# __build_completion_add_if docker make
# # Build hosts
# __build_completion_add_if icecc local
# # Port dir
# __build_completion_add_if port-only
# # Platforms
# __build_completion_add_if native marlin bailey loggan lockhart porting-kit streambar stb
COMPREPLY=($(compgen -W "$CANDIDATES" "${COMP_WORDS[${COMP_CWORD}]}"))
}
__set_server_ip()
{
SERVER_IP=$(ip route get "${ROKU_DEV_TARGET}" | sed -n "s/.* src \([\.0-9]*\) .*/\1/p")
}
device_cmd()
{
echo "$1; exit" | __netcat
}
################################################################################
##
## Set active roku device
##
rokuflash()
{
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
__set_server_ip
device_cmd ". /nvram/san; export SERVER_IP=$SERVER_IP; rokuflash $1"
}
#rokutelnet()
#{
# [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
# telnet "$ROKU_DEV_TARGET" $1
#}
rokureboot()
{
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
device_cmd "reboot"
}
################################################################################
##
## Run commands on active device
##
#__netcat()
#{
# if [ "$1" != "" ]; then
# netcat -t $ROKU_DEV_TARGET $1
# else
# netcat -t $ROKU_DEV_TARGET 23
# fi
#}
rokutelnet()
{
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
telnet "$ROKU_DEV_TARGET" $1
}
#__set_server_ip()
#{
# SERVER_IP=$(ip route get "${ROKU_DEV_TARGET}" | sed -n "s/.* src \([\.0-9]*\) .*/\1/p")
#}
update_san()
{
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
}
#device_cmd()
#{
# echo "$1; exit" | __netcat
#}
#rokuflash()
#{
# [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
# __set_server_ip
# device_cmd ". /nvram/san; export SERVER_IP=$SERVER_IP; rokuflash $1"
#}
#rokulog()
#{
# [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
# device_cmd "setconsole /dev/pts/0"
#}
#rokureboot()
#{
# [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
# device_cmd "reboot"
#}
#update_san()
#{
# [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
#}
################################################################################
##
## Retrieve audio.
##
#app_cmd()
#{
#echo "$1
#exit" | __netcat 8080
#}
#rokuaudcap()
#{
# [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
# __set_server_ip
# app_cmd "audcap record start 00"
# echo -n "Press Enter to stop capture."
# read
# app_cmd "audcap record stop"
# device_cmd "tftp -p -r $1.pcm -l /tmp/audcap_audio.pcm $SERVER_IP"
# sox -t raw -r 48000 -b 16 -c 2 -e signed-integer $1.pcm $1.wav
#}
################################################################################
##
## Work with channels.
##
#install_auth_token()
#{
# [ ! -f "$1" ] && echo "usage: install_auth_toke <auth token file> \n ROKU_DEV_TARGET=${ROKU_DEV_TARGET}" && return 0
# [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
# curl --data-binary @$1 http://${ROKU_DEV_TARGET}:8060/token/install
#}
#sideload()
#{
# [ ! -f "$1" ] && echo "usage: sideload <file> \n ${ROKU_DEV_TARGET}=${ROKU_DEV_TARGET}" && return 0
# [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
# curl --anyauth --user "rokudev:${DEVPASSWORD}" -F "mysubmit=Install_Netflix" -F "archive=@$1" http://${ROKU_DEV_TARGET}/plugin_install
#}
###############################################################################
#
@@ -113,19 +238,19 @@ dtail()
fi
}
###############################################################################
#
# Misc
#
################################################################################
##
## Misc
##
rokuget()
{
[ -z "$1" ] && echo "usage: rokuget <url>" && return 0
if [ -z "$ROKU_CORP_PASSWORD" ]; then
local USER_PASSWORD="--ask-password"
else
local USER_PASSWORD="--password=$ROKU_CORP_PASSWORD"
fi
wget --no-check-certificate --user=vkhachatryan $USER_PASSWORD $1
}
#rokuget()
#{
# [ -z "$1" ] && echo "usage: rokuget <url>" && return 0
# if [ -z "$ROKU_CORP_PASSWORD" ]; then
# local USER_PASSWORD="--ask-password"
# else
# local USER_PASSWORD="--password=$ROKU_CORP_PASSWORD"
# fi
# wget --no-check-certificate --user=vkhachatryan $USER_PASSWORD $1
#}