From: kremlin Date: Sat, 11 Feb 2017 07:50:52 +0000 (-0600) Subject: add overengineered kernel send script X-Git-Url: https://uglyman.kremlin.cc/gitweb/gitweb.cgi?a=commitdiff_plain;h=35c1ac30c5525dec01bf965c9d4bb403f20e0990;p=bbb-usb.git add overengineered kernel send script --- diff --git a/misc/bbb-sendkern.sh b/misc/bbb-sendkern.sh new file mode 100755 index 0000000..03e7a84 --- /dev/null +++ b/misc/bbb-sendkern.sh @@ -0,0 +1,52 @@ +#!/bin/ksh + +BBB_IP="0" +PATHSAVE=`pwd` +OURF=`basename $0` +TMPF=$OURF.tmp +RUSER=root + +check_kern() { + if ssh $RUSER@$BBB_IP stat /bsd.safe \> /dev/null 2\>\&1 ; then + return + else + echo "/bsd.safe not found -- copying /bsd to /bsd.safe" + ssh $RUSER@$BBB_IP 'cp /bsd /bsd.safe' + fi +} + +cd `dirname $0` + +if [[ $BBB_IP == "0" || $1 == "-f" ]]; then + echo -n "Enter BBB's IP address or host: " + read BBB_NEWIP + cat $OURF | sed -E -e "s/^BBB_IP=.*$/BBB_IP=$BBB_NEWIP/" > $TMPF + mv $TMPF $OURF && chmod +x $OURF +fi + +cd $PATHSAVE + +if [[ ! -f ./obj.amd64.armv7/bsd && ! -f ./bsd ]]; then + echo "Run me in your compile// directory" + exit 1 +fi + +check_kern + +if [[ -f ./obj.amd64.armv7/bsd ]]; then + scp ./obj.amd64.armv7/bsd $RUSER@$BBB_IP:/bsd +else + scp ./bsd $RUSER@$BBB_IP:/bsd +fi + +echo -n "Reboot it? (y/n): " +read BOOT +case $BOOT in + yes|Yes|y|Y) + echo "Rebooting..." + ssh $RUSER@$BBB_IP '{ sleep 1; reboot -f; } >/dev/null &' + ;; + no|No|n|N|"") + exit 0 + ;; +esac