Browse Source

Improve the image command

Bob Mottram 9 years ago
parent
commit
4fccf12c69

BIN
man/freedombone-image.1.gz View File


+ 83
- 9
src/freedombone-image View File

28
 # You should have received a copy of the GNU General Public License
28
 # You should have received a copy of the GNU General Public License
29
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
29
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
30
 
30
 
31
-IMAGE_TYPE=$1
31
+IMAGE_TYPE='beaglebone'
32
 CURR_DIR=$(pwd)
32
 CURR_DIR=$(pwd)
33
 BUILD_DIR=~/.tmp_freedombone_build
33
 BUILD_DIR=~/.tmp_freedombone_build
34
+VMDEBOOTSTRAP_REPO=git://git.liw.fi/vmdebootstrap
35
+VMDEBOOTSTRAP_VERSION=0.8
36
+MAKEFILE=freedombone-image-makefile
34
 
37
 
38
+USERNAME=$(echo $USER)
39
+PASSWORD='freedombone'
40
+
41
+# IP address of the router (gateway)
42
+ROUTER_IP_ADDRESS="192.168.1.254"
43
+
44
+# The fixed IP address of the Beaglebone Black (or other SBC) on your local network
45
+BOX_IP_ADDRESS="192.168.1.55"
46
+
47
+# DNS
48
+NAMESERVER1='213.73.91.35'
49
+NAMESERVER2='85.214.20.141'
50
+
51
+while [[ $# > 1 ]]
52
+do
53
+key="$1"
54
+
55
+case $key in
56
+    -h|--help)
57
+    show_help
58
+    ;;
59
+    -t|--target|--board)
60
+    shift
61
+    IMAGE_TYPE="$1"
62
+    ;;
63
+    -u|--user|--username)
64
+    shift
65
+    USERNAME="$1"
66
+    ;;
67
+    -p|--password)
68
+    shift
69
+    PASSWORD="$1"
70
+    ;;
71
+    # Box static IP address on the LAN
72
+    --ip)
73
+    shift
74
+    BOX_IP_ADDRESS="$1"
75
+    ;;
76
+    # Router IP address on the LAN
77
+    --iprouter)
78
+    shift
79
+    ROUTER_IP_ADDRESS="$1"
80
+    ;;
81
+    # nameserver 1
82
+    --ns1|--nameserver1)
83
+    shift
84
+    NAMESERVER1="$1"
85
+    ;;
86
+    # nameserver 2
87
+    --ns2|--nameserver2)
88
+    shift
89
+    NAMESERVER2="$1"
90
+    ;;
91
+    *)
92
+    # unknown option
93
+    ;;
94
+esac
95
+shift
96
+done
97
+
98
+
99
+
100
+rm $CURR_DIR/*.img.bz2
35
 rm $CURR_DIR/*.img
101
 rm $CURR_DIR/*.img
102
+rm $CURR_DIR/*.sig
36
 
103
 
37
 if [ -d $BUILD_DIR ]; then
104
 if [ -d $BUILD_DIR ]; then
38
-	rm -rf $BUILD_DIR
105
+    rm -rf $BUILD_DIR
39
 fi
106
 fi
40
 mkdir -p $BUILD_DIR
107
 mkdir -p $BUILD_DIR
41
-if [ -f /usr/local/bin/freedombone-image-makefile ]; then
42
-	cp /usr/local/bin/freedombone-image-makefile $BUILD_DIR/Makefile
108
+if [ -f /usr/local/bin/$MAKEFILE ]; then
109
+    cp /usr/local/bin/$MAKEFILE $BUILD_DIR/Makefile
43
 else
110
 else
44
-	cp /usr/bin/freedombone-image-makefile $BUILD_DIR/Makefile
111
+    cp /usr/bin/$MAKEFILE $BUILD_DIR/Makefile
45
 fi
112
 fi
46
 
113
 
47
 cp -r /etc/freedombone/* $BUILD_DIR
114
 cp -r /etc/freedombone/* $BUILD_DIR
52
 if [ -d vendor/vmdebootstrap ] ; then
119
 if [ -d vendor/vmdebootstrap ] ; then
53
     (cd vendor/vmdebootstrap; git checkout .; git pull)
120
     (cd vendor/vmdebootstrap; git checkout .; git pull)
54
 else
121
 else
55
-    git clone git://git.liw.fi/vmdebootstrap vendor/vmdebootstrap
122
+    git clone $VMDEBOOTSTRAP_REPO vendor/vmdebootstrap
56
 fi
123
 fi
57
 cd vendor/vmdebootstrap
124
 cd vendor/vmdebootstrap
58
-git checkout tags/vmdebootstrap-0.8
59
-git checkout -b tags/vmdebootstrap-0.8
125
+git checkout tags/vmdebootstrap-${VMDEBOOTSTRAP_VERSION}
126
+git checkout -b tags/vmdebootstrap-${VMDEBOOTSTRAP_VERSION}
60
 for f in ../../vendor-patches/vmdebootstrap/* ; do
127
 for f in ../../vendor-patches/vmdebootstrap/* ; do
61
     echo applying $(basename $f)
128
     echo applying $(basename $f)
62
     patch -p1 < $f
129
     patch -p1 < $f
63
 done
130
 done
64
 
131
 
65
 cd $BUILD_DIR
132
 cd $BUILD_DIR
66
-make $IMAGE_TYPE
133
+make $IMAGE_TYPE \
134
+    USERNAME="$USERNAME" \
135
+    PASSWORD="$PASSWORD" \
136
+    ROUTER_IP_ADDRESS="$ROUTER_IP_ADDRESS" \
137
+    BOX_IP_ADDRESS="$BOX_IP_ADDRESS" \
138
+    NAMESERVER1="$NAMESERVER1" \
139
+    NAMESERVER2="$NAMESERVER2"
140
+
67
 mv build/*.bz2 $CURR_DIR
141
 mv build/*.bz2 $CURR_DIR
68
 mv build/*.img $CURR_DIR
142
 mv build/*.img $CURR_DIR
69
 mv build/*.sig $CURR_DIR
143
 mv build/*.sig $CURR_DIR

+ 85
- 11
src/freedombone-image-customise View File

18
 set -e
18
 set -e
19
 set -x
19
 set -x
20
 
20
 
21
+# The number of arguments
22
+NO_OF_ARGS=$#
23
+
24
+MY_USERNAME=$USER
25
+MY_PASSWORD='freedombone'
26
+
27
+# IP address of the router (gateway)
28
+ROUTER_IP_ADDRESS="192.168.1.254"
29
+
30
+# The fixed IP address of the Beaglebone Black on your local network
31
+BOX_IP_ADDRESS="192.168.1.55"
32
+
33
+# DNS
34
+NAMESERVER1='213.73.91.35'
35
+NAMESERVER2='85.214.20.141'
36
+
21
 enable_eatmydata_override() {
37
 enable_eatmydata_override() {
22
     chroot $rootdir apt-get install --no-install-recommends -y eatmydata
38
     chroot $rootdir apt-get install --no-install-recommends -y eatmydata
23
     if [ -x $rootdir/usr/bin/eatmydata ] && \
39
     if [ -x $rootdir/usr/bin/eatmydata ] && \
78
 # are not created yet.
94
 # are not created yet.
79
 export TMP=/tmp/ TMPDIR=/tmp/
95
 export TMP=/tmp/ TMPDIR=/tmp/
80
 
96
 
81
-username=freedom
97
+username=$MY_USERNAME
82
 echo "warning: creating initial user $username with well known password!"
98
 echo "warning: creating initial user $username with well known password!"
83
-password=bone
99
+password=$MY_PASSWORD
84
 chroot $rootdir adduser --gecos $username --disabled-password $username
100
 chroot $rootdir adduser --gecos $username --disabled-password $username
85
 echo $username:$password | chroot $rootdir /usr/sbin/chpasswd
101
 echo $username:$password | chroot $rootdir /usr/sbin/chpasswd
86
 chroot $rootdir adduser $username sudo
102
 chroot $rootdir adduser $username sudo
112
     chroot "$rootdir" gdebi -n /tmp/"$(basename $CUSTOM_SETUP)"
128
     chroot "$rootdir" gdebi -n /tmp/"$(basename $CUSTOM_SETUP)"
113
 fi
129
 fi
114
 
130
 
115
-chroot "$rootdir" apt-get install -y git dialog
131
+chroot "$rootdir" apt-get install -y git dialog build-essential
116
 chroot "$rootdir" git clone https://github.com/bashrc/freedombone /root/freedombone
132
 chroot "$rootdir" git clone https://github.com/bashrc/freedombone /root/freedombone
117
 chroot "$rootdir" cd /root/freedombone && make install
133
 chroot "$rootdir" cd /root/freedombone && make install
118
 
134
 
127
 # Remove SSH keys from the image
143
 # Remove SSH keys from the image
128
 rm $rootdir/etc/ssh/ssh_host_* || true
144
 rm $rootdir/etc/ssh/ssh_host_* || true
129
 
145
 
146
+echo "# This file describes the network interfaces available on your system
147
+# and how to activate them. For more information, see interfaces(5).
148
+
149
+# The loopback network interface
150
+auto lo
151
+iface lo inet loopback
152
+
153
+# The primary network interface
154
+auto eth0
155
+iface eth0 inet static
156
+    address $BOX_IP_ADDRESS
157
+    netmask 255.255.255.0
158
+    gateway $ROUTER_IP_ADDRESS
159
+    dns-nameservers $NAMESERVER1 $NAMESERVER2
160
+# Example to keep MAC address between reboots
161
+#hwaddress ether B5:A2:BE:3F:1A:FE
162
+
163
+# The secondary network interface
164
+#auto eth1
165
+#iface eth1 inet dhcp
166
+
167
+# WiFi Example
168
+#auto wlan0
169
+#iface wlan0 inet dhcp
170
+#    wpa-ssid \"essid\"
171
+#    wpa-psk  \"password\"
172
+
173
+# Ethernet/RNDIS gadget (g_ether)
174
+# ... or on host side, usbnet and random hwaddr
175
+# Note on some boards, usb0 is automaticly setup with an init script
176
+#iface usb0 inet static
177
+#    address 192.168.7.2
178
+#    netmask 255.255.255.0
179
+#    network 192.168.7.0
180
+#    gateway 192.168.7.1" > $rootdir/etc/network/interfaces
181
+
182
+hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
183
+a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
184
+b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
185
+c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
186
+d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
187
+e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
188
+sed -i "s|#hwaddress ether.*|hwaddress ether de:$a:$b:$c:$d:$e|g" $rootdir/etc/network/interfaces
189
+
190
+sed -i "s/nameserver.*/nameserver $NAMESERVER1/g" $rootdir/etc/resolv.conf
191
+sed -i "/nameserver $NAMESERVER1/a\nameserver $NAMESERVER2" $rootdir/etc/resolv.conf
192
+
193
+# change the motd to show further install instructions
194
+echo "
195
+To complete the installation run the following:
196
+
197
+    su
198
+    freedombone menuconfig
199
+
200
+" > $rootdir/etc/init.d/motd
201
+
202
+
130
 # copy u-boot to beginning of image
