소스 검색

Improve the image command

Bob Mottram 9 년 전
부모
커밋
4fccf12c69
6개의 변경된 파일240개의 추가작업 그리고 45개의 파일을 삭제
  1. BIN
      man/freedombone-image.1.gz
  2. 83
    9
      src/freedombone-image
  3. 85
    11
      src/freedombone-image-customise
  4. 20
    1
      src/freedombone-image-make
  5. 20
    1
      src/freedombone-image-makefile
  6. 32
    23
      src/freedombone-prep

BIN
man/freedombone-image.1.gz 파일 보기


+ 83
- 9
src/freedombone-image 파일 보기

@@ -28,20 +28,87 @@
28 28
 # You should have received a copy of the GNU General Public License
29 29
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
30 30
 
31
-IMAGE_TYPE=$1
31
+IMAGE_TYPE='beaglebone'
32 32
 CURR_DIR=$(pwd)
33 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 101
 rm $CURR_DIR/*.img
102
+rm $CURR_DIR/*.sig
36 103
 
37 104
 if [ -d $BUILD_DIR ]; then
38
-	rm -rf $BUILD_DIR
105
+    rm -rf $BUILD_DIR
39 106
 fi
40 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 110
 else
44
-	cp /usr/bin/freedombone-image-makefile $BUILD_DIR/Makefile
111
+    cp /usr/bin/$MAKEFILE $BUILD_DIR/Makefile
45 112
 fi
46 113
 
47 114
 cp -r /etc/freedombone/* $BUILD_DIR
@@ -52,18 +119,25 @@ mkdir vendor
52 119
 if [ -d vendor/vmdebootstrap ] ; then
53 120
     (cd vendor/vmdebootstrap; git checkout .; git pull)
54 121
 else
55
-    git clone git://git.liw.fi/vmdebootstrap vendor/vmdebootstrap
122
+    git clone $VMDEBOOTSTRAP_REPO vendor/vmdebootstrap
56 123
 fi
57 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 127
 for f in ../../vendor-patches/vmdebootstrap/* ; do
61 128
     echo applying $(basename $f)
62 129
     patch -p1 < $f
63 130
 done
64 131
 
65 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 141
 mv build/*.bz2 $CURR_DIR
68 142
 mv build/*.img $CURR_DIR
69 143
 mv build/*.sig $CURR_DIR

+ 85
- 11
src/freedombone-image-customise 파일 보기

@@ -18,6 +18,22 @@
18 18
 set -e
19 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 37
 enable_eatmydata_override() {
22 38
     chroot $rootdir apt-get install --no-install-recommends -y eatmydata
23 39
     if [ -x $rootdir/usr/bin/eatmydata ] && \
@@ -78,9 +94,9 @@ export LC_ALL=C LANGUAGE=C LANG=C
78 94
 # are not created yet.
79 95
 export TMP=/tmp/ TMPDIR=/tmp/
80 96
 
81
-username=freedom
97
+username=$MY_USERNAME
82 98
 echo "warning: creating initial user $username with well known password!"
83
-password=bone
99
+password=$MY_PASSWORD
84 100
 chroot $rootdir adduser --gecos $username --disabled-password $username
85 101
 echo $username:$password | chroot $rootdir /usr/sbin/chpasswd
86 102
 chroot $rootdir adduser $username sudo
@@ -112,7 +128,7 @@ if [ -n "$CUSTOM_SETUP" ]; then
112 128
     chroot "$rootdir" gdebi -n /tmp/"$(basename $CUSTOM_SETUP)"
113 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 132
 chroot "$rootdir" git clone https://github.com/bashrc/freedombone /root/freedombone
117 133
 chroot "$rootdir" cd /root/freedombone && make install
118 134
 
@@ -127,18 +143,76 @@ chroot $rootdir /usr/lib/freedombone/setup 2>&1 | \
127 143
 # Remove SSH keys from the image
128 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 203
 # copy u-boot to beginning of image
131 204
 case "$MACHINE" in
132 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 214
     cubieboard2)
215
+        chroot $rootdir apt-get -y install haveged
142 216
         dd if=$rootdir/usr/lib/u-boot/Cubieboard2/u-boot-sunxi-with-spl.bin of="$image" \
143 217
            seek=8 conv=notrunc bs=1k
144 218
         ;;

+ 20
- 1
src/freedombone-image-make 파일 보기

@@ -25,6 +25,12 @@ export ARCHITECTURE
25 25
 export MACHINE
26 26
 export SOURCE
27 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 35
 # Locate vmdebootstrap program fetched in Makefile
30 36
 basedir=`pwd`
@@ -103,6 +109,16 @@ else
103 109
     VMDEBOOTSTRAP=vmdebootstrap
104 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 122
 echo "starting $VMDEBOOTSTRAP"
107 123
 # Run vmdebootstrap script to create image
108 124
 sudo -H \
@@ -121,9 +137,12 @@ sudo -H \
121 137
     --hostname freedombone \
122 138
     --verbose \
123 139
     --mirror $BUILD_MIRROR \
124
-    --customize "freedombone-image-customise" \
140
+    --customize "$TEMP_CUSTOMISE" \
125 141
     --lock-root-password \
126 142
     --arch $ARCHITECTURE \
127 143
     --distribution $SUITE \
128 144
     $extra_opts \
129 145
     $pkgopts
146
+
147
+echo 'Removing customised customisation script'
148
+sudo shred -zu $TEMP_CUSTOMISE

+ 20
- 1
src/freedombone-image-makefile 파일 보기

@@ -38,13 +38,32 @@ SIGN = -gpg --output $(SIGNATURE) --detach-sig $(ARCHIVE)
38 38
 TEST_SSH_PORT = 2222
39 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 54
 # Using taskset to pin build process to single core. This is a
42 55
 # workaround for a qemu-user-static issue that causes builds to
43 56
 # hang. (See Debian bug #769983 for details.)
44 57
 MAKE_IMAGE = ARCHITECTURE=$(ARCHITECTURE) MACHINE=$(MACHINE) SOURCE=$(SOURCE) \
45 58
     MIRROR=$(MIRROR) SUITE=$(SUITE) OWNER=$(OWNER) \
46 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 67
     IMAGE_SIZE=$(IMAGE_SIZE) taskset 0x01 freedombone-image-make $(NAME)
49 68
 
50 69
 # build Beaglebone SD card image

+ 32
- 23
src/freedombone-prep 파일 보기

@@ -58,9 +58,12 @@ DEBIAN_FILE_NAME="bone-debian-8.1-console-armhf-2015-07-12-2gb.img"
58 58
 DOWNLOAD_LINK1="https://rcn-ee.com/rootfs/bb.org/testing/2015-07-12/console/$DEBIAN_FILE_NAME.xz"
59 59
 
60 60
 ROOTFS='rootfs'
61
+ROOTFS_SUBDIR=''
61 62
 
62 63
 PARTITION_NUMBER=1
63 64
 
65
+CURR_DIR=$(pwd)
66
+
64 67
 function show_help {
65 68
     echo ''
66 69
     echo 'freedombone-prep -d [microSD device] --ip [BBB LAN IP address] --iprouter [Router LAN IP address] --mount [mount directory]'
@@ -83,7 +86,8 @@ if [ -d /media ]; then
83 86
     fi
84 87
     if [ -d /media/usb1/@ ]; then
85 88
         MICROSD_MOUNT_POINT=/media
86
-        ROOTFS='usb1/@'
89
+        ROOTFS=usb1
90
+		ROOTFS_SUBDIR='/@'
87 91
     fi
88 92
     if [ -d /media/usb0 ]; then
89 93
         MICROSD_MOUNT_POINT=/media
@@ -114,7 +118,7 @@ case $key in
114 118
     -i|--image)
115 119
     shift
116 120
     DEBIAN_IMAGE_FILENAME="$1"
117
-    ROOTFS='usb1/@'
121
+    ROOTFS_SUBDIR='/@'
118 122
     ;;
119 123
     # BBB static IP address on the LAN
120 124
     --ip)
@@ -177,7 +181,7 @@ SUDO=
177 181
 if [ -f /usr/bin/sudo ]; then
178 182
     SUDO='sudo'
179 183
 fi
180
-$SUDO apt-get install p7zip dd wget
184
+$SUDO apt-get install p7zip wget
181 185
 
182 186
 if [ ! -d ~/freedombone ]; then
183 187
     mkdir ~/freedombone
@@ -198,6 +202,11 @@ if [ $DEBIAN_IMAGE_FILENAME ]; then
198 202
         exit 62394
199 203
     fi
200 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 210
 else
202 211
     # default debian image downloaded from elsewhere
203 212
     if [ ! -f ~/freedombone/$DEBIAN_FILE_NAME.xz ]; then
@@ -215,7 +224,7 @@ fi
215 224
 
216 225
 cd ~/freedombone
217 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 228
 sync
220 229
 
221 230
 sleep 5
@@ -244,19 +253,19 @@ if [ ! -d $MICROSD_MOUNT_POINT/$ROOTFS ]; then
244 253
     exit 65688
245 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 257
     echo ''
249 258
     echo "The rootfs partition was not written correctly."
250
-    ls $MICROSD_MOUNT_POINT/$ROOTFS
259
+    ls $MICROSD_MOUNT_POINT/$ROOTFS$ROOTFS_SUBDIR
251 260
     exit 65688
252 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 270
 hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
262 271
 a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
@@ -264,24 +273,24 @@ b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
264 273
 c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
265 274
 d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
266 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 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 287
     echo 'There was a problem with writing freedombone commands to the SD card'
279 288
     exit 8736
280 289
 fi
281 290
 
282 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 294
 fi
286 295
 
287 296
 # change the motd to show further install instructions
@@ -303,7 +312,7 @@ echo '    apt-get update' >> /tmp/freedombone_motd
303 312
 echo '    apt-get -y install git dialog build-essential' >> /tmp/freedombone_motd
304 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 317
 clear
309 318
 echo '*** Initial microSD card setup is complete ***'