Files
san/.profile.roku.dev

257 lines
5.4 KiB
Bash

#!/bin/sh
# I have my automake
export ACLOCAL_PATH=/usr/share/aclocal
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
}
###############################################################################
#
# Build Completion
#
__roku_completion_contains()
{
# Platforms
for WORD in "$@"; do
if [[ "${COMP_WORDS[*]}" =~ "$WORD" ]]; then
return 1
fi
done
return 0
}
__roku_completion_add_if()
{
__roku_completion_contains "$@"
if [[ $? == 0 ]]; then
CANDIDATES+=" $@"
fi
}
# 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()
{
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 active roku device
##
#rokutelnet()
#{
# [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0
# telnet "$ROKU_DEV_TARGET" $1
#}
################################################################################
##
## Run commands on active device
##
#__netcat()
#{
# if [ "$1" != "" ]; then
# netcat -t $ROKU_DEV_TARGET $1
# else
# netcat -t $ROKU_DEV_TARGET 23
# fi
#}
#__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
#}
#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
#}
###############################################################################
#
# 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
##
#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
#}