203
 # copy u-boot to beginning of image
131
 case "$MACHINE" in
204
 case "$MACHINE" in
132
     beaglebone)
205
     beaglebone)
133
-    chroot $rootdir apt-get -y install rng-tools
134
-    sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' $rootdir/etc/default/rng-tools
135
-
136
-	dd if=$rootdir/usr/lib/u-boot/am335x_boneblack/MLO of="$image" \
137
-	   count=1 seek=1 conv=notrunc bs=128k
138
-	dd if=$rootdir/usr/lib/u-boot/am335x_boneblack/u-boot.img of="$image" \
139
-	   count=2 seek=1 conv=notrunc bs=384k
140
-	;;
206
+        chroot $rootdir apt-get -y install rng-tools
207
+        sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' $rootdir/etc/default/rng-tools
208
+
209
+        dd if=$rootdir/usr/lib/u-boot/am335x_boneblack/MLO of="$image" \
210
+           count=1 seek=1 conv=notrunc bs=128k
211
+        dd if=$rootdir/usr/lib/u-boot/am335x_boneblack/u-boot.img of="$image" \
212
+           count=2 seek=1 conv=notrunc bs=384k
213
+        ;;
141
     cubieboard2)
214
     cubieboard2)
215
+        chroot $rootdir apt-get -y install haveged
142
         dd if=$rootdir/usr/lib/u-boot/Cubieboard2/u-boot-sunxi-with-spl.bin of="$image" \
