Przeglądaj źródła

Prep can use a given disk image

Bob Mottram 9 lat temu
rodzic
commit
a6ed6c0a12
1 zmienionych plików z 33 dodań i 10 usunięć
  1. 33
    10
      src/freedombone-prep

+ 33
- 10
src/freedombone-prep Wyświetl plik

51
 
51
 
52
 MICROSD_MOUNT_POINT="/media/$USER"
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
 # Downloads for the Debian installer
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
 ROOTFS='rootfs'
60
 ROOTFS='rootfs'
60
 
61
 
106
     MICROSD_DRIVE="$1"
107
     MICROSD_DRIVE="$1"
107
     ;;
108
     ;;
108
     # BBB static IP address on the LAN
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
     --ip)
115
     --ip)
110
     shift
116
     shift
111
     BBB_FIXED_IP_ADDRESS="$1"
117
     BBB_FIXED_IP_ADDRESS="$1"
172
     mkdir ~/freedombone
178
     mkdir ~/freedombone
173
 fi
179
 fi
174
 cd ~/freedombone
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
     fi
202
     fi
203
+    xz -d $DEBIAN_FILE_NAME.xz
179
 fi
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
     exit 4
208
     exit 4
186
 fi
209
 fi
187
 
210
 
188
 cd ~/freedombone
211
 cd ~/freedombone
189
 echo 'Flashing image. This may take a while.'
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
 sync
214
 sync
192
 
215
 
193
 sleep 5
216
 sleep 5