From 4ff39435b9d9a7b1a280894154fbd8c34ba17a25 Mon Sep 17 00:00:00 2001 From: Vahagn Khachatryan Date: Wed, 25 Jan 2023 14:00:18 +0000 Subject: [PATCH] .profile.roku.dev and etc --- .profile.roku | 30 ----------- .profile.roku.dev | 131 +++++++++++++++++++++++++++++++++++++++++++++ .profile.roku.jira | 5 ++ install.sh | 32 +++++++++++ 4 files changed, 168 insertions(+), 30 deletions(-) create mode 100644 .profile.roku.dev create mode 100644 .profile.roku.jira create mode 100755 install.sh diff --git a/.profile.roku b/.profile.roku index af5e784..33d2218 100644 --- a/.profile.roku +++ b/.profile.roku @@ -70,36 +70,6 @@ jcat() cat $(jfile $1) } -############################################################################### -# -# Misc -# - -rokuget() -{ - [ -z "$1" ] && echo "usage: rokuget " && 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 -} - -install_auth_token() -{ - [ ! -f "$1" ] && echo "usage: install_auth_toke " && return 0 - [ -z "$ROKU_DEVICE_IP" ] && echo "ROKU_DEVICE_IP must be defined" && return 0 - curl --data-binary @$1 http://$ROKU_DEVICE_IP:8060/token/install -} - -sideload() -{ - [ ! -f "$1" ] && echo "usage: sideload " && return 0 - [ -z "$ROKU_DEVICE_IP" ] && echo "ROKU_DEVICE_IP must be defined" && return 0 - curl --anyauth --user "rokudev:aaaa" -F "mysubmit=Install_Netflix" -F "archive=@$1" http://$ROKU_DEVICE_IP/plugin_install -} - ############################################################################### # # Other helpers diff --git a/.profile.roku.dev b/.profile.roku.dev new file mode 100644 index 0000000..1d94144 --- /dev/null +++ b/.profile.roku.dev @@ -0,0 +1,131 @@ +#!/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} + +############################################################################### +# +# Work with device. +# +export DEVPASSWORD=aaaa + +install_auth_token() +{ + [ ! -f "$1" ] && echo "usage: install_auth_toke \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 \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 +} + +__netcat() +{ + netcat -t $ROKU_DEV_TARGET 23 +} + +__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" +} + +rokureboot() +{ + [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0 + device_cmd "reboot" +} + +rokutelnet() +{ + [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0 + telnet "$ROKU_DEV_TARGET" $1 +} + +update_san() +{ + [ -z "$ROKU_DEV_TARGET" ] && echo "ROKU_DEV_TARGET must be defined" && return 0 +} + +############################################################################### +# +# 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 " && 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 +} + diff --git a/.profile.roku.jira b/.profile.roku.jira new file mode 100644 index 0000000..7396987 --- /dev/null +++ b/.profile.roku.jira @@ -0,0 +1,5 @@ +export GOROOT=/opt/go +export GOPATH=$HOME/.go +export PATH=$PATH:$GOROOT/bin:$GOPATH/bin +export JIRA_AUTH_TYPE=bearer +export JIRA_API_TOKEN=NDgxMDQ4OTEyMzc4OsbbS3Et1TCVFNPAVrKIONLY99NM diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..9b16cc7 --- /dev/null +++ b/install.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +# +# Make sure that .profile loads all .profile.* files. +# +[ ! -f ${HOME}/.profile ] && touch ${HOME}/.profile +grep "# Load .profile.* files." ${HOME}/.profile +if [ $? != 0 ]; then + cat >> ${HOME}/.profile << EOF + +# Load .profile.* files. +for profile in \${HOME}/.profile.*; do + [ -f \${profile} ] && source \${profile} +done +EOF +fi + +# +# Make sure that .profile file is loaded from bashrc. +# +grep .profile ${HOME}/.bashrc +if [ $? != 0 ]; then + printf "# Load .profile in case its an ssh(non interactive) shell.\n" + printf "[ -f ~/.profile ] && source ~/.profile\n" >> ${HOME}/.bashrc +fi + +# +# Create symlinks to all .profile.* files. +# +find $(pwd) -maxdepth 1 -name .profile.\* -type f -exec ln -i -s \{\} ${HOME} \; + +