216
         dd if=$rootdir/usr/lib/u-boot/Cubieboard2/u-boot-sunxi-with-spl.bin of="$image" \
143
            seek=8 conv=notrunc bs=1k
217
            seek=8 conv=notrunc bs=1k
144
         ;;
218
         ;;

+ 20
- 1
src/freedombone-image-make View File

25
 export MACHINE
25
 export MACHINE
26
 export SOURCE
26
 export SOURCE
27
 export SUITE
27
 export SUITE
28
+export MY_USERNAME
29
+export MY_PASSWORD
30
+export ROUTER_IP_ADDRESS
31
+export BOX_IP_ADDRESS
32
+export NAMESERVER1
33
+export NAMESERVER2
28
 
34
 
29
 # Locate vmdebootstrap program fetched in Makefile
35
 # Locate vmdebootstrap program fetched in Makefile
30
 basedir=`pwd`
36
 basedir=`pwd`
103
     VMDEBOOTSTRAP=vmdebootstrap
109
     VMDEBOOTSTRAP=vmdebootstrap
104
 fi
110
 fi
105
 
111
 
112
+echo 'Making customised customisation script'
113
+TEMP_CUSTOMISE=/etc/freedombone/image-customise
114
+sudo cp /usr/local/bin/freedombone-image-customise $TEMP_CUSTOMISE
115
+sudo sed -i "s|MY_USERNAME=.*|MY_USERNAME=${MY_USERNAME}|g" $TEMP_CUSTOMISE
116
+sudo sed -i "s|MY_PASSWORD=.*|MY_PASSWORD=${MY_PASSWORD}|g" $TEMP_CUSTOMISE
117
+sudo sed -i "s|ROUTER_IP_ADDRESS=.*|ROUTER_IP_ADDRESS=${ROUTER_IP_ADDRESS}|g" $TEMP_CUSTOMISE
118
+sudo sed -i "s|BOX_IP_ADDRESS=.*|BOX_IP_ADDRESS=${BOX_IP_ADDRESS}|g" $TEMP_CUSTOMISE
119
+sudo sed -i "s|NAMESERVER1=.*|NAMESERVER1=${NAMESERVER1}|g" $TEMP_CUSTOMISE
120
+sudo sed -i "s|NAMESERVER2=.*|NAMESERVER2=${NAMESERVER1}|g" $TEMP_CUSTOMISE
121
+
106
 echo "starting $VMDEBOOTSTRAP"
