| 
				
			 | 
			
			
				@@ -43,7 +43,7 @@ MICROSD_DRIVE= 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				43
			 | 
			
			
				 ROUTER_IP_ADDRESS="192.168.1.254" 
			 | 
		
	
		
			
			| 
				44
			 | 
			
				44
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				45
			 | 
			
				45
			 | 
			
			
				 # The fixed IP address of the Beaglebone Black on your local network 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				
			 | 
			
			
				-BBB_FIXED_IP_ADDRESS="192.168.1.55" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				46
			 | 
			
			
				+BOX_IP_ADDRESS="192.168.1.55" 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				47
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				48
			 | 
			
				48
			 | 
			
			
				 # DNS 
			 | 
		
	
		
			
			| 
				49
			 | 
			
				49
			 | 
			
			
				 NAMESERVER1='213.73.91.35' 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -66,12 +66,67 @@ CURR_DIR=$(pwd) 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				66
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				67
			 | 
			
				67
			 | 
			
			
				 function show_help { 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				68
			 | 
			
			
				     echo '' 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				
			 | 
			
			
				-    echo 'freedombone-prep -d [microSD device] --ip [BBB LAN IP address] --iprouter [Router LAN IP address] --mount [mount directory]' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				+    echo 'freedombone-prep -i [image filename] -d [microSD device] --ip [BBB LAN IP address] --iprouter [Router LAN IP address] --mount [mount directory]' 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				70
			 | 
			
			
				     echo '' 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				71
			 | 
			
			
				     echo 'See the manpage for more details' 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				72
			 | 
			
			
				     echo '' 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				73
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				74
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				75
			 | 
			
			
				+function configure_networking { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				76
			 | 
			
			
				+    rootdir=$1 
			 | 
		
	
		
			
			| 
				
			 | 
			
				77
			 | 
			
			
				+	temp_interfaces=/tmp/freedombone_interfaces 
			 | 
		
	
		
			
			| 
				
			 | 
			
				78
			 | 
			
			
				+    echo "# This file describes the network interfaces available on your system 
			 | 
		
	
		
			
			| 
				
			 | 
			
				79
			 | 
			
			
				+# and how to activate them. For more information, see interfaces(5). 
			 | 
		
	
		
			
			| 
				
			 | 
			
				80
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				+# The loopback network interface 
			 | 
		
	
		
			
			| 
				
			 | 
			
				82
			 | 
			
			
				+auto lo 
			 | 
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				+iface lo inet loopback 
			 | 
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				+# The primary network interface 
			 | 
		
	
		
			
			| 
				
			 | 
			
				86
			 | 
			
			
				+auto eth0 
			 | 
		
	
		
			
			| 
				
			 | 
			
				87
			 | 
			
			
				+iface eth0 inet static 
			 | 
		
	
		
			
			| 
				
			 | 
			
				88
			 | 
			
			
				+    address $BOX_IP_ADDRESS 
			 | 
		
	
		
			
			| 
				
			 | 
			
				89
			 | 
			
			
				+    netmask 255.255.255.0 
			 | 
		
	
		
			
			| 
				
			 | 
			
				90
			 | 
			
			
				+    gateway $ROUTER_IP_ADDRESS 
			 | 
		
	
		
			
			| 
				
			 | 
			
				91
			 | 
			
			
				+    dns-nameservers $NAMESERVER1 $NAMESERVER2 
			 | 
		
	
		
			
			| 
				
			 | 
			
				92
			 | 
			
			
				+# Example to keep MAC address between reboots 
			 | 
		
	
		
			
			| 
				
			 | 
			
				93
			 | 
			
			
				+#hwaddress ether B5:A2:BE:3F:1A:FE 
			 | 
		
	
		
			
			| 
				
			 | 
			
				94
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				95
			 | 
			
			
				+# The secondary network interface 
			 | 
		
	
		
			
			| 
				
			 | 
			
				96
			 | 
			
			
				+#auto eth1 
			 | 
		
	
		
			
			| 
				
			 | 
			
				97
			 | 
			
			
				+#iface eth1 inet dhcp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				98
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				99
			 | 
			
			
				+# WiFi Example 
			 | 
		
	
		
			
			| 
				
			 | 
			
				100
			 | 
			
			
				+#auto wlan0 
			 | 
		
	
		
			
			| 
				
			 | 
			
				101
			 | 
			
			
				+#iface wlan0 inet dhcp 
			 | 
		
	
		
			
			| 
				
			 | 
			
				102
			 | 
			
			
				+#    wpa-ssid \"essid\" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				103
			 | 
			
			
				+#    wpa-psk  \"password\" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				104
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				105
			 | 
			
			
				+# Ethernet/RNDIS gadget (g_ether) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				106
			 | 
			
			
				+# ... or on host side, usbnet and random hwaddr 
			 | 
		
	
		
			
			| 
				
			 | 
			
				107
			 | 
			
			
				+# Note on some boards, usb0 is automaticly setup with an init script 
			 | 
		
	
		
			
			| 
				
			 | 
			
				108
			 | 
			
			
				+#iface usb0 inet static 
			 | 
		
	
		
			
			| 
				
			 | 
			
				109
			 | 
			
			
				+#    address 192.168.7.2 
			 | 
		
	
		
			
			| 
				
			 | 
			
				110
			 | 
			
			
				+#    netmask 255.255.255.0 
			 | 
		
	
		
			
			| 
				
			 | 
			
				111
			 | 
			
			
				+#    network 192.168.7.0 
			 | 
		
	
		
			
			| 
				
			 | 
			
				112
			 | 
			
			
				+#    gateway 192.168.7.1" > $temp_interfaces 
			 | 
		
	
		
			
			| 
				
			 | 
			
				113
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				114
			 | 
			
			
				+    hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f ) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				115
			 | 
			
			
				+    a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				116
			 | 
			
			
				+    b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				117
			 | 
			
			
				+    c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				118
			 | 
			
			
				+    d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				119
			 | 
			
			
				+    e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				120
			 | 
			
			
				+    sed -i "s|#hwaddress ether.*|hwaddress ether de:$a:$b:$c:$d:$e|g" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				121
			 | 
			
			
				+        $temp_interfaces 
			 | 
		
	
		
			
			| 
				
			 | 
			
				122
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				123
			 | 
			
			
				+	$SUDO cp $temp_interfaces $rootdir/etc/network/interfaces 
			 | 
		
	
		
			
			| 
				
			 | 
			
				124
			 | 
			
			
				+	rm $temp_interfaces 
			 | 
		
	
		
			
			| 
				
			 | 
			
				125
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				126
			 | 
			
			
				+    $SUDO sed -i "s/nameserver.*/nameserver $NAMESERVER1/g" $rootdir/etc/resolv.conf 
			 | 
		
	
		
			
			| 
				
			 | 
			
				127
			 | 
			
			
				+    $SUDO sed -i "/nameserver $NAMESERVER1/a\nameserver $NAMESERVER2" $rootdir/etc/resolv.conf 
			 | 
		
	
		
			
			| 
				
			 | 
			
				128
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				129
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				130
			 | 
			
			
				 # if no arguments are given 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				131
			 | 
			
			
				 if [[ $NO_OF_ARGS == 0 ]]; then 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				132
			 | 
			
			
				   show_help 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -123,7 +178,7 @@ case $key in 
			 | 
		
	
		
			
			| 
				123
			 | 
			
				178
			 | 
			
			
				     # BBB static IP address on the LAN 
			 | 
		
	
		
			
			| 
				124
			 | 
			
				179
			 | 
			
			
				     --ip) 
			 | 
		
	
		
			
			| 
				125
			 | 
			
				180
			 | 
			
			
				     shift 
			 | 
		
	
		
			
			| 
				126
			 | 
			
				
			 | 
			
			
				-    BBB_FIXED_IP_ADDRESS="$1" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				181
			 | 
			
			
				+    BOX_IP_ADDRESS="$1" 
			 | 
		
	
		
			
			| 
				127
			 | 
			
				182
			 | 
			
			
				     ;; 
			 | 
		
	
		
			
			| 
				128
			 | 
			
				183
			 | 
			
			
				     # Router IP address on the LAN 
			 | 
		
	
		
			
			| 
				129
			 | 
			
				184
			 | 
			
			
				     --iprouter) 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -260,23 +315,7 @@ if [ ! -d $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/home ]; then 
			 | 
		
	
		
			
			| 
				260
			 | 
			
				315
			 | 
			
			
				     exit 65688 
			 | 
		
	
		
			
			| 
				261
			 | 
			
				316
			 | 
			
			
				 fi 
			 | 
		
	
		
			
			| 
				262
			 | 
			
				317
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				263
			 | 
			
				
			 | 
			
			
				-$SUDO sed -i 's/iface eth0 inet dhcp/iface eth0 inet static/g' $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/network/interfaces 
			 | 
		
	
		
			
			| 
				264
			 | 
			
				
			 | 
			
			
				-$SUDO sed -i "/iface eth0 inet static/a\    dns-nameservers $NAMESERVER1 $NAMESERVER2" $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/network/interfaces 
			 | 
		
	
		
			
			| 
				265
			 | 
			
				
			 | 
			
			
				-$SUDO sed -i "/iface eth0 inet static/a\    gateway $ROUTER_IP_ADDRESS" $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/network/interfaces 
			 | 
		
	
		
			
			| 
				266
			 | 
			
				
			 | 
			
			
				-$SUDO sed -i '/iface eth0 inet static/a\    netmask 255.255.255.0' $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/network/interfaces 
			 | 
		
	
		
			
			| 
				267
			 | 
			
				
			 | 
			
			
				-$SUDO sed -i "/iface eth0 inet static/a\    address $BBB_FIXED_IP_ADDRESS" $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/network/interfaces 
			 | 
		
	
		
			
			| 
				268
			 | 
			
				
			 | 
			
			
				-$SUDO sed -i '/iface usb0 inet static/,/    gateway 192.168.7.1/ s/^/#/' $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/network/interfaces 
			 | 
		
	
		
			
			| 
				269
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				270
			 | 
			
				
			 | 
			
			
				-hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f ) 
			 | 
		
	
		
			
			| 
				271
			 | 
			
				
			 | 
			
			
				-a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} 
			 | 
		
	
		
			
			| 
				272
			 | 
			
				
			 | 
			
			
				-b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} 
			 | 
		
	
		
			
			| 
				273
			 | 
			
				
			 | 
			
			
				-c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} 
			 | 
		
	
		
			
			| 
				274
			 | 
			
				
			 | 
			
			
				-d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} 
			 | 
		
	
		
			
			| 
				275
			 | 
			
				
			 | 
			
			
				-e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} 
			 | 
		
	
		
			
			| 
				276
			 | 
			
				
			 | 
			
			
				-$SUDO sed -i "s|#hwaddress ether.*|hwaddress ether de:$a:$b:$c:$d:$e|g" $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/network/interfaces 
			 | 
		
	
		
			
			| 
				277
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				278
			 | 
			
				
			 | 
			
			
				-$SUDO sed -i "s/nameserver.*/nameserver $NAMESERVER1/g" $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/resolv.conf 
			 | 
		
	
		
			
			| 
				279
			 | 
			
				
			 | 
			
			
				-$SUDO sed -i "/nameserver $NAMESERVER1/a\nameserver $NAMESERVER2" $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/resolv.conf 
			 | 
		
	
		
			
			| 
				
			 | 
			
				318
			 | 
			
			
				+configure_networking $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR 
			 | 
		
	
		
			
			| 
				280
			 | 
			
				319
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				281
			 | 
			
				320
			 | 
			
			
				 # copy the commands to the card 
			 | 
		
	
		
			
			| 
				282
			 | 
			
				321
			 | 
			
			
				 $SUDO cp -f $(which freedombone)* $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/ 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -302,7 +341,7 @@ echo '' >> /tmp/freedombone_motd 
			 | 
		
	
		
			
			| 
				302
			 | 
			
				341
			 | 
			
			
				 echo 'Enter the command "exit" a couple of times to get back to your main system' >> /tmp/freedombone_motd 
			 | 
		
	
		
			
			| 
				303
			 | 
			
				342
			 | 
			
			
				 echo 'then log back in as the user you just created with:' >> /tmp/freedombone_motd 
			 | 
		
	
		
			
			| 
				304
			 | 
			
				343
			 | 
			
			
				 echo '' >> /tmp/freedombone_motd 
			 | 
		
	
		
			
			| 
				305
			 | 
			
				
			 | 
			
			
				-echo "    ssh [username]@$BBB_FIXED_IP_ADDRESS" >> /tmp/freedombone_motd 
			 | 
		
	
		
			
			| 
				
			 | 
			
				344
			 | 
			
			
				+echo "    ssh [username]@$BOX_IP_ADDRESS" >> /tmp/freedombone_motd 
			 | 
		
	
		
			
			| 
				306
			 | 
			
				345
			 | 
			
			
				 echo '' >> /tmp/freedombone_motd 
			 | 
		
	
		
			
			| 
				307
			 | 
			
				346
			 | 
			
			
				 echo 'and use the "su" command to become the root user again.' >> /tmp/freedombone_motd 
			 | 
		
	
		
			
			| 
				308
			 | 
			
				347
			 | 
			
			
				 echo '' >> /tmp/freedombone_motd 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -323,7 +362,7 @@ echo '' 
			 | 
		
	
		
			
			| 
				323
			 | 
			
				362
			 | 
			
			
				 echo 'The microSD card can now be removed and inserted into the Beaglebone Black.' 
			 | 
		
	
		
			
			| 
				324
			 | 
			
				363
			 | 
			
			
				 echo 'Once the Beaglebone has booted then you can log in with:' 
			 | 
		
	
		
			
			| 
				325
			 | 
			
				364
			 | 
			
			
				 echo '' 
			 | 
		
	
		
			
			| 
				326
			 | 
			
				
			 | 
			
			
				-echo "    ssh root@$BBB_FIXED_IP_ADDRESS" 
			 | 
		
	
		
			
			| 
				
			 | 
			
				365
			 | 
			
			
				+echo "    ssh root@$BOX_IP_ADDRESS" 
			 | 
		
	
		
			
			| 
				327
			 | 
			
				366
			 | 
			
			
				 echo '' 
			 | 
		
	
		
			
			| 
				328
			 | 
			
				367
			 | 
			
			
				 echo 'The root password should be changed with the command "passwd".' 
			 | 
		
	
		
			
			| 
				329
			 | 
			
				368
			 | 
			
			
				 cat /tmp/freedombone_motd 
			 |