add overengineered kernel send script
authorkremlin <ian@kremlin.cc>
Sat, 11 Feb 2017 07:50:52 +0000 (01:50 -0600)
committerkremlin <ian@kremlin.cc>
Sat, 11 Feb 2017 07:50:52 +0000 (01:50 -0600)
misc/bbb-sendkern.sh [new file with mode: 0755]

diff --git a/misc/bbb-sendkern.sh b/misc/bbb-sendkern.sh
new file mode 100755 (executable)
index 0000000..03e7a84
--- /dev/null
@@ -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/<target>/ 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