122
 echo "starting $VMDEBOOTSTRAP"
107
 # Run vmdebootstrap script to create image
123
 # Run vmdebootstrap script to create image
108
 sudo -H \
124
 sudo -H \
121
     --hostname freedombone \
137
     --hostname freedombone \
122
     --verbose \
138
     --verbose \
123
     --mirror $BUILD_MIRROR \
139
     --mirror $BUILD_MIRROR \
124
-    --customize "freedombone-image-customise" \
140
+    --customize "$TEMP_CUSTOMISE" \
125
     --lock-root-password \
141
     --lock-root-password \
126
     --arch $ARCHITECTURE \
142
     --arch $ARCHITECTURE \
127
     --distribution $SUITE \
143
     --distribution $SUITE \
128
     $extra_opts \
144
     $extra_opts \
129
     $pkgopts
145
     $pkgopts
146
+
147
+echo 'Removing customised customisation script'
148
+sudo shred -zu $TEMP_CUSTOMISE

+ 20
- 1
src/freedombone-image-makefile View File

38
 TEST_SSH_PORT = 2222
38
 TEST_SSH_PORT = 2222
39
 TEST_FIRSTRUN_WAIT_TIME = 120 # seconds
39
 TEST_FIRSTRUN_WAIT_TIME = 120 # seconds
