Added Crestron helper functions

This commit is contained in:
David Thurstenson 2019-12-11 11:46:30 -06:00
parent f6219cb894
commit f3176367f1
4 changed files with 82 additions and 0 deletions

20
.bashrc.d/cn-fwupd.sh Normal file
View File

@ -0,0 +1,20 @@
cn-fwupd() {
local addr="$1"
local puf="$2"
local ext="${puf##*.}"
case $ext in
zip)
printf 'put %q firmware/update.zip' "$puf" | cnsftp $addr
cnssh $addr pushupdate FULL
;;
puf)
printf 'put %q firmware/update.puf' "$puf" | cnsftp $addr
cnssh $addr puf
;;
*)
echo "Error: Bad file type. Currently, only'.zip' and '.puf' file types are supported."
;;
esac
}

34
.bashrc.d/cn-progload.sh Normal file
View File

@ -0,0 +1,34 @@
cn-progload() {
local addr="$1"
local project="$2"
local ext="${project##*.}"
# Add a zero in front of the 3rd arg
local slot="0${3}"
# expand only to the last 2 digits of $slot
slot="${slot: -2}"
case $ext in
vtz)
if [[ ! -z $slot ]]; then
echo "==NOTICE== Ignoring slot number for touchpanel project..."
fi
printf 'put %q' "$project" | cnsftp $addr:display
cnssh $addr projectload
;;
lpz)
if [[ -z $slot ]]; then
echo "==NOTICE== No target program slot defined. Assuming Slot 01..."
slot=01
fi
printf 'put %q' "$project" | cnsftp $addr:Program$slot
cnssh $addr progload -p:$slot
;;
*)
echo "Error: Bad file type. Currently only supports vtz and lpz projects."
;;
esac
}

13
.bashrc.d/cnsftp.sh Normal file
View File

@ -0,0 +1,13 @@
cnsftp() {
# sshpass -p "" ssh Crestron@192.168.0.51
local uname="Crestron"
local pass=""
local cmd="$@"
sshpass -p "$pass" sftp \
-o StrictHostKeyChecking=no\
-o GlobalKnownHostsFile=/dev/null\
-o UserKnownHostsFile=/dev/null\
-o User="$uname" \
"$cmd"
}

15
.bashrc.d/cnssh.sh Normal file
View File

@ -0,0 +1,15 @@
cnssh() {
# Usage: cnssh <ip address> [command]
# sshpass -p "" ssh Crestron@192.168.0.51
local uname="Crestron"
local pass=""
local addr="$1"
shift
local cmd="$@"
sshpass -p "$pass" ssh \
-o StrictHostKeyChecking=no\
-o GlobalKnownHostsFile=/dev/null\
-o UserKnownHostsFile=/dev/null\
"$uname"@"$addr" "$cmd"
}