|  | @@ -1,380 +0,0 @@
 | 
	
		
			
			| 1 |  | -#!/bin/bash
 | 
	
		
			
			| 2 |  | -#
 | 
	
		
			
			| 3 |  | -# .---.                  .              .
 | 
	
		
			
			| 4 |  | -# |                      |              |
 | 
	
		
			
			| 5 |  | -# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
 | 
	
		
			
			| 6 |  | -# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
 | 
	
		
			
			| 7 |  | -# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
 | 
	
		
			
			| 8 |  | -#
 | 
	
		
			
			| 9 |  | -#                    Freedom in the Cloud
 | 
	
		
			
			| 10 |  | -#
 | 
	
		
			
			| 11 |  | -# This script installs the Debian image to the microSD card, and should
 | 
	
		
			
			| 12 |  | -# be run on your laptop/desktop with the microSD card plugged in.
 | 
	
		
			
			| 13 |  | -
 | 
	
		
			
			| 14 |  | -# License
 | 
	
		
			
			| 15 |  | -# =======
 | 
	
		
			
			| 16 |  | -#
 | 
	
		
			
			| 17 |  | -# Copyright (C) 2014-2015 Bob Mottram <bob@robotics.uk.to>
 | 
	
		
			
			| 18 |  | -#
 | 
	
		
			
			| 19 |  | -# This program is free software: you can redistribute it and/or modify
 | 
	
		
			
			| 20 |  | -# it under the terms of the GNU General Public License as published by
 | 
	
		
			
			| 21 |  | -# the Free Software Foundation, either version 3 of the License, or
 | 
	
		
			
			| 22 |  | -# (at your option) any later version.
 | 
	
		
			
			| 23 |  | -#
 | 
	
		
			
			| 24 |  | -# This program is distributed in the hope that it will be useful,
 | 
	
		
			
			| 25 |  | -# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
	
		
			
			| 26 |  | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
	
		
			
			| 27 |  | -# GNU General Public License for more details.
 | 
	
		
			
			| 28 |  | -#
 | 
	
		
			
			| 29 |  | -# You should have received a copy of the GNU General Public License
 | 
	
		
			
			| 30 |  | -# along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
	
		
			
			| 31 |  | -
 | 
	
		
			
			| 32 |  | -# The number of arguments
 | 
	
		
			
			| 33 |  | -NO_OF_ARGS=$#
 | 
	
		
			
			| 34 |  | -
 | 
	
		
			
			| 35 |  | -PROJECT_NAME='freedombone'
 | 
	
		
			
			| 36 |  | -
 | 
	
		
			
			| 37 |  | -export TEXTDOMAIN=${PROJECT_NAME}-prep
 | 
	
		
			
			| 38 |  | -export TEXTDOMAINDIR="/usr/share/locale"
 | 
	
		
			
			| 39 |  | -
 | 
	
		
			
			| 40 |  | -# Version number of this script
 | 
	
		
			
			| 41 |  | -VERSION="1.01"
 | 
	
		
			
			| 42 |  | -
 | 
	
		
			
			| 43 |  | -# typically /dev/sdb or /dev/sdc, depending upon how
 | 
	
		
			
			| 44 |  | -# many drives there are on your system
 | 
	
		
			
			| 45 |  | -MICROSD_DRIVE=
 | 
	
		
			
			| 46 |  | -
 | 
	
		
			
			| 47 |  | -# IP address of the router (gateway)
 | 
	
		
			
			| 48 |  | -ROUTER_IP_ADDRESS="192.168.1.254"
 | 
	
		
			
			| 49 |  | -
 | 
	
		
			
			| 50 |  | -# The fixed IP address of the Beaglebone Black on your local network
 | 
	
		
			
			| 51 |  | -BOX_IP_ADDRESS="192.168.1.55"
 | 
	
		
			
			| 52 |  | -
 | 
	
		
			
			| 53 |  | -# DNS
 | 
	
		
			
			| 54 |  | -NAMESERVER1='213.73.91.35'
 | 
	
		
			
			| 55 |  | -NAMESERVER2='85.214.20.141'
 | 
	
		
			
			| 56 |  | -
 | 
	
		
			
			| 57 |  | -MICROSD_MOUNT_POINT="/media/$USER"
 | 
	
		
			
			| 58 |  | -
 | 
	
		
			
			| 59 |  | -DEBIAN_IMAGE_FILENAME=
 | 
	
		
			
			| 60 |  | -DEBIAN_FILE_NAME="bone-debian-8.1-console-armhf-2015-07-12-2gb.img"
 | 
	
		
			
			| 61 |  | -
 | 
	
		
			
			| 62 |  | -# Downloads for the Debian installer
 | 
	
		
			
			| 63 |  | -DOWNLOAD_LINK1="https://rcn-ee.com/rootfs/bb.org/testing/2015-07-12/console/$DEBIAN_FILE_NAME.xz"
 | 
	
		
			
			| 64 |  | -
 | 
	
		
			
			| 65 |  | -ROOTFS='rootfs'
 | 
	
		
			
			| 66 |  | -ROOTFS_SUBDIR=''
 | 
	
		
			
			| 67 |  | -
 | 
	
		
			
			| 68 |  | -PARTITION_NUMBER=1
 | 
	
		
			
			| 69 |  | -
 | 
	
		
			
			| 70 |  | -CURR_DIR=$(pwd)
 | 
	
		
			
			| 71 |  | -
 | 
	
		
			
			| 72 |  | -function show_help {
 | 
	
		
			
			| 73 |  | -    echo ''
 | 
	
		
			
			| 74 |  | -    echo $'freedombone-prep -i [image filename] -d [microSD device] --ip [BBB LAN IP address] --iprouter [Router LAN IP address] --mount [mount directory]'
 | 
	
		
			
			| 75 |  | -    echo ''
 | 
	
		
			
			| 76 |  | -    echo $'See the manpage for more details'
 | 
	
		
			
			| 77 |  | -    echo ''
 | 
	
		
			
			| 78 |  | -}
 | 
	
		
			
			| 79 |  | -
 | 
	
		
			
			| 80 |  | -function configure_networking {
 | 
	
		
			
			| 81 |  | -    rootdir=$1
 | 
	
		
			
			| 82 |  | -	temp_interfaces=/tmp/freedombone_interfaces
 | 
	
		
			
			| 83 |  | -    echo "# This file describes the network interfaces available on your system
 | 
	
		
			
			| 84 |  | -# and how to activate them. For more information, see interfaces(5).
 | 
	
		
			
			| 85 |  | -
 | 
	
		
			
			| 86 |  | -# The loopback network interface
 | 
	
		
			
			| 87 |  | -auto lo
 | 
	
		
			
			| 88 |  | -iface lo inet loopback
 | 
	
		
			
			| 89 |  | -
 | 
	
		
			
			| 90 |  | -# The primary network interface
 | 
	
		
			
			| 91 |  | -auto eth0
 | 
	
		
			
			| 92 |  | -iface eth0 inet static
 | 
	
		
			
			| 93 |  | -    address $BOX_IP_ADDRESS
 | 
	
		
			
			| 94 |  | -    netmask 255.255.255.0
 | 
	
		
			
			| 95 |  | -    gateway $ROUTER_IP_ADDRESS
 | 
	
		
			
			| 96 |  | -    dns-nameservers $NAMESERVER1 $NAMESERVER2
 | 
	
		
			
			| 97 |  | -# Example to keep MAC address between reboots
 | 
	
		
			
			| 98 |  | -#hwaddress ether B5:A2:BE:3F:1A:FE
 | 
	
		
			
			| 99 |  | -
 | 
	
		
			
			| 100 |  | -# The secondary network interface
 | 
	
		
			
			| 101 |  | -#auto eth1
 | 
	
		
			
			| 102 |  | -#iface eth1 inet dhcp
 | 
	
		
			
			| 103 |  | -
 | 
	
		
			
			| 104 |  | -# WiFi Example
 | 
	
		
			
			| 105 |  | -#auto wlan0
 | 
	
		
			
			| 106 |  | -#iface wlan0 inet dhcp
 | 
	
		
			
			| 107 |  | -#    wpa-ssid \"essid\"
 | 
	
		
			
			| 108 |  | -#    wpa-psk  \"password\"
 | 
	
		
			
			| 109 |  | -
 | 
	
		
			
			| 110 |  | -# Ethernet/RNDIS gadget (g_ether)
 | 
	
		
			
			| 111 |  | -# ... or on host side, usbnet and random hwaddr
 | 
	
		
			
			| 112 |  | -# Note on some boards, usb0 is automaticly setup with an init script
 | 
	
		
			
			| 113 |  | -#iface usb0 inet static
 | 
	
		
			
			| 114 |  | -#    address 192.168.7.2
 | 
	
		
			
			| 115 |  | -#    netmask 255.255.255.0
 | 
	
		
			
			| 116 |  | -#    network 192.168.7.0
 | 
	
		
			
			| 117 |  | -#    gateway 192.168.7.1" > $temp_interfaces
 | 
	
		
			
			| 118 |  | -
 | 
	
		
			
			| 119 |  | -    hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
 | 
	
		
			
			| 120 |  | -    a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
 | 
	
		
			
			| 121 |  | -    b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
 | 
	
		
			
			| 122 |  | -    c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
 | 
	
		
			
			| 123 |  | -    d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
 | 
	
		
			
			| 124 |  | -    e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
 | 
	
		
			
			| 125 |  | -    sed -i "s|#hwaddress ether.*|hwaddress ether de:$a:$b:$c:$d:$e|g" \
 | 
	
		
			
			| 126 |  | -        $temp_interfaces
 | 
	
		
			
			| 127 |  | -
 | 
	
		
			
			| 128 |  | -	$SUDO cp $temp_interfaces $rootdir/etc/network/interfaces
 | 
	
		
			
			| 129 |  | -	rm $temp_interfaces
 | 
	
		
			
			| 130 |  | -
 | 
	
		
			
			| 131 |  | -    $SUDO sed -i "s/nameserver.*/nameserver $NAMESERVER1/g" $rootdir/etc/resolv.conf
 | 
	
		
			
			| 132 |  | -    $SUDO sed -i "/nameserver $NAMESERVER1/a\nameserver $NAMESERVER2" $rootdir/etc/resolv.conf
 | 
	
		
			
			| 133 |  | -}
 | 
	
		
			
			| 134 |  | -
 | 
	
		
			
			| 135 |  | -# if no arguments are given
 | 
	
		
			
			| 136 |  | -if [[ $NO_OF_ARGS == 0 ]]; then
 | 
	
		
			
			| 137 |  | -  show_help
 | 
	
		
			
			| 138 |  | -  exit 0
 | 
	
		
			
			| 139 |  | -fi
 | 
	
		
			
			| 140 |  | -
 | 
	
		
			
			| 141 |  | -if [ -d /media ]; then
 | 
	
		
			
			| 142 |  | -    # different directories for Debian
 | 
	
		
			
			| 143 |  | -    if [ -d /media/usb1 ]; then
 | 
	
		
			
			| 144 |  | -        MICROSD_MOUNT_POINT=/media
 | 
	
		
			
			| 145 |  | -        ROOTFS=usb1
 | 
	
		
			
			| 146 |  | -    fi
 | 
	
		
			
			| 147 |  | -    if [ -d /media/usb1/@ ]; then
 | 
	
		
			
			| 148 |  | -        MICROSD_MOUNT_POINT=/media
 | 
	
		
			
			| 149 |  | -        ROOTFS=usb1
 | 
	
		
			
			| 150 |  | -		ROOTFS_SUBDIR='/@'
 | 
	
		
			
			| 151 |  | -    fi
 | 
	
		
			
			| 152 |  | -    if [ -d /media/usb0 ]; then
 | 
	
		
			
			| 153 |  | -        MICROSD_MOUNT_POINT=/media
 | 
	
		
			
			| 154 |  | -    fi
 | 
	
		
			
			| 155 |  | -fi
 | 
	
		
			
			| 156 |  | -if [ ! -d $MICROSD_MOUNT_POINT ]; then
 | 
	
		
			
			| 157 |  | -    echo $"The mount directory $MICROSD_MOUNT_POINT does not exist."
 | 
	
		
			
			| 158 |  | -    echo $'Use the --mount option to specify where the microSD gets mounted to.'
 | 
	
		
			
			| 159 |  | -    exit 67563
 | 
	
		
			
			| 160 |  | -fi
 | 
	
		
			
			| 161 |  | -
 | 
	
		
			
			| 162 |  | -echo "MICROSD_MOUNT_POINT=$MICROSD_MOUNT_POINT"
 | 
	
		
			
			| 163 |  | -
 | 
	
		
			
			| 164 |  | -while [[ $# > 1 ]]
 | 
	
		
			
			| 165 |  | -do
 | 
	
		
			
			| 166 |  | -key="$1"
 | 
	
		
			
			| 167 |  | -
 | 
	
		
			
			| 168 |  | -case $key in
 | 
	
		
			
			| 169 |  | -    -h|--help)
 | 
	
		
			
			| 170 |  | -    show_help
 | 
	
		
			
			| 171 |  | -    ;;
 | 
	
		
			
			| 172 |  | -    # Drive path for the microSD
 | 
	
		
			
			| 173 |  | -    -d|--drive)
 | 
	
		
			
			| 174 |  | -    shift
 | 
	
		
			
			| 175 |  | -    MICROSD_DRIVE="$1"
 | 
	
		
			
			| 176 |  | -    ;;
 | 
	
		
			
			| 177 |  | -    # debian disk image created with freedombone-image
 | 
	
		
			
			| 178 |  | -    -i|--image)
 | 
	
		
			
			| 179 |  | -    shift
 | 
	
		
			
			| 180 |  | -    DEBIAN_IMAGE_FILENAME="$1"
 | 
	
		
			
			| 181 |  | -    ROOTFS_SUBDIR='/@'
 | 
	
		
			
			| 182 |  | -    ;;
 | 
	
		
			
			| 183 |  | -    # BBB static IP address on the LAN
 | 
	
		
			
			| 184 |  | -    --ip)
 | 
	
		
			
			| 185 |  | -    shift
 | 
	
		
			
			| 186 |  | -    BOX_IP_ADDRESS="$1"
 | 
	
		
			
			| 187 |  | -    ;;
 | 
	
		
			
			| 188 |  | -    # Router IP address on the LAN
 | 
	
		
			
			| 189 |  | -    --iprouter)
 | 
	
		
			
			| 190 |  | -    shift
 | 
	
		
			
			| 191 |  | -    ROUTER_IP_ADDRESS="$1"
 | 
	
		
			
			| 192 |  | -    ;;
 | 
	
		
			
			| 193 |  | -    # mount point
 | 
	
		
			
			| 194 |  | -    --mount)
 | 
	
		
			
			| 195 |  | -    shift
 | 
	
		
			
			| 196 |  | -    MICROSD_MOUNT_POINT="$1"
 | 
	
		
			
			| 197 |  | -    ;;
 | 
	
		
			
			| 198 |  | -    # nameserver 1
 | 
	
		
			
			| 199 |  | -    --ns1)
 | 
	
		
			
			| 200 |  | -    shift
 | 
	
		
			
			| 201 |  | -    NAMESERVER1="$1"
 | 
	
		
			
			| 202 |  | -    ;;
 | 
	
		
			
			| 203 |  | -    # nameserver 2
 | 
	
		
			
			| 204 |  | -    --ns2)
 | 
	
		
			
			| 205 |  | -    shift
 | 
	
		
			
			| 206 |  | -    NAMESERVER2="$1"
 | 
	
		
			
			| 207 |  | -    ;;
 | 
	
		
			
			| 208 |  | -    *)
 | 
	
		
			
			| 209 |  | -    # unknown option
 | 
	
		
			
			| 210 |  | -    ;;
 | 
	
		
			
			| 211 |  | -esac
 | 
	
		
			
			| 212 |  | -shift
 | 
	
		
			
			| 213 |  | -done
 | 
	
		
			
			| 214 |  | -
 | 
	
		
			
			| 215 |  | -
 | 
	
		
			
			| 216 |  | -if [ ! $MICROSD_DRIVE ]; then
 | 
	
		
			
			| 217 |  | -    echo $'You need to specify a drive for the connected microSD.'
 | 
	
		
			
			| 218 |  | -    echo $'This can most easily be found by removing the microSD, then'
 | 
	
		
			
			| 219 |  | -    echo $'running:'
 | 
	
		
			
			| 220 |  | -    echo ''
 | 
	
		
			
			| 221 |  | -    echo '  ls /dev/sd*'
 | 
	
		
			
			| 222 |  | -    echo ''
 | 
	
		
			
			| 223 |  | -    echo 'or'
 | 
	
		
			
			| 224 |  | -    echo ''
 | 
	
		
			
			| 225 |  | -    echo '  ls /dev/mmcblk*'
 | 
	
		
			
			| 226 |  | -    echo ''
 | 
	
		
			
			| 227 |  | -    echo $'Then plugging the microSD back in and entering the same command again'
 | 
	
		
			
			| 228 |  | -    exit 1
 | 
	
		
			
			| 229 |  | -fi
 | 
	
		
			
			| 230 |  | -
 | 
	
		
			
			| 231 |  | -if [ ! -b ${MICROSD_DRIVE}${PARTITION_NUMBER} ]; then
 | 
	
		
			
			| 232 |  | -    if [ -b ${MICROSD_DRIVE}p${PARTITION_NUMBER} ]; then
 | 
	
		
			
			| 233 |  | -        PARTITION_NUMBER=p${PARTITION_NUMBER}
 | 
	
		
			
			| 234 |  | -    else
 | 
	
		
			
			| 235 |  | -        echo $"The microSD drive could not be found at ${MICROSD_DRIVE}1"
 | 
	
		
			
			| 236 |  | -        exit 2
 | 
	
		
			
			| 237 |  | -    fi
 | 
	
		
			
			| 238 |  | -fi
 | 
	
		
			
			| 239 |  | -
 | 
	
		
			
			| 240 |  | -SUDO=
 | 
	
		
			
			| 241 |  | -if [ -f /usr/bin/sudo ]; then
 | 
	
		
			
			| 242 |  | -    SUDO='sudo'
 | 
	
		
			
			| 243 |  | -fi
 | 
	
		
			
			| 244 |  | -$SUDO apt-get install p7zip wget
 | 
	
		
			
			| 245 |  | -
 | 
	
		
			
			| 246 |  | -if [ ! -d ~/freedombone ]; then
 | 
	
		
			
			| 247 |  | -    mkdir ~/freedombone
 | 
	
		
			
			| 248 |  | -fi
 | 
	
		
			
			| 249 |  | -cd ~/freedombone
 | 
	
		
			
			| 250 |  | -
 | 
	
		
			
			| 251 |  | -# extract the image
 | 
	
		
			
			| 252 |  | -if [ $DEBIAN_IMAGE_FILENAME ]; then
 | 
	
		
			
			| 253 |  | -    # debian image filename specified as an option
 | 
	
		
			
			| 254 |  | -    if [[ $DEBIAN_IMAGE_FILENAME == *".bz2" ]]; then
 | 
	
		
			
			| 255 |  | -        tar -xjvf $DEBIAN_IMAGE_FILENAME
 | 
	
		
			
			| 256 |  | -        pattern="*.img"
 | 
	
		
			
			| 257 |  | -        files=( $pattern )
 | 
	
		
			
			| 258 |  | -        DEBIAN_IMAGE_FILENAME=${files[0]}
 | 
	
		
			
			| 259 |  | -    fi
 | 
	
		
			
			| 260 |  | -    if [[ $DEBIAN_IMAGE_FILENAME != *".img" ]]; then
 | 
	
		
			
			| 261 |  | -        echo $'Debian image (.img) file expected'
 | 
	
		
			
			| 262 |  | -        exit 62394
 | 
	
		
			
			| 263 |  | -    fi
 | 
	
		
			
			| 264 |  | -    DEBIAN_FILE_NAME=$DEBIAN_IMAGE_FILENAME
 | 
	
		
			
			| 265 |  | -    if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME ]; then
 | 
	
		
			
			| 266 |  | -		cd $CURR_DIR
 | 
	
		
			
			| 267 |  | -        cp $DEBIAN_FILE_NAME ~/freedombone/$DEBIAN_FILE_NAME
 | 
	
		
			
			| 268 |  | -		cd ~/freedombone
 | 
	
		
			
			| 269 |  | -    fi
 | 
	
		
			
			| 270 |  | -else
 | 
	
		
			
			| 271 |  | -    # default debian image downloaded from elsewhere
 | 
	
		
			
			| 272 |  | -    if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.xz ]; then
 | 
	
		
			
			| 273 |  | -        if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME ]; then
 | 
	
		
			
			| 274 |  | -            wget $DOWNLOAD_LINK1
 | 
	
		
			
			| 275 |  | -        fi
 | 
	
		
			
			| 276 |  | -    fi
 | 
	
		
			
			| 277 |  | -    xz -d $DEBIAN_FILE_NAME.xz
 | 
	
		
			
			| 278 |  | -fi
 | 
	
		
			
			| 279 |  | -
 | 
	
		
			
			| 280 |  | -if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME ]; then
 | 
	
		
			
			| 281 |  | -    echo $"Couldn't extract image $DEBIAN_FILE_NAME"
 | 
	
		
			
			| 282 |  | -    exit 4
 | 
	
		
			
			| 283 |  | -fi
 | 
	
		
			
			| 284 |  | -
 | 
	
		
			
			| 285 |  | -cd ~/freedombone
 | 
	
		
			
			| 286 |  | -echo $'Flashing image. This may take a while.'
 | 
	
		
			
			| 287 |  | -#$SUDO dd if=$DEBIAN_FILE_NAME of=$MICROSD_DRIVE
 | 
	
		
			
			| 288 |  | -sync
 | 
	
		
			
			| 289 |  | -
 | 
	
		
			
			| 290 |  | -sleep 5
 | 
	
		
			
			| 291 |  | -if [ -d $MICROSD_MOUNT_POINT/$ROOTFS ]; then
 | 
	
		
			
			| 292 |  | -    umount $MICROSD_MOUNT_POINT/$ROOTFS
 | 
	
		
			
			| 293 |  | -    $SUDO rm $MICROSD_MOUNT_POINT/$ROOTFS
 | 
	
		
			
			| 294 |  | -fi
 | 
	
		
			
			| 295 |  | -$SUDO mkdir -p $MICROSD_MOUNT_POINT/$ROOTFS
 | 
	
		
			
			| 296 |  | -$SUDO mount ${MICROSD_DRIVE}${PARTITION_NUMBER} $MICROSD_MOUNT_POINT/$ROOTFS
 | 
	
		
			
			| 297 |  | -sync
 | 
	
		
			
			| 298 |  | -
 | 
	
		
			
			| 299 |  | -if [ ! -b ${MICROSD_DRIVE}${PARTITION_NUMBER} ]; then
 | 
	
		
			
			| 300 |  | -    echo ''
 | 
	
		
			
			| 301 |  | -    echo $"The microSD drive could not be found at ${MICROSD_DRIVE}${PARTITION_NUMBER}"
 | 
	
		
			
			| 302 |  | -    read -p $"Wait for the drive to mount then press any key... " -n1 -s
 | 
	
		
			
			| 303 |  | -    if [ ! -b ${MICROSD_DRIVE}${PARTITION_NUMBER} ]; then
 | 
	
		
			
			| 304 |  | -        echo $"microSD drive not found at ${MICROSD_DRIVE}${PARTITION_NUMBER}"
 | 
	
		
			
			| 305 |  | -        exit 5
 | 
	
		
			
			| 306 |  | -    fi
 | 
	
		
			
			| 307 |  | -fi
 | 
	
		
			
			| 308 |  | -
 | 
	
		
			
			| 309 |  | -if [ ! -d $MICROSD_MOUNT_POINT/$ROOTFS ]; then
 | 
	
		
			
			| 310 |  | -    echo ''
 | 
	
		
			
			| 311 |  | -    echo $"The rootfs partition $MICROSD_MOUNT_POINT/$ROOTFS was not found."
 | 
	
		
			
			| 312 |  | -    ls $MICROSD_MOUNT_POINT
 | 
	
		
			
			| 313 |  | -    exit 65688
 | 
	
		
			
			| 314 |  | -fi
 | 
	
		
			
			| 315 |  | -
 | 
	
		
			
			| 316 |  | -if [ ! -d $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/home ]; then
 | 
	
		
			
			| 317 |  | -    echo ''
 | 
	
		
			
			| 318 |  | -    echo $"The rootfs partition was not written correctly."
 | 
	
		
			
			| 319 |  | -    ls $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR
 | 
	
		
			
			| 320 |  | -    exit 65688
 | 
	
		
			
			| 321 |  | -fi
 | 
	
		
			
			| 322 |  | -
 | 
	
		
			
			| 323 |  | -configure_networking $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR
 | 
	
		
			
			| 324 |  | -
 | 
	
		
			
			| 325 |  | -# copy the commands to the card
 | 
	
		
			
			| 326 |  | -$SUDO cp -f $(which freedombone)* $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/
 | 
	
		
			
			| 327 |  | -$SUDO cp -f $(which zeronetavahi)* $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/
 | 
	
		
			
			| 328 |  | -$SUDO cp -f $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/freedombone-mesh $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/mesh
 | 
	
		
			
			| 329 |  | -$SUDO cp -f $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/freedombone-meshweb $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/meshweb
 | 
	
		
			
			| 330 |  | -if [ ! -f $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/freedombone ]; then
 | 
	
		
			
			| 331 |  | -    echo $'There was a problem with writing freedombone commands to the SD card'
 | 
	
		
			
			| 332 |  | -    exit 8736
 | 
	
		
			
			| 333 |  | -fi
 | 
	
		
			
			| 334 |  | -
 | 
	
		
			
			| 335 |  | -# remove automatic motd creator if it exists
 | 
	
		
			
			| 336 |  | -if [ -f $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/init.d/motd ]; then
 | 
	
		
			
			| 337 |  | -    $SUDO rm -f $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/init.d/motd
 | 
	
		
			
			| 338 |  | -fi
 | 
	
		
			
			| 339 |  | -
 | 
	
		
			
			| 340 |  | -# change the motd to show further install instructions
 | 
	
		
			
			| 341 |  | -echo '' >> /tmp/freedombone_motd
 | 
	
		
			
			| 342 |  | -echo $'Create a user for the system with:' >> /tmp/freedombone_motd
 | 
	
		
			
			| 343 |  | -echo '' >> /tmp/freedombone_motd
 | 
	
		
			
			| 344 |  | -echo '    adduser [username]' >> /tmp/freedombone_motd
 | 
	
		
			
			| 345 |  | -echo '' >> /tmp/freedombone_motd
 | 
	
		
			
			| 346 |  | -echo $'Enter the command "exit" a couple of times to get back to your main system' >> /tmp/freedombone_motd
 | 
	
		
			
			| 347 |  | -echo $'then log back in as the user you just created with:' >> /tmp/freedombone_motd
 | 
	
		
			
			| 348 |  | -echo '' >> /tmp/freedombone_motd
 | 
	
		
			
			| 349 |  | -echo "    ssh [username]@$BOX_IP_ADDRESS" >> /tmp/freedombone_motd
 | 
	
		
			
			| 350 |  | -echo '' >> /tmp/freedombone_motd
 | 
	
		
			
			| 351 |  | -echo $'and use the "su" command to become the root user again.' >> /tmp/freedombone_motd
 | 
	
		
			
			| 352 |  | -echo '' >> /tmp/freedombone_motd
 | 
	
		
			
			| 353 |  | -echo $'Finally you can use the freedombone command to install a server configuration:' >> /tmp/freedombone_motd
 | 
	
		
			
			| 354 |  | -echo '' >> /tmp/freedombone_motd
 | 
	
		
			
			| 355 |  | -echo '    apt-get update' >> /tmp/freedombone_motd
 | 
	
		
			
			| 356 |  | -echo '    apt-get -y install git dialog build-essential' >> /tmp/freedombone_motd
 | 
	
		
			
			| 357 |  | -echo '    freedombone menuconfig' >> /tmp/freedombone_motd
 | 
	
		
			
			| 358 |  | -
 | 
	
		
			
			| 359 |  | -$SUDO cp -f /tmp/freedombone_motd $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/motd
 | 
	
		
			
			| 360 |  | -
 | 
	
		
			
			| 361 |  | -clear
 | 
	
		
			
			| 362 |  | -echo $'*** Initial microSD card setup is complete ***'
 | 
	
		
			
			| 363 |  | -echo ''
 | 
	
		
			
			| 364 |  | -echo $'To avoid running out of disk space you may first wish to resize the'
 | 
	
		
			
			| 365 |  | -echo $'partition to the size of your microSD card, using something like gparted.'
 | 
	
		
			
			| 366 |  | -echo ''
 | 
	
		
			
			| 367 |  | -echo $'The microSD card can now be removed and inserted into the Beaglebone Black.'
 | 
	
		
			
			| 368 |  | -echo $'Once the Beaglebone has booted then you can log in with:'
 | 
	
		
			
			| 369 |  | -echo ''
 | 
	
		
			
			| 370 |  | -echo "    ssh root@$BOX_IP_ADDRESS"
 | 
	
		
			
			| 371 |  | -echo ''
 | 
	
		
			
			| 372 |  | -echo $'The root password should be changed with the command "passwd".'
 | 
	
		
			
			| 373 |  | -cat /tmp/freedombone_motd
 | 
	
		
			
			| 374 |  | -rm /tmp/freedombone_motd
 | 
	
		
			
			| 375 |  | -$SUDO umount $MICROSD_MOUNT_POINT/$ROOTFS
 | 
	
		
			
			| 376 |  | -sync
 | 
	
		
			
			| 377 |  | -if [ -d $MICROSD_MOUNT_POINT/$ROOTFS ]; then
 | 
	
		
			
			| 378 |  | -    $SUDO rm -rf $MICROSD_MOUNT_POINT/$ROOTFS
 | 
	
		
			
			| 379 |  | -fi
 | 
	
		
			
			| 380 |  | -exit 0
 |