|  | @@ -51,10 +51,11 @@ NAMESERVER2='85.214.20.141'
 | 
	
		
			
			| 51 | 51 |  
 | 
	
		
			
			| 52 | 52 |  MICROSD_MOUNT_POINT="/media/$USER"
 | 
	
		
			
			| 53 | 53 |  
 | 
	
		
			
			| 54 |  | -DEBIAN_FILE_NAME="bone-debian-8.1-console-armhf-2015-07-12-2gb"
 | 
	
		
			
			|  | 54 | +DEBIAN_IMAGE_FILENAME=
 | 
	
		
			
			|  | 55 | +DEBIAN_FILE_NAME="bone-debian-8.1-console-armhf-2015-07-12-2gb.img"
 | 
	
		
			
			| 55 | 56 |  
 | 
	
		
			
			| 56 | 57 |  # Downloads for the Debian installer
 | 
	
		
			
			| 57 |  | -DOWNLOAD_LINK1="https://rcn-ee.com/rootfs/bb.org/testing/2015-07-12/console/$DEBIAN_FILE_NAME.img.xz"
 | 
	
		
			
			|  | 58 | +DOWNLOAD_LINK1="https://rcn-ee.com/rootfs/bb.org/testing/2015-07-12/console/$DEBIAN_FILE_NAME.xz"
 | 
	
		
			
			| 58 | 59 |  
 | 
	
		
			
			| 59 | 60 |  ROOTFS='rootfs'
 | 
	
		
			
			| 60 | 61 |  
 | 
	
	
		
			
			|  | @@ -106,6 +107,11 @@ case $key in
 | 
	
		
			
			| 106 | 107 |      MICROSD_DRIVE="$1"
 | 
	
		
			
			| 107 | 108 |      ;;
 | 
	
		
			
			| 108 | 109 |      # BBB static IP address on the LAN
 | 
	
		
			
			|  | 110 | +    -i|--image)
 | 
	
		
			
			|  | 111 | +    shift
 | 
	
		
			
			|  | 112 | +    DEBIAN_IMAGE_FILENAME="$1"
 | 
	
		
			
			|  | 113 | +    ;;
 | 
	
		
			
			|  | 114 | +    # BBB static IP address on the LAN
 | 
	
		
			
			| 109 | 115 |      --ip)
 | 
	
		
			
			| 110 | 116 |      shift
 | 
	
		
			
			| 111 | 117 |      BBB_FIXED_IP_ADDRESS="$1"
 | 
	
	
		
			
			|  | @@ -172,22 +178,39 @@ if [ ! -d ~/freedombone ]; then
 | 
	
		
			
			| 172 | 178 |      mkdir ~/freedombone
 | 
	
		
			
			| 173 | 179 |  fi
 | 
	
		
			
			| 174 | 180 |  cd ~/freedombone
 | 
	
		
			
			| 175 |  | -if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.img.xz ]; then
 | 
	
		
			
			| 176 |  | -    if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.img ]; then
 | 
	
		
			
			| 177 |  | -        wget $DOWNLOAD_LINK1
 | 
	
		
			
			|  | 181 | +
 | 
	
		
			
			|  | 182 | +# extract the image
 | 
	
		
			
			|  | 183 | +if [ $DEBIAN_IMAGE_FILENAME ]; then
 | 
	
		
			
			|  | 184 | +    # debian image filename specified as an option
 | 
	
		
			
			|  | 185 | +    if [[ $DEBIAN_IMAGE_FILENAME == *".bz2" ]]; then
 | 
	
		
			
			|  | 186 | +        tar -xjvf $DEBIAN_IMAGE_FILENAME
 | 
	
		
			
			|  | 187 | +        pattern="*.img"
 | 
	
		
			
			|  | 188 | +        files=( $pattern )
 | 
	
		
			
			|  | 189 | +        DEBIAN_IMAGE_FILENAME=${files[0]}
 | 
	
		
			
			|  | 190 | +    fi
 | 
	
		
			
			|  | 191 | +    if [[ $DEBIAN_IMAGE_FILENAME != *".img" ]]; then
 | 
	
		
			
			|  | 192 | +        echo 'Debian image (.img) file expected'
 | 
	
		
			
			|  | 193 | +        exit 62394
 | 
	
		
			
			|  | 194 | +    fi
 | 
	
		
			
			|  | 195 | +    DEBIAN_FILE_NAME=$DEBIAN_IMAGE_FILENAME
 | 
	
		
			
			|  | 196 | +else
 | 
	
		
			
			|  | 197 | +    # default debian image downloaded from elsewhere
 | 
	
		
			
			|  | 198 | +    if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.xz ]; then
 | 
	
		
			
			|  | 199 | +        if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME ]; then
 | 
	
		
			
			|  | 200 | +            wget $DOWNLOAD_LINK1
 | 
	
		
			
			|  | 201 | +        fi
 | 
	
		
			
			| 178 | 202 |      fi
 | 
	
		
			
			|  | 203 | +    xz -d $DEBIAN_FILE_NAME.xz
 | 
	
		
			
			| 179 | 204 |  fi
 | 
	
		
			
			| 180 | 205 |  
 | 
	
		
			
			| 181 |  | -echo 'Extracting image...'
 | 
	
		
			
			| 182 |  | -xz -d $DEBIAN_FILE_NAME.img.xz
 | 
	
		
			
			| 183 |  | -if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.img ]; then
 | 
	
		
			
			| 184 |  | -    echo "Couldn't extract image"
 | 
	
		
			
			|  | 206 | +if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME ]; then
 | 
	
		
			
			|  | 207 | +    echo "Couldn't extract image $DEBIAN_FILE_NAME"
 | 
	
		
			
			| 185 | 208 |      exit 4
 | 
	
		
			
			| 186 | 209 |  fi
 | 
	
		
			
			| 187 | 210 |  
 | 
	
		
			
			| 188 | 211 |  cd ~/freedombone
 | 
	
		
			
			| 189 | 212 |  echo 'Flashing image. This may take a while.'
 | 
	
		
			
			| 190 |  | -$SUDO dd if=$DEBIAN_FILE_NAME.img of=$MICROSD_DRIVE
 | 
	
		
			
			|  | 213 | +$SUDO dd if=$DEBIAN_FILE_NAME of=$MICROSD_DRIVE
 | 
	
		
			
			| 191 | 214 |  sync
 | 
	
		
			
			| 192 | 215 |  
 | 
	
		
			
			| 193 | 216 |  sleep 5
 |