diff --git a/iop/scripts/cfe_upgrade.sh b/iop/scripts/cfe_upgrade.sh new file mode 100644 index 000000000..7a87af857 --- /dev/null +++ b/iop/scripts/cfe_upgrade.sh @@ -0,0 +1,42 @@ +# this is a developer helper script to install firmware on a remote host running in CFE mode + +function usage { + echo "usage: $0 cfe_upgrade " +} + +function cfe_upgrade { + if [ -z "$1" ] ; then + usage + echo "Error: host required" + exit 1 + fi + if [ -z "$2" ] ; then + usage + echo "Error: firmware filename required" + exit 1 + fi + if [ ! -e $2 ] ; then + usage + echo "Error: firmware file does not exist" + exit 1 + fi + IMAGE=`basename $2` + echo "CFE upgrade host: $1 with file $IMAGE" + [ "$2" ] && [ -e "$2" ] && curl -i -F filedata=@$2 http://$1/upload.cgi && echo "upgrade done!" +} + +register_command "cfe_upgrade" " Install firmware on remote host in CFE mode" + +function cfe_upgrade_latest { + if [ -z "$1" ] ; then + echo "usage: $0 cfe_upgrade_latest " + echo "Error: host required" + exit 1 + fi + { cd `dirname $0` + IMAGE=`ls -Art bin/*/*.y | tail -n1` + [ "$IMAGE" ] && [ -e "$IMAGE" ] && ./iop cfe_upgrade $1 $IMAGE + } +} + +register_command "cfe_upgrade_latest" " Install latest firmware on remote host in CFE mode" diff --git a/iop/scripts/scp_changes.sh b/iop/scripts/scp_changes.sh new file mode 100644 index 000000000..ad7664615 --- /dev/null +++ b/iop/scripts/scp_changes.sh @@ -0,0 +1,70 @@ +# this is a developer helper script to SCP changed files to remote host + +ROOT=build_dir/target-mips_uClibc-0.9.33.2/root-iopsys-brcm63xx-mips/ +ROOT_OLD=tmp/root_old/ +ROOT_TMP=tmp/root_tmp/ + +function scp_changes_reset { + { cd `dirname $0` + rm -rf "$ROOT_OLD" + mkdir -p "$ROOT_OLD" + cp -a "$ROOT"* "$ROOT_OLD" + } +} + +function scp_changes { + if [ -z "$1" ] ; then + echo "usage: $0 scp_changes " + echo "Error: host required" + exit 1 + fi + { cd `dirname $0` + if [ ! -d $ROOT ]; then + echo "$ROOT does not exist" + echo "please build the project first" + exit 1; + fi + if [ "$1" = "-r" ]; then + echo "reset changes" + scp_changes_reset + exit 0 + fi + if [ ! -d $ROOT_OLD ]; then + echo "$ROOT_OLD does not exist" + echo "you didn't store state of previous buildroot" + #echo "please run ./scp_changes_reset.sh" + echo "doing it now" + scp_changes_reset + exit 1; + fi + FILES=`diff -rq "$ROOT" "$ROOT_OLD" 2>&1 | sed -ne "s?^Files .* and $ROOT_OLD\\(.*\\) differ?\\1?p" -ne "s?^Only in $ROOT\\(.*\\): \\(.*\\)?\\1/\\2?p"` + if [ "$1" = "-p" ]; then + echo "files that would be copied:" + echo $FILES + exit 0 + fi + for f in $FILES + do + mkdir -p "$ROOT_TMP`dirname $f`" + cp -af "$ROOT$f" "$ROOT_TMP$f" + done + if [ -d "$ROOT_TMP" ]; then + echo "scp changed files to $1" + pushd "$ROOT_TMP" 2>&1 >/dev/null + scp -r * root@$1:/ + RETVAL=$? + popd 2>&1 >/dev/null + rm -rf "$ROOT_TMP" + if [ "$RETVAL" -eq 0 ]; then + scp_changes_reset + else + echo "scp error" + exit $RETVAL + fi + else + echo "no change" + fi + } +} + +register_command "scp_changes" " SCP only changed files to device" diff --git a/iop/scripts/ssh_install_key.sh b/iop/scripts/ssh_install_key.sh new file mode 100755 index 000000000..9e40a5d1d --- /dev/null +++ b/iop/scripts/ssh_install_key.sh @@ -0,0 +1,17 @@ +# this is a developer helper script to install the public ssh key on host running dropbear + +function ssh_install_key { + if [ -e ~/.ssh/id_rsa.pub ]; then + echo "Adding public RSA key to $1" + KEY=`cat ~/.ssh/id_rsa.pub` + elif [ -e ~/.ssh/id_dsa.pub ]; then + echo "Adding public DSA key to $1" + KEY=`cat ~/.ssh/id_dsa.pub` + else + echo "No public key found" + exit 1 + fi + ssh root@$1 "echo '$KEY' >> /etc/dropbear/authorized_keys" && echo ok +} + +register_command "ssh_install_key" "Install the users public ssh key on host running dropbear" diff --git a/iop/scripts/ssh_sysupgrade.sh b/iop/scripts/ssh_sysupgrade.sh new file mode 100644 index 000000000..2bad6f003 --- /dev/null +++ b/iop/scripts/ssh_sysupgrade.sh @@ -0,0 +1,56 @@ +# this is a developer helper script to install firmware on a remote host with SSH + +function usage { + echo "usage: $0 ssh_sysupgrade [opts]" +} + +function ssh_sysupgrade { + if [ -z "$1" ] ; then + usage + echo "Error: host required" + exit 1 + fi + if [ -z "$2" ] ; then + usage + echo "Error: firmware filename required" + exit 1 + fi + if [ ! -e $2 ] ; then + usage + echo "Error: firmware file does not exist" + exit 1 + fi + IMAGE=`basename $2` + echo "sysupgrade host: $1 with file $IMAGE" + [ "$2" ] && [ -e "$2" ] && scp $2 root@$1:/tmp/ && ssh root@$1 "sysupgrade $3 /tmp/$IMAGE" && echo "sysupgrade done!" +} + +register_command "ssh_sysupgrade" " [opts] Install firmware on remote host with SSH" + +function ssh_sysupgrade_latest { + if [ -z "$1" ] ; then + echo "usage: $0 ssh_sysupgrade_latest [opts]" + echo "Error: host required" + exit 1 + fi + { cd `dirname $0` + IMAGE=`ls -Art bin/*/*.y | tail -n1` + [ "$IMAGE" ] && [ -e "$IMAGE" ] && ./iop ssh_sysupgrade $1 $IMAGE $2 + } +} + +register_command "ssh_sysupgrade_latest" " [opts] Install latest ubifs firmware on remote host with SSH" + +function ssh_sysupgrade_latest_w { + if [ -z "$1" ] ; then + echo "usage: $0 ssh_sysupgrade_latest_w [opts]" + echo "Error: host required" + exit 1 + fi + { cd `dirname $0` + IMAGE=`ls -Art bin/*/*.w | tail -n1` + [ "$IMAGE" ] && [ -e "$IMAGE" ] && ./iop ssh_sysupgrade $1 $IMAGE $2 + } +} + +register_command "ssh_sysupgrade_latest_w" " [opts] Install latest jffs2 firmware on remote host with SSH"