-
Notifications
You must be signed in to change notification settings - Fork 2
/
image-creator.sh
executable file
·687 lines (651 loc) · 16.8 KB
/
image-creator.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
$DIALOG1 \
--title "Error:" --msgbox "\nYou must be root to do this" 7 32
#echo "You must be root to do this."
1>&2
exit 100
fi
set -ex
# load env variables.
# shellcheck source=./image-creator.conf
source "$(pwd)/image-creator.conf"
ensure_cleanup() {
set +e
umount arch-root/proc
umount arch-root/sys
umount arch-root/dev/pts
umount arch-root/dev
umount arch-root
losetup -d /dev/loop0
set -e
}
ensure_cleanup
modify_chroot() {
#add bootstrapping packages
if [ -d "$_packagedir" ]; then
cd $_packagedir
toinstall=$(ls *.pkg.tar.*)
cd ..
for i in $toinstall; do
cp $_packagedir/$i arch-root/root/$i
done
cp pacman.conf arch-root/etc/pacman.conf
cp /usr/bin/qemu-arm-static arch-root/usr/bin
# arch-chroot arch-root pacman -U /root/*.pkg.tar.xz --noconfirm
#manually chroot to support image creation on other distros
mount -t proc /proc arch-root/proc
mount -o bind /dev arch-root/dev
mount -o bind /dev/pts arch-root/dev/pts
mount -o bind /sys arch-root/sys
chroot arch-root /bin/bash -c "pacman -U /root/*.pkg.tar.* --noconfirm"
rm arch-root/usr/bin/qemu-arm-static
umount arch-root/proc
umount arch-root/sys
umount arch-root/dev/pts
umount arch-root/dev
fi
}
create_rpi_img(){
#rpi2
#IMG=rpi2-archlinux-armv7-$(date +%Y%m%d)
#URL=$BASEURL/ArchLinuxARM-rpi-2-latest.tar.gz
#RPIMG=ArchLinuxARM-rpi-2-latest.tar.gz
#rpi3
#IMG=rpi3-archlinux-armv7-$(date +%Y%m%d)
#URL=$BASEURL/ArchLinuxARM-rpi-3-latest.tar.gz
#RPIMG=ArchLinuxARM-rpi-3-latest.tar.gz
#rpi4
#IMG=rpi4-archlinux-armv8-$(date +%Y%m%d)
#URL=$BASEURL/ArchLinuxARM-rpi-4-latest.tar.gz
#RPIMG=ArchLinuxARM-rpi-4-latest.tar.gz
#check for an image alerady created
IMGPATH=$SRCDIR/$IMG
ROOTFSGZPATH=$SRCDIR/$RPIMG
if [ ! -f $IMGPATH ]; then
set -ex
losetup /dev/loop0 && exit 1 || true
if [ ! -f "$ROOTFSGZPATH" ]; then
wget -P $SRCDIR -N $URL
fi
truncate -s 2G $IMGPATH
losetup /dev/loop0 $IMGPATH
parted -s /dev/loop0 mklabel msdos
parted -s /dev/loop0 unit MiB mkpart primary fat32 -- 1 128
parted -s /dev/loop0 set 1 boot on
parted -s /dev/loop0 unit MiB mkpart primary ext2 -- 128 -1
parted -s /dev/loop0 print
mkfs.vfat -n SYSTEM /dev/loop0p1
mkfs.ext4 -L root -b 4096 -E stride=4,stripe_width=1024 /dev/loop0p2
mkdir -p arch-boot
mount /dev/loop0p1 arch-boot
mkdir -p arch-root
mount /dev/loop0p2 arch-root
bsdtar -xpf $ROOTFSGZPATH -C arch-root
sed -i "s/ defaults / defaults,noatime /" arch-root/etc/fstab
mv arch-root/boot/* arch-boot/
modify_chroot
umount arch-boot arch-root
losetup -d /dev/loop0
fi
if [ -f $IMGPATH ]; then
img_created
fi
}
create_orpi_prime_img() {
IMG=orangepiprime-archlinux-aarch64-$(date +%Y%m%d).img
if [ ! -f $IMG ]; then
set -ex
if [ ! -f $SRCDIR/ArchLinuxARM-aarch64-latest.tar.gz ]; then
wget -P $SRCDIR -N $BASEURL/ArchLinuxARM-aarch64-latest.tar.gz
fi
if [ ! -f $SRCDIR/ArchPrimeH5.img.tar.xz ]; then
wget -P $SRCDIR -N https://github.com/0pcom/skyalarm-old/releases/download/ArchPrimeH5/ArchPrimeH5.img.tar.xz
fi
bsdtar -xpf $SRCDIR/ArchPrimeH5.img.tar.xz -C $SRCDIR
gnome-disk-image-mounter -w $SRCDIR/ArchPrimeH5.img
mkdir -p arch-root
mount /dev/loop0p2 arch-root
#cd arch-root
rm -rf arch-root/bin arch-root/dev arch-root/home arch-root/mnt arch-root/proc arch-root/run arch-root/srv arch-root/tmp arch-root/var arch-root/etc arch-root/lib arch-root/opt arch-root/root arch-root/sbin arch-root/sys arch-root/usr
#cd $WORKINGDIR
bsdtar -xpf $SRCDIR/ArchLinuxARM-aarch64-latest.tar.gz -C arch-root --exclude 'boot'
modify_chroot
umount arch-root
losetup -d /dev/loop0
mv $SRCDIR/ArchPrimeH5.img $OUTDIR/$IMG
fi
if [ -f $IMG ]; then
img_created
fi
}
create_orpi_zero_img() {
#https://github.com/0pcom/skyalarm-old/releases/download/ArchZeroH2/ArchLinuxARM-OrangePiZero-latest.img.tar.xz
IMG=orangepizero-archlinux-armv7-$(date +%Y%m%d).img
if [ ! -f "$SRCDIR/$IMG" ]; then
set -ex
if [ ! -f "$SRCDIR/ArchLinuxARM-armv7-latest.tar.gz" ]; then
wget -P $SRCDIR -N $BASEURL/ArchLinuxARM-armv7-latest.tar.gz
fi
if [ ! -f "$SRCDIR/ArchLinuxARM-OrangePiZero-latest.img.tar.xz" ]; then
wget -P $SRCDIR -N https://github.com/0pcom/skyalarm-old/releases/download/ArchZeroH2/ArchLinuxARM-OrangePiZero-latest.img.tar.xz
fi
bsdtar -xpf $SRCDIR/ArchLinuxARM-OrangePiZero-latest.img.tar.xz -C $SRCDIR
gnome-disk-image-mounter -w $SRCDIR/ArchLinuxARM-OrangePiZero-latest.img
mkdir -p arch-root
mount /dev/loop0p1 arch-root
rm -rf arch-root/bin arch-root/dev arch-root/home arch-root/mnt arch-root/proc arch-root/run arch-root/srv arch-root/tmp arch-root/var arch-root/etc arch-root/lib arch-root/opt arch-root/root arch-root/sbin arch-root/sys arch-root/usr
bsdtar -xpf $SRCDIR/ArchLinuxARM-armv7-latest.tar.gz -C arch-root --exclude 'boot'
modify_chroot
umount arch-root
losetup -d /dev/loop0
mv $SRCDIR/ArchLinuxARM-OrangePiZero-latest.img $IMG
fi
if [ -f $IMG ]; then
img_created
fi
}
create_pine64_img(){
IMG=pine64-archlinux-aarch64-$(date +%Y%m%d).img
FULLIMGNAME=$PLATFORM-$AARCH64
URL1=$BASEURL1$BOOTSCR
URL2=$BASEURL1$UBOOT
if [ ! -f $IMG ]; then
set -ex
losetup /dev/loop0 && exit 1 || true
if [ ! -f "$SRCDIR/ArchLinuxARM-aarch64-latest.tar.gz" ]; then
wget -P $SRCDIR -N $BASEURL/ArchLinuxARM-aarch64-latest.tar.gz
fi
truncate -s 2G $IMG
losetup /dev/loop0 $IMG
parted -s /dev/loop0 mklabel msdos
parted -s /dev/loop0 unit MiB mkpart primary fat32 -- 1 64
parted -s /dev/loop0 set 1 boot on
parted -s /dev/loop0 unit MiB mkpart primary ext2 -- 64 -1
parted -s /dev/loop0 print
mkfs.vfat -n SYSTEM /dev/loop0p1
mkfs.ext4 -L root -b 4096 -E stride=4,stripe_width=1024 /dev/loop0p2
#mkdir -p arch-boot
#mount /dev/loop0p1 arch-boot
mkdir -p $SRCDIR/pine64boot
if [ ! -f "$SRCDIR/pine64boot/boot.scr" ]; then
wget -P $SRCDIR/pine64boot/ -N ${BASEURL}/allwinner/boot/pine64/boot.scr
fi
dd if=pine64boot/boot.scr of=/dev/loop0 bs=8k seek=1
mkdir -p arch-root
mount /dev/loop0p2 arch-root
bsdtar -xpf $SRCDIR/ArchLinuxARM-aarch64-latest.tar.gz -C arch-root
#sed -i "s/ defaults / defaults,noatime /" arch-root/etc/fstab
#mv arch-root/boot/* arch-boot/
if [ ! -f "$SRCDIR/pine64boot/u-boot-sunxi-with-spl.bin" ]; then
wget -N ${BASEURL}/allwinner/boot/pine64/u-boot-sunxi-with-spl.bin
fi
cp pine64boot/u-boot-sunxi-with-spl.bin arch-root/boot/u-boot-sunxi-with-spl.bin
modify_chroot
umount arch-root
losetup -d /dev/loop0
fi
if [ -f $IMG ]; then
img_created
fi
}
img_created() {
$DIALOG1 \
--title "DHCP base image created at:" --msgbox "
$(ls $WORKINGDIR/$IMG)" 0 0
}
static_img_created() {
$DIALOG1 \
--title "Static IP image created at:" --msgbox "
$(ls $OUTDIR/*.img)" 0 0
}
create_all_base() {
IMG=orangepiprime-archlinux-aarch64-$(date +%Y%m%d)
create_orpi_prime_img
IMG=orangepizero-archlinux-armv7-$(date +%Y%m%d)
create_orpi_zero_img
IMG=rpi2-archlinux-armv7-$(date +%Y%m%d)
URL=$BASEURL/ArchLinuxARM-rpi-2-latest.tar.gz
RPIMG=ArchLinuxARM-rpi-2-latest.tar.gz
create_rpi_img
IMG=rpi3-archlinux-armv7-$(date +%Y%m%d)
URL=$BASEURL/ArchLinuxARM-rpi-3-latest.tar.gz
RPIMG=ArchLinuxARM-rpi-3-latest.tar.gz
create_rpi_img
IMG=rpi4-archlinux-armv8-$(date +%Y%m%d)
URL=$BASEURL/ArchLinuxARM-rpi-4-latest.tar.gz
RPIMG=ArchLinuxARM-rpi-4-latest.tar.gz
create_rpi_img
IMG=pine64-archlinux-aarch64-$(date +%Y%m%d)
create_pine64_img
}
select_board_dhcp() {
$DIALOG1 \
--title "Choose Board Type" \
--menu "Board select:" 0 0 5 \
"1" "Orange Pi Prime" \
"2" "Orange Pi Zero" \
"3" "Rpi2" \
"4" "Rpi3" \
"5" "Rpi4" \
"6" "Pine64" \
"7" "go back" 2>${ANSWER}
case $(cat ${ANSWER}) in
"1")
IMG=orangepiprime-archlinux-aarch64-$(date +%Y%m%d)
create_orpi_prime_img
break ;;
"2")
IMG=orangepizero-archlinux-armv7-$(date +%Y%m%d)
create_orpi_zero_img
break ;;
"3")
IMG=rpi2-archlinux-armv7-$(date +%Y%m%d)
URL=$BASEURL/ArchLinuxARM-rpi-2-latest.tar.gz
RPIMG=ArchLinuxARM-rpi-2-latest.tar.gz
create_rpi_img
break ;;
"4")
IMG=rpi3-archlinux-armv7-$(date +%Y%m%d)
URL=$BASEURL/ArchLinuxARM-rpi-3-latest.tar.gz
RPIMG=ArchLinuxARM-rpi-3-latest.tar.gz
create_rpi_img
break ;;
"5")
IMG=rpi4-archlinux-armv8-$(date +%Y%m%d)
URL=$BASEURL/ArchLinuxARM-rpi-4-latest.tar.gz
RPIMG=ArchLinuxARM-rpi-4-latest.tar.gz
create_rpi_img
break ;;
"6")
IMG=pine64-archlinux-aarch64-$(date +%Y%m%d)
create_pine64_img
break ;;
"7")
static_ip_set
break ;;
*)
exit 1
;;
esac
}
select_board_static() {
$DIALOG1 \
--title "Choose Board Type" \
--menu "Board select:" 0 0 5 \
"1" "Orange Pi Prime" \
"2" "Orange Pi Zero" \
"3" "Rpi2" \
"4" "Rpi3" \
"5" "Rpi4" \
"6" "Pine64" \
"7" "go back" 2>${ANSWER}
case $(cat ${ANSWER}) in
"1")
IMG=orangepiprime-archlinux-aarch64-$(date +%Y%m%d)
create_orpi_prime_img
create_ip_preset_imgs $SKY_MGR_IP 1
break ;;
"2")
IMG=orangepizero-archlinux-armv7-$(date +%Y%m%d)
create_orpi_zero_img
create_ip_preset_imgs $SKY_MGR_IP 1
break ;;
"3")
IMG=rpi2-archlinux-armv7-$(date +%Y%m%d)
URL=$BASEURL/ArchLinuxARM-rpi-2-latest.tar.gz
RPIMG=ArchLinuxARM-rpi-2-latest.tar.gz
create_rpi_img
create_ip_preset_imgs $SKY_MGR_IP 1
break ;;
"4")
IMG=rpi3-archlinux-armv7-$(date +%Y%m%d)
URL=$BASEURL/ArchLinuxARM-rpi-3-latest.tar.gz
RPIMG=ArchLinuxARM-rpi-3-latest.tar.gz
create_rpi_img
create_ip_preset_imgs $SKY_MGR_IP 1
break ;;
"5")
IMG=rpi4-archlinux-armv8-$(date +%Y%m%d)
URL=$BASEURL/ArchLinuxARM-rpi-4-latest.tar.gz
RPIMG=ArchLinuxARM-rpi-4-latest.tar.gz
create_rpi_img
create_ip_preset_imgs $SKY_MGR_IP 1
break ;;
"6")
IMG=pine64-archlinux-aarch64-$(date +%Y%m%d)
create_pine64_img
create_ip_preset_imgs $SKY_MGR_IP 1
break ;;
"7")
static_ip_set
break ;;
*)
exit 1
;;
esac
}
create_ip_preset_imgs() {
set -ex
SKY_MGR_IP=$1
if [ -d "$OUTDIR" ]; then
rm -rf $OUTDIR
fi
if [ $2 = "1" ]; then
IPDIR=$CUSTDIR
cd $IPDIR
HOSTNAMES=$(ls *)
cd $WORKINGDIR
else
IPDIR=$PRESETDIR
cd $IPDIR
HOSTNAMES=$(ls *)
cd $WORKINGDIR
fi
mkdir -p $OUTDIR
for i in $HOSTNAMES; do
cp -b $IMG $OUTDIR/${FULLIMGNAME}-${i}.img
gnome-disk-image-mounter -w $OUTDIR/${FULLIMGNAME}-${i}.img
mount /dev/loop0p2 arch-root
cp -b $IPDIR/$i arch-root/etc/systemd/network/eth.network
echo "$i" > arch-root/etc/hostname
if [[ "$i" == *"node"* ]] && [ ! -z "$SKY_MGR_IP" ]; then
echo "SKYMGRIP=$SKY_MGR_IP" >> arch-root/etc/profile
fi
sleep 1
umount arch-root
losetup -d /dev/loop0
done
static_img_created
exit
}
hostname_set() {
set +e
rm $CUSTDIR/*
set -e
$DIALOG1 \
--radiolist "Choose Hostname:" 0 0 6 \
"1" "skymanager" off \
"2" "node1" off \
"3" "node2" off \
"4" "node3" off \
"5" "node4" off \
"6" "node5" off \
"7" "node6" off \
"8" "node7" off 2> ${ANSWER}
case $(cat ${ANSWER}) in
"1")
IMGHOSTNAME="skymanager"
;;
"2")
IMGHOSTNAME="node1"
;;
"3")
IMGHOSTNAME="node2"
;;
"4")
IMGHOSTNAME="node3"
;;
"5")
IMGHOSTNAME="node4"
;;
"6")
IMGHOSTNAME="node5"
;;
"7")
IMGHOSTNAME="node6"
;;
"8")
IMGHOSTNAME="node7"
;;
*)
cd $WORKINGDIR
rm -r $CUSTDIR
exit 1
;;
esac
if [ -z $IMGHOSTNAME ]; then
hostname_set
else
touch $IMGHOSTNAME
fi
if [ "$IMGHOSTNAME" == *"skymanager"* ]; then
SKY_MGR_IP=127.0.0.1
static_ip_set continue
else
mgr_ip_enter
static_ip_set continue
fi
}
img_ip_enter() {
$DIALOG1 \
--title "Image IP Address?" \
--inputbox "\nEnter desired image IP Address:" 8 40 2> ${ANSWER}
IMGIPADDRESS=$(cat ${ANSWER})
case $(cat ${ANSWER}) in
*.*.*.*)
if [ -z $SKY_MGR_IP ]; then
mgr_ip_enter
fi
static_ip_set continue
break;;
*)
$DIALOG1 \
--title "Error:" --msgbox "\nInvalid IP address provided" 7 40
HIGHLIGHT=2
static_ip_set continue
break;;
esac
if [ -z $IMGIPADDRESS ]; then
img_ip_enter
fi
static_ip_set continue
}
mgr_ip_enter() {
$DIALOG1 \
--title "Sky Manager IP Address?" \
--inputbox "\nEnter skymanager IP Address:" 8 40 2> ${ANSWER}
SKY_MGR_IP=$(cat ${ANSWER})
case $(cat ${ANSWER}) in
*.*.*.*)
if [ -z $SKY_MGR_IP ]; then
mgr_ip_enter
fi
static_ip_set continue
break;;
*)
$DIALOG1 \
--title "Error:" --msgbox "\nInvalid IP address provided" 7 40
HIGHLIGHT=1
static_ip_set
break;;
esac
}
router_ip_enter() {
$DIALOG1 \
--title "Router / Gateway IP Address?" \
--inputbox "\nEnter router IP Address:" 8 40 2> ${ANSWER}
ROUTERIP=$(cat ${ANSWER})
case $(cat ${ANSWER}) in
*.*.*.*)
if [ -z $ROUTERIP ]; then
router_ip_enter
fi
static_ip_set continue
break;;
*)
$DIALOG1 \
--title "Error:" --msgbox 'Invalid IP address provided' 7 40
HIGHLIGHT=3
static_ip_set continue
break;;
esac
}
confirm_static_cfg() {
$DIALOG1 \
--title "Use this config?" --clear \
--yesno "\nHostname: $IMGHOSTNAME\nImage IP: $IMGIPADDRESS\nGateway: $ROUTERIP\nManager IP: $SKY_MGR_IP" 9 40
case $? in
0)
select_board_static
break;;
esac
}
static_ip_set() {
set -ex
cd $WORKINGDIR
if [[ "$1" != *"continue"* ]]; then
if [ -d $CUSTDIR ]; then
rm -rf $CUSTDIR
fi
if [ ! -d $CUSTDIR ]; then
mkdir -p $CUSTDIR
cd $CUSTDIR
fi
fi
#if [ "$1" == *"continue"* ] && [[ $HIGHLIGHT != 4 ]]; then
# HIGHLIGHT=$(( HIGHLIGHT + 1 ))
#fi
$DIALOG1 \
--default-item ${HIGHLIGHT} \
--title "Choose" \
--menu "Please select: " 0 0 3 \
"1" "Set Hostname / manager IP" \
"2" "Set Image IP" \
"3" "Set Router IP" \
"4" "Confirm Settings" \
"5" "Back" 2> ${ANSWER1}
case $(cat ${ANSWER1}) in
"1")
HIGHLIGHT=2
hostname_set
IMGHOSTNAME=$(ls *)
if [ $IMGHOSTNAME != *"skymanager"* ]; then
mgr_ip_enter
fi
;;
"2")
if [ -z $IMGHOSTNAME ]; then
$DIALOG1 \
--title "Error:" \
--yesno "\nPlease configure the hostname first.\n" 7 40
case $? in
0)
HIGHLIGHT=1
static_ip_set
break;;
esac
else
HIGHLIGHT=3
img_ip_enter
fi
IMGIPADDRESS=$(cat ${ANSWER})
;;
"3")
if [ -z $IMGIPADDRESS ]; then
$DIALOG1 \
--title "Error:" \
--yesno "\nPlease set the image IP first.\n" 7 40
case $? in
0)
HIGHLIGHT=1
static_ip_set
break;;
esac
else
HIGHLIGHT=4
router_ip_enter
ROUTERIP=$(cat ${ANSWER})
fi
;;
"4")
if [ -z $IMGHOSTNAME ]; then
$DIALOG1 \
--title "Error:" \
--yesno "\nPlease configure the hostname first.\n" 7 40
case $? in
0)
HIGHLIGHT=1
static_ip_set
break;;
esac
else
if [ -z $IMGIPADDRESS ]; then
$DIALOG1 \
--title "Error:" \
--yesno "\nPlease set the image IP first.\n" 7 40
case $? in
0)
HIGHLIGHT=2
static_ip_set
break;;
esac
else
if [ -z $ROUTERIP ]; then
$DIALOG1 \
--title "Error:" \
--yesno "\nPlease set the router IP first.\n" 7 40
case $? in
0)
HIGHLIGHT=1
static_ip_set
break;;
esac
else
HIGHLIGHT=1
echo "[Match]
Name=eth*
[Network]
Address=$IMGIPADDRESS
Gateway=$ROUTERIP
DNS=$ROUTERIP
" > ${CUSTDIR}/${IMGHOSTNAME}
cd $WORKINGDIR
confirm_static_cfg $IMGHOSTNAME
fi
fi
fi
;;
"5")
cd $WORKINGDIR
rm -rf "customIP"
main_menu
;;
*)
exit 1
;;
esac
static_ip_set
}
main_menu() {
$DIALOG1 \
--title "Choose Installation Type" \
--menu "Please select: " 0 0 1 \
"1" "Official Skyminer (8 Image Set)" \
"2" "Single IP Preset Image" \
"3" "DHCP Image"
"4" "All Base images" 2> answer
# HIGHLIGHT=$(cat ${ANSWER})
case $(cat answer) in
"1")
create_orpi_prime_img
create_ip_preset_imgs 192.168.0.2
;;
"2")
static_ip_set
;;
"3")
select_board_dhcp
;;
"4")
create_all_base
;;
*)
exit 1
;;
esac
main_menu
}
while true; do
main_menu
done