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

@@ -18,6 +18,21 @@ EOF
}
__build_legacy()
{
eval $MAKE \
-C $BUILD_ROOT \
BUILD_PLATFORM=$BUILD_PLATFORM \
${BUILD_PLID:+BUILD_PLID=$BUILD_PLID} \
${PLATFORM_TYPE:+PLATFORM_TYPE=$PLATFORM_TYPE} \
ENABLE_ICECC=$ENABLE_ICECC \
PAX_DEBUG=$PAX_DEBUG \
${BUILD_MODE:+BUILD_MODE=$BUILD_MODE} \
$OPTIONS \
-j $JOBS \
$TARGET
}
__build_os()
{
eval $MAKE \
@@ -53,6 +68,7 @@ __build_port()
$TARGET
}
# declar -a __build_configs = (
build()
{
local REPO_ROKU_OS_DIR=$REPO_ROOT/os/dist/rootfs/Carbon14_dev_stb.OBJ/export/package/porting_kit/os
@@ -135,6 +151,7 @@ build()
benjamin|\
benjaminw|\
loggan|\
lockhart|\
madison)
local ROOT_DIR="$(basename $REPO_ROOT)"
if [ "$ROOT_DIR" == "stark" ] || \

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
#}

188
_roku.sh Executable file
View File

@@ -0,0 +1,188 @@
#!/bin/sh
###############################################################################
#
# Helper functions
#
__set_server_ip()
{
SERVER_IP=$(ip route get "${ROKU_DEV_TARGET}" | sed -n "s/.* src \([\.0-9]*\) .*/\1/p")
}
__netcat()
{
if [ "$1" != "" ]; then
netcat -t $ROKU_DEV_TARGET $1
else
netcat -t $ROKU_DEV_TARGET 23
fi
}
__app_cmd()
{
echo "$1
exit" | __netcat 8080
}
__device_cmd()
{
echo "$1; exit" | __netcat
}
###############################################################################
#
# Run commands on active device
#
_roku_telnet()
{
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
telnet "$ROKU_DEV_TARGET" $1
}
_roku_flash()
{
[ -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"
}
_roku_log()
{
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
__device_cmd "setconsole /dev/pts/0"
}
_roku_reboot()
{
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
__device_cmd "reboot"
}
_roku_san_update()
{
[ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
__set_server_ip
__device_cmd "wget -O /nvram/san http://${SERVER_IP}/roku/san/san"
}
###############################################################################
#
# Retrieve audio.
#
_roku_audcap()
{
[ -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.
#
_roku_token_install()
{
[ ! -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
}
_roku_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
}
###############################################################################
#
# Logging
#
LOGDIR="${HOME}/roku/logs"
dcapture()
{
nc minicom "$@" -C $LOGDIR/.log.$(date +%Y-%m-%d--%H-%M-%S)
}
dfile()
{
local Nth="-1"
if [ $# -gt 0 ]; then
Nth="$1"
fi
echo $(ls -tr -1 ${LOGDIR}/minicom.log.* | tail ${Nth} | head -1)
}
dless()
{
less $(lfile "$@")
}
dcat()
{
cat $(lfile "$@")
}
dgrep()
{
lcat | grep -a --color "$@"
}
dtail()
{
if [ $# -gt 0 ]; then
tail -f $(lfile) | grep "$@"
else
tail -f $(lfile)
fi
}
###############################################################################
#
# Misc
#
_roku_get()
{
[ -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
}
###############################################################################
#
# Dispatch commands.
#
help()
{
echo "Command is not recognised."
}
FUNC=help
if [ "$(type -t _roku_$1)" == "function" ]; then
FUNC=_roku_$1
shift
elif [ "$(type -t _roku_$1_$2)" == "function" ]; then
FUNC=_roku_$1_$2
shift
shift
fi
$FUNC "$@"

5
san
View File

@@ -88,6 +88,9 @@ ACRAMFS=/tmp/acramfs.bin
set_image_dir()
{
case $ROKU_PLATFORM in
lockhart)
IMAGE_DIR="port/realtek/stark/$ROKU_PLATFORM"
;;
bailey)
IMAGE_DIR="port/realtek/stark/$ROKU_PLATFORM"
;;
@@ -514,7 +517,7 @@ EOF
fi
}
san_help
# san_help
# PROGNAME="${0##*/}"
# usage()