40
 
40
 
41
+USERNAME ?= $(echo $USER)
42
+PASSWORD ?= 'freedombone'
43
+
44
+# IP address of the router (gateway)
45
+ROUTER_IP_ADDRESS ?= "192.168.1.254"
46
+
47
+# The fixed IP address of the Beaglebone Black (or other SBC) on your local network
48
+BOX_IP_ADDRESS ?= "192.168.1.55"
49
+
50
+# DNS
51
+NAMESERVER1 ?= '213.73.91.35'
52
+NAMESERVER2 ?= '85.214.20.141'
53
+
41
 # Using taskset to pin build process to single core. This is a
54
 # Using taskset to pin build process to single core. This is a
42
 # workaround for a qemu-user-static issue that causes builds to
55
 # workaround for a qemu-user-static issue that causes builds to
43
 # hang. (See Debian bug #769983 for details.)
56
 # hang. (See Debian bug #769983 for details.)
44
 MAKE_IMAGE = ARCHITECTURE=$(ARCHITECTURE) MACHINE=$(MACHINE) SOURCE=$(SOURCE) \
57
 MAKE_IMAGE = ARCHITECTURE=$(ARCHITECTURE) MACHINE=$(MACHINE) SOURCE=$(SOURCE) \
45
     MIRROR=$(MIRROR) SUITE=$(SUITE) OWNER=$(OWNER) \
58
     MIRROR=$(MIRROR) SUITE=$(SUITE) OWNER=$(OWNER) \
46
     BUILD_MIRROR=$(BUILD_MIRROR) \
59
     BUILD_MIRROR=$(BUILD_MIRROR) \
47
-    CUSTOM_PLINTH=$(CUSTOM_PLINTH) CUSTOM_SETUP=$(CUSTOM_SETUP) \
60
+    MY_USERNAME=$(USERNAME) \
61
+    MY_PASSWORD=$(PASSWORD) \
62
+    ROUTER_IP_ADDRESS=$(ROUTER_IP_ADDRESS) \
63
+    BOX_IP_ADDRESS=$(BOX_IP_ADDRESS) \
64
+    NAMESERVER1=$(NAMESERVER1) \
65
+    NAMESERVER2=$(NAMESERVER2) \
66
+    CUSTOM_SETUP=$(CUSTOM_SETUP) \
48
     IMAGE_SIZE=$(IMAGE_SIZE) taskset 0x01 freedombone-image-make $(NAME)
67
     IMAGE_SIZE=$(IMAGE_SIZE) taskset 0x01 freedombone-image-make $(NAME)
49
 
68
 
50
 # build Beaglebone SD card image
69
 # build Beaglebone SD card image

+ 32
- 23
src/freedombone-prep View File

58
 DOWNLOAD_LINK1="https://rcn-ee.com/rootfs/bb.org/testing/2015-07-12/console/$DEBIAN_FILE_NAME.xz"
58
 DOWNLOAD_LINK1="https://rcn-ee.com/rootfs/bb.org/testing/2015-07-12/console/$DEBIAN_FILE_NAME.xz"
59
 
59
 
60
 ROOTFS='rootfs'
60
 ROOTFS='rootfs'
61
+ROOTFS_SUBDIR=''
61
 
62
 
62
 PARTITION_NUMBER=1
63
 PARTITION_NUMBER=1
63
 
64
 
65
+CURR_DIR=$(pwd)
66
+
64
 function show_help {
67
 function show_help {
65
     echo ''
68
     echo ''
66
     echo 'freedombone-prep -d [microSD device] --ip [BBB LAN IP address] --iprouter [Router LAN IP address] --mount [mount directory]'
69
     echo 'freedombone-prep -d [microSD device] --ip [BBB LAN IP address] --iprouter [Router LAN IP address] --mount [mount directory]'
83
     fi
86
     fi
84
     if [ -d /media/usb1/@ ]; then
87
     if [ -d /media/usb1/@ ]; then
85
         MICROSD_MOUNT_POINT=/media
88
         MICROSD_MOUNT_POINT=/media
86
-        ROOTFS='usb1/@'
89
+        ROOTFS=usb1
90
+		ROOTFS_SUBDIR='/@'
87
     fi
91
     fi
88
     if [ -d /media/usb0 ]; then
92
     if [ -d /media/usb0 ]; then
89
         MICROSD_MOUNT_POINT=/media
93
         MICROSD_MOUNT_POINT=/media
114
     -i|--image)
118
     -i|--image)
115
     shift
119
     shift
116
     DEBIAN_IMAGE_FILENAME="$1"
120
     DEBIAN_IMAGE_FILENAME="$1"
117
-    ROOTFS='usb1/@'
121
+    ROOTFS_SUBDIR='/@'
118
     ;;
122
     ;;
119
     # BBB static IP address on the LAN
123
     # BBB static IP address on the LAN
120
     --ip)
124
     --ip)
177
 if [ -f /usr/bin/sudo ]; then
181
 if [ -f /usr/bin/sudo ]; then
178
     SUDO='sudo'
182
     SUDO='sudo'
179
 fi
183
 fi
180
-$SUDO apt-get install p7zip dd wget
184
+$SUDO apt-get install p7zip wget
181
 
185
 
182
 if [ ! -d ~/freedombone ]; then
186
 if [ ! -d ~/freedombone ]; then
183
     mkdir ~/freedombone
187
     mkdir ~/freedombone
198
         exit 62394
202
         exit 62394
199
     fi
203
     fi
200
     DEBIAN_FILE_NAME=$DEBIAN_IMAGE_FILENAME
204
     DEBIAN_FILE_NAME=$DEBIAN_IMAGE_FILENAME
205
+    if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME ]; then
206
+		cd $CURR_DIR
207
+        cp $DEBIAN_FILE_NAME ~/freedombone/$DEBIAN_FILE_NAME
208
+		cd ~/freedombone
209
+    fi
201
 else
210
 else
202
     # default debian image downloaded from elsewhere
211
     # default debian image downloaded from elsewhere
203
     if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.xz ]; then
212
     if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.xz ]; then
215
 
224
 
216
 cd ~/freedombone
225
 cd ~/freedombone
217
 echo 'Flashing image. This may take a while.'
226
 echo 'Flashing image. This may take a while.'
218
-$SUDO dd if=$DEBIAN_FILE_NAME of=$MICROSD_DRIVE
227
+#$SUDO dd if=$DEBIAN_FILE_NAME of=$MICROSD_DRIVE
219
 sync
228
 sync
220
 
229
 
221
 sleep 5
230
 sleep 5
244
     exit 65688
253
     exit 65688
245
 fi
254
 fi
246
 
255
 
247
-if [ ! -d $MICROSD_MOUNT_POINT/$ROOTFS/home ]; then
256
+if [ ! -d $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/home ]; then
248
     echo ''
257
     echo ''
249
     echo "The rootfs partition was not written correctly."
258
     echo "The rootfs partition was not written correctly."
250
-    ls $MICROSD_MOUNT_POINT/$ROOTFS
259
+    ls $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR
251
     exit 65688
260
     exit 65688
252
 fi
261
 fi
253
 
262
 
254
-$SUDO sed -i 's/iface eth0 inet dhcp/iface eth0 inet static/g' $MICROSD_MOUNT_POINT/$ROOTFS/etc/network/interfaces
255
-$SUDO sed -i "/iface eth0 inet static/a\    dns-nameservers $NAMESERVER1 $NAMESERVER2" $MICROSD_MOUNT_POINT/$ROOTFS/etc/network/interfaces
256
-$SUDO sed -i "/iface eth0 inet static/a\    gateway $ROUTER_IP_ADDRESS" $MICROSD_MOUNT_POINT/$ROOTFS/etc/network/interfaces
257
-$SUDO sed -i '/iface eth0 inet static/a\    netmask 255.255.255.0' $MICROSD_MOUNT_POINT/$ROOTFS/etc/network/interfaces
258
-$SUDO sed -i "/iface eth0 inet static/a\    address $BBB_FIXED_IP_ADDRESS" $MICROSD_MOUNT_POINT/$ROOTFS/etc/network/interfaces
259
-$SUDO sed -i '/iface usb0 inet static/,/    gateway 192.168.7.1/ s/^/#/' $MICROSD_MOUNT_POINT/$ROOTFS/etc/network/interfaces
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
260
 
269
 
261
 hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
270
 hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
262
 a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
271
 a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
264
 c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
273
 c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
265
 d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
274
 d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
266
 e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
275
 e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
267
-$SUDO sed -i "s|#hwaddress ether.*|hwaddress ether de:$a:$b:$c:$d:$e|g" $MICROSD_MOUNT_POINT/$ROOTFS/etc/network/interfaces
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
268
 
277
 
269
-$SUDO sed -i "s/nameserver.*/nameserver $NAMESERVER1/g" $MICROSD_MOUNT_POINT/$ROOTFS/etc/resolv.conf
270
-$SUDO sed -i "/nameserver $NAMESERVER1/a\nameserver $NAMESERVER2" $MICROSD_MOUNT_POINT/$ROOTFS/etc/resolv.conf
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
271
 
280
 
272
 # copy the commands to the card
281
 # copy the commands to the card
273
-$SUDO cp -f $(which freedombone)* $MICROSD_MOUNT_POINT/$ROOTFS/usr/local/bin/
274
-$SUDO cp -f $(which zeronetavahi)* $MICROSD_MOUNT_POINT/$ROOTFS/usr/local/bin/
275
-$SUDO cp -f $MICROSD_MOUNT_POINT/$ROOTFS/usr/local/bin/freedombone-mesh $MICROSD_MOUNT_POINT/$ROOTFS/usr/local/bin/mesh
276
-$SUDO cp -f $MICROSD_MOUNT_POINT/$ROOTFS/usr/local/bin/freedombone-meshweb $MICROSD_MOUNT_POINT/$ROOTFS/usr/local/bin/meshweb
277
-if [ ! -f $MICROSD_MOUNT_POINT/$ROOTFS/usr/local/bin/freedombone ]; then
282
+$SUDO cp -f $(which freedombone)* $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/
283
+$SUDO cp -f $(which zeronetavahi)* $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/
284
+$SUDO cp -f $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/freedombone-mesh $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/mesh
285
+$SUDO cp -f $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/freedombone-meshweb $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/meshweb
286
+if [ ! -f $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/usr/local/bin/freedombone ]; then
278
     echo 'There was a problem with writing freedombone commands to the SD card'
287
     echo 'There was a problem with writing freedombone commands to the SD card'
279
     exit 8736
288
     exit 8736
280
 fi
289
 fi
281
 
290
 
282
 # remove automatic motd creator if it exists
291
 # remove automatic motd creator if it exists
283
-if [ -f $MICROSD_MOUNT_POINT/$ROOTFS/etc/init.d/motd ]; then
284
-    $SUDO rm -f $MICROSD_MOUNT_POINT/$ROOTFS/etc/init.d/motd
292
+if [ -f $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/init.d/motd ]; then
293
+    $SUDO rm -f $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/init.d/motd
285
 fi
294
 fi
286
 
295
 
287
 # change the motd to show further install instructions
296
 # change the motd to show further install instructions
303
 echo '    apt-get -y install git dialog build-essential' >> /tmp/freedombone_motd
312
 echo '    apt-get -y install git dialog build-essential' >> /tmp/freedombone_motd
304
 echo '    freedombone menuconfig' >> /tmp/freedombone_motd
313
 echo '    freedombone menuconfig' >> /tmp/freedombone_motd
305
 
314
 
306
-$SUDO cp -f /tmp/freedombone_motd $MICROSD_MOUNT_POINT/$ROOTFS/etc/motd
315
+$SUDO cp -f /tmp/freedombone_motd $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR/etc/motd
307
 
316
 
308
 clear
317
 clear
309
 echo '*** Initial microSD card setup is complete ***'
318
 echo '*** Initial microSD card setup is complete ***'