Bob Mottram 9 anni fa
parent
commit
6a2019dfc9
1 ha cambiato i file con 73 aggiunte e 66 eliminazioni
  1. 73
    66
      src/freedombone-image-customise

+ 73
- 66
src/freedombone-image-customise Vedi File

@@ -90,6 +90,77 @@ deb-src $NEW_MIRROR $SUITE $COMPONENTS
90 90
 EOF
91 91
 }
92 92
 
93
+configure_networking {
94
+    echo "# This file describes the network interfaces available on your system
95
+# and how to activate them. For more information, see interfaces(5).
96
+
97
+# The loopback network interface
98
+auto lo
99
+iface lo inet loopback
100
+
101
+# The primary network interface
102
+auto eth0
103
+iface eth0 inet static
104
+    address $BOX_IP_ADDRESS
105
+    netmask 255.255.255.0
106
+    gateway $ROUTER_IP_ADDRESS
107
+    dns-nameservers $NAMESERVER1 $NAMESERVER2
108
+# Example to keep MAC address between reboots
109
+#hwaddress ether B5:A2:BE:3F:1A:FE
110
+
111
+# The secondary network interface
112
+#auto eth1
113
+#iface eth1 inet dhcp
114
+
115
+# WiFi Example
116
+#auto wlan0
117
+#iface wlan0 inet dhcp
118
+#    wpa-ssid \"essid\"
119
+#    wpa-psk  \"password\"
120
+
121
+# Ethernet/RNDIS gadget (g_ether)
122
+# ... or on host side, usbnet and random hwaddr
123
+# Note on some boards, usb0 is automaticly setup with an init script
124
+#iface usb0 inet static
125
+#    address 192.168.7.2
126
+#    netmask 255.255.255.0
127
+#    network 192.168.7.0
128
+#    gateway 192.168.7.1" > $rootdir/etc/network/interfaces
129
+
130
+    hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
131
+    a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
132
+    b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
133
+    c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
134
+    d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
135
+    e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
136
+    sed -i "s|#hwaddress ether.*|hwaddress ether de:$a:$b:$c:$d:$e|g" \
137
+        $rootdir/etc/network/interfaces
138
+
139
+    sed -i "s/nameserver.*/nameserver $NAMESERVER1/g" $rootdir/etc/resolv.conf
140
+    sed -i "/nameserver $NAMESERVER1/a\nameserver $NAMESERVER2" $rootdir/etc/resolv.conf
141
+
142
+    # change the motd to show further install instructions
143
+    echo '
144
+To complete the installation run the following:
145
+
146
+    sudo su
147
+    freedombone menuconfig
148
+
149
+' > $rootdir/etc/init.d/motd
150
+}
151
+
152
+continue_installation {
153
+    # If a configuration file exists then run with it
154
+    # otherwise the interactive installer can be used
155
+    # This is equivalent to installing freedombox-setup on freedombox
156
+    if [ $CONFIG_FILENAME ]; then
157
+        if [ ${#CONFIG_FILENAME} -gt 2 ]; then
158
+            cp $CONFIG_FILENAME $rootdir/root/$PROJECT_NAME.cfg
159
+            chroot $rootdir $PROJECT_NAME -c /root/$PROJECT_NAME.cfg
160
+        fi
161
+    fi
162
+}
163
+
93 164
 # Set to true/false to control if eatmydata is used during build
94 165
 use_eatmydata=true
95 166
 
@@ -156,63 +227,6 @@ chroot $rootdir /usr/lib/freedombone/setup 2>&1 | \
156 227
 # Remove SSH keys from the image
157 228
 rm $rootdir/etc/ssh/ssh_host_* || true
158 229
 
159
-echo "# This file describes the network interfaces available on your system
160
-# and how to activate them. For more information, see interfaces(5).
161
-
162
-# The loopback network interface
163
-auto lo
164
-iface lo inet loopback
165
-
166
-# The primary network interface
167
-auto eth0
168
-iface eth0 inet static
169
-    address $BOX_IP_ADDRESS
170
-    netmask 255.255.255.0
171
-    gateway $ROUTER_IP_ADDRESS
172
-    dns-nameservers $NAMESERVER1 $NAMESERVER2
173
-# Example to keep MAC address between reboots
174
-#hwaddress ether B5:A2:BE:3F:1A:FE
175
-
176
-# The secondary network interface
177
-#auto eth1
178
-#iface eth1 inet dhcp
179
-
180
-# WiFi Example
181
-#auto wlan0
182
-#iface wlan0 inet dhcp
183
-#    wpa-ssid \"essid\"
184
-#    wpa-psk  \"password\"
185
-
186
-# Ethernet/RNDIS gadget (g_ether)
187
-# ... or on host side, usbnet and random hwaddr
188
-# Note on some boards, usb0 is automaticly setup with an init script
189
-#iface usb0 inet static
190
-#    address 192.168.7.2
191
-#    netmask 255.255.255.0
192
-#    network 192.168.7.0
193
-#    gateway 192.168.7.1" > $rootdir/etc/network/interfaces
194
-
195
-hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
196
-a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
197
-b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
198
-c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
199
-d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
200
-e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
201
-sed -i "s|#hwaddress ether.*|hwaddress ether de:$a:$b:$c:$d:$e|g" $rootdir/etc/network/interfaces
202
-
203
-sed -i "s/nameserver.*/nameserver $NAMESERVER1/g" $rootdir/etc/resolv.conf
204
-sed -i "/nameserver $NAMESERVER1/a\nameserver $NAMESERVER2" $rootdir/etc/resolv.conf
205
-
206
-# change the motd to show further install instructions
207
-echo "
208
-To complete the installation run the following:
209
-
210
-    sudo su
211
-    freedombone menuconfig
212
-
213
-" > $rootdir/etc/init.d/motd
214
-
215
-
216 230
 # copy u-boot to beginning of image
217 231
 case "$MACHINE" in
218 232
     beaglebone)
@@ -238,15 +252,8 @@ fi
238 252
 set_apt_sources $MIRROR
239 253
 chroot $rootdir apt-get update
240 254
 
241
-# If a configuration file exists then run with it
242
-# otherwise the interactive installer can be used
243
-# This is equivalent to installing freedombox-setup on freedombox
244
-if [ $CONFIG_FILENAME ]; then
245
-    if [ ${#CONFIG_FILENAME} -gt 2 ]; then
246
-        cp $CONFIG_FILENAME $rootdir/root/$PROJECT_NAME.cfg
247
-        chroot $rootdir $PROJECT_NAME -c /root/$PROJECT_NAME.cfg
248
-    fi
249
-fi
255
+configure_networking
256
+continue_installation
250 257
 
251 258
 cd /
252 259
 echo "info: killing leftover processes in chroot"