From 740ec2a7dc497dddfc0b3d95d018a97a08763bbc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 16 Jan 2015 22:55:18 +0000 Subject: [PATCH] prep gets command line --- debian.sh | 1 + src/freedombone-prep | 93 +++++++++++++++++++++++++++++++------------- 2 files changed, 66 insertions(+), 28 deletions(-) diff --git a/debian.sh b/debian.sh index 0d9685ee..da48ed2b 100755 --- a/debian.sh +++ b/debian.sh @@ -9,6 +9,7 @@ DIR=${APP}-${VERSION} #update version numbers automatically - so you don't have to sed -i 's/VERSION='${PREV_VERSION}'/VERSION='${VERSION}'/g' Makefile sed -i 's/VERSION="'${PREV_VERSION}'"/VERSION="'${VERSION}'"/g' src/freedombone +sed -i 's/VERSION="'${PREV_VERSION}'"/VERSION="'${VERSION}'"/g' src/freedombone-prep # change the parent directory name to debian format mv ../${APP} ../${DIR} diff --git a/src/freedombone-prep b/src/freedombone-prep index d7d9cdb8..a93aa207 100755 --- a/src/freedombone-prep +++ b/src/freedombone-prep @@ -25,7 +25,7 @@ VERSION="1.00" # typically /dev/sdb or /dev/sdc, depending upon how # many drives there are on your system -MICROSD_DRIVE=$1 +MICROSD_DRIVE= # IP address of the router (gateway) ROUTER_IP_ADDRESS="192.168.1.254" @@ -41,43 +41,80 @@ DEBIAN_FILE_NAME="debian-jessie-console-armhf-2014-08-13" DOWNLOAD_LINK1="https://rcn-ee.net/deb/rootfs/jessie/$DEBIAN_FILE_NAME.tar.xz" DOWNLOAD_LINK2="http://ynezz.ibawizard.net/beagleboard/jessie/$DEBIAN_FILE_NAME.tar.xz" -if [ ! MICROSD_DRIVE ]; then - echo 'You need to specify a drive for the connected microSD.' - echo 'This can most easily be found by removing the microSD, then' - echo 'running:' - echo '' - echo ' ls /dev/sd*' - echo '' - echo 'Then plugging the microSD back in and entering the same command again' - exit 1 +function show_help { + echo '' + echo 'freedombone-prep -d [microSD device] --ip [BBB static IP address] --iprouter [Router IP address]' + echo '' +} + +while [[ $# > 1 ]] +do +key="$1" + +case $key in + -h|--help) + show_help + ;; + # Drive path for the microSD + -d|--drive) + shift + MICROSD_DRIVE="$1" + ;; + # BBB static IP address on the LAN + --ip) + shift + BBB_FIXED_IP_ADDRESS="$1" + ;; + # Router IP address on the LAN + --iprouter) + shift + ROUTER_IP_ADDRESS="$1" + ;; + *) + # unknown option + ;; +esac +shift +done + + +if [ ! $MICROSD_DRIVE ]; then + echo 'You need to specify a drive for the connected microSD.' + echo 'This can most easily be found by removing the microSD, then' + echo 'running:' + echo '' + echo ' ls /dev/sd*' + echo '' + echo 'Then plugging the microSD back in and entering the same command again' + exit 1 fi if [ ! -b ${MICROSD_DRIVE}1 ]; then - echo "The microSD drive could not be found at ${MICROSD_DRIVE}1" - exit 2 + echo "The microSD drive could not be found at ${MICROSD_DRIVE}1" + exit 2 fi if [ ! -d ~/freedombone ]; then - mkdir ~/freedombone + mkdir ~/freedombone fi cd ~/freedombone if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then - wget $DOWNLOAD_LINK1 + wget $DOWNLOAD_LINK1 fi if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then - # try another site + # try another site wget $DOWNLOAD_LINK2 - if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then - echo 'The Debian installer could not be downloaded' - exit 3 - fi + if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then + echo 'The Debian installer could not be downloaded' + exit 3 + fi fi echo 'Extracting files...' tar xJf $DEBIAN_FILE_NAME.tar.xz if [ ! -d ~/freedombone/$DEBIAN_FILE_NAME ]; then - echo "Couldn't extract files" - exit 4 + echo "Couldn't extract files" + exit 4 fi cd $DEBIAN_FILE_NAME sudo ./setup_sdcard.sh --mmc $MICROSD_DRIVE --dtb beaglebone @@ -87,13 +124,13 @@ echo '' read -p "Eject the microSD card, re-insert it and wait a minute for it to mount, then press any key to continue... " -n1 -s if [ ! -b ${MICROSD_DRIVE}1 ]; then - echo '' - echo "The microSD drive could not be found at ${MICROSD_DRIVE}1" - read -p "Wait for the drive to mount then press any key... " -n1 -s - if [ ! -b ${MICROSD_DRIVE}1 ]; then - echo "microSD drive not found at ${MICROSD_DRIVE}1" - exit 5 - fi + echo '' + echo "The microSD drive could not be found at ${MICROSD_DRIVE}1" + read -p "Wait for the drive to mount then press any key... " -n1 -s + if [ ! -b ${MICROSD_DRIVE}1 ]; then + echo "microSD drive not found at ${MICROSD_DRIVE}1" + exit 5 + fi fi sudo cp $MICROSD_MOUNT_POINT/BOOT/bbb-uEnv.txt $MICROSD_MOUNT_POINT/BOOT/uEnv.txt