Update the prep command with a new Beaglebone Black image

This commit is contained in:
Bob Mottram 2015-07-18 22:55:50 +01:00
parent 7a55cf62f4
commit 3217d9def6
1 changed files with 32 additions and 64 deletions

View File

@ -51,14 +51,12 @@ NAMESERVER2='85.214.20.141'
MICROSD_MOUNT_POINT="/media/$USER"
DEBIAN_FILE_NAME="debian-jessie-console-armhf-2014-08-13"
DEBIAN_FILE_NAME="bone-debian-8.1-console-armhf-2015-07-12-2gb"
# Downloads for the Debian installer
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"
DOWNLOAD_LINK1="https://rcn-ee.com/rootfs/bb.org/testing/2015-07-12/console/$DEBIAN_FILE_NAME.img.xz"
ROOTFS='rootfs'
BOOT='BOOT'
ROOTFS='bbb'
function show_help {
echo ''
@ -82,7 +80,6 @@ if [ -d /media ]; then
fi
if [ -d /media/usb0 ]; then
MICROSD_MOUNT_POINT=/media
BOOT=usb0
fi
fi
if [ ! -d $MICROSD_MOUNT_POINT ]; then
@ -92,7 +89,6 @@ if [ ! -d $MICROSD_MOUNT_POINT ]; then
fi
echo "MICROSD_MOUNT_POINT=$MICROSD_MOUNT_POINT"
echo "BOOT=$BOOT"
while [[ $# > 1 ]]
do
@ -156,47 +152,39 @@ if [ ! -b ${MICROSD_DRIVE}1 ]; then
exit 2
fi
if [ ! -d ~/freedombone ]; then
mkdir ~/freedombone
fi
cd ~/freedombone
if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then
wget $DOWNLOAD_LINK1
fi
if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.tar.xz ]; then
# 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
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
fi
cd $DEBIAN_FILE_NAME
SUDO=
if [ -f /usr/bin/sudo ]; then
SUDO='sudo'
fi
$SUDO apt-get install u-boot-tools dosfstools git-core kpartx wget parted
$SUDO ./setup_sdcard.sh --mmc $MICROSD_DRIVE --dtb beaglebone
$SUDO apt-get install p7zip dd wget
echo ''
echo ''
$SUDO umount $MICROSD_MOUNT_POINT/$ROOTFS
$SUDO umount $MICROSD_MOUNT_POINT/$BOOT
if [ ! -d ~/freedombone ]; then
mkdir ~/freedombone
fi
cd ~/freedombone
if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.img.xz ]; then
if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.img ]; then
wget $DOWNLOAD_LINK1
fi
fi
echo 'Extracting image...'
xz -d $DEBIAN_FILE_NAME.img.xz
if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.img ]; then
echo "Couldn't extract image"
exit 4
fi
cd ~/freedombone
echo 'Flashing image. This may take a while.'
$SUDO dd if=$DEBIAN_FILE_NAME.img of=$MICROSD_DRIVE
sync
sleep 5
$SUDO mkdir -p $MICROSD_MOUNT_POINT/$BOOT
$SUDO mkdir -p $MICROSD_MOUNT_POINT/$ROOTFS
$SUDO mount ${MICROSD_DRIVE}1 $MICROSD_MOUNT_POINT/$BOOT
$SUDO mount ${MICROSD_DRIVE}2 $MICROSD_MOUNT_POINT/$ROOTFS
if [ ! -d $MICROSD_MOUNT_POINT/$ROOTFS ]; then
$SUDO mkdir -p $MICROSD_MOUNT_POINT/$ROOTFS
fi
$SUDO mount ${MICROSD_DRIVE}1 $MICROSD_MOUNT_POINT/$ROOTFS
sync
if [ ! -b ${MICROSD_DRIVE}1 ]; then
@ -209,13 +197,6 @@ if [ ! -b ${MICROSD_DRIVE}1 ]; then
fi
fi
if [ ! -d $MICROSD_MOUNT_POINT/$BOOT ]; then
echo ''
echo "The boot partition $MICROSD_MOUNT_POINT/$BOOT was not found."
ls $MICROSD_MOUNT_POINT
exit 67857
fi
if [ ! -d $MICROSD_MOUNT_POINT/$ROOTFS ]; then
echo ''
echo "The rootfs partition $MICROSD_MOUNT_POINT/$ROOTFS was not found."
@ -230,8 +211,6 @@ if [ ! -d $MICROSD_MOUNT_POINT/$ROOTFS/home ]; then
exit 65688
fi
$SUDO cp $MICROSD_MOUNT_POINT/$BOOT/bbb-uEnv.txt $MICROSD_MOUNT_POINT/$BOOT/uEnv.txt
$SUDO sed -i 's/iface eth0 inet dhcp/iface eth0 inet static/g' $MICROSD_MOUNT_POINT/$ROOTFS/etc/network/interfaces
$SUDO sed -i "/iface eth0 inet static/a\ dns-nameservers $NAMESERVER1 $NAMESERVER2" $MICROSD_MOUNT_POINT/$ROOTFS/etc/network/interfaces
$SUDO sed -i "/iface eth0 inet static/a\ gateway $ROUTER_IP_ADDRESS" $MICROSD_MOUNT_POINT/$ROOTFS/etc/network/interfaces
@ -250,15 +229,8 @@ if [ ! -f $MICROSD_MOUNT_POINT/$ROOTFS/usr/local/bin/freedombone ]; then
fi
# change the motd to show further install instructions
echo 'Become the root user by typing:' > /tmp/freedombone_motd
echo '' >> /tmp/freedombone_motd
echo ' su' >> /tmp/freedombone_motd
echo '' >> /tmp/freedombone_motd
echo 'Using the password "root". Change the root user password by typing:' >> /tmp/freedombone_motd
echo '' >> /tmp/freedombone_motd
echo ' passwd' >> /tmp/freedombone_motd
echo '' >> /tmp/freedombone_motd
echo 'Then create a user for the system with:' >> /tmp/freedombone_motd
echo 'Create a user for the system with:' >> /tmp/freedombone_motd
echo '' >> /tmp/freedombone_motd
echo ' adduser [username]' >> /tmp/freedombone_motd
echo '' >> /tmp/freedombone_motd
@ -283,18 +255,14 @@ echo ''
echo 'The microSD card can now be removed and inserted into the Beaglebone Black.'
echo 'Once the Beaglebone has booted then you can log in with:'
echo ''
echo " ssh debian@$BBB_FIXED_IP_ADDRESS"
echo " ssh root@$BBB_FIXED_IP_ADDRESS"
echo ''
echo 'The password is "temppwd".'
echo 'The root password should be changed with the command "passwd".'
cat /tmp/freedombone_motd
rm /tmp/freedombone_motd
$SUDO umount $MICROSD_MOUNT_POINT/$ROOTFS
$SUDO umount $MICROSD_MOUNT_POINT/$BOOT
sync
if [ -d $MICROSD_MOUNT_POINT/$ROOTFS ]; then
$SUDO rm -rf $MICROSD_MOUNT_POINT/$ROOTFS
fi
if [ -d $MICROSD_MOUNT_POINT/$BOOT ]; then
$SUDO rm -rf $MICROSD_MOUNT_POINT/$BOOT
fi
exit 0