add developer / fw update scripts to ./iop command

This commit is contained in:
Nabeel Sowan 2016-04-27 17:14:57 +02:00
parent 75ec580e89
commit 3db08a8ec8
4 changed files with 185 additions and 0 deletions

View file

@ -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 <host> <file>"
}
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" "<host> <file> Install firmware on remote host in CFE mode"
function cfe_upgrade_latest {
if [ -z "$1" ] ; then
echo "usage: $0 cfe_upgrade_latest <host>"
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" "<host> Install latest firmware on remote host in CFE mode"

View file

@ -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 <host/-r(eset)/-p(retend)>"
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" "<host/-r(eset)/-p(retend)> SCP only changed files to device"

17
iop/scripts/ssh_install_key.sh Executable file
View file

@ -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"

View file

@ -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 <host> <file> [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" "<host> <file> [opts] Install firmware on remote host with SSH"
function ssh_sysupgrade_latest {
if [ -z "$1" ] ; then
echo "usage: $0 ssh_sysupgrade_latest <host> [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" "<host> [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 <host> [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" "<host> [opts] Install latest jffs2 firmware on remote host with SSH"