-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatch-alpine-netboot-image-with-zfs.sh
executable file
·55 lines (40 loc) · 1.36 KB
/
patch-alpine-netboot-image-with-zfs.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
#!/bin/bash
# Purpose: Patch alpine netboot image with
# - include zfs kernel module by default
# (note the 'alpine extended iso' includes the zfs module
# but that is not a netboot image)
# - ping delay wait until network links are up and can
# reach gateway for download of additional packages
#
set -x
# Force a wait for interfaces to come up
# on slow switches
WORK_DIR=$PWD
NETBOOT_OUTPUT_FILENAME=alpine-zfsnetboot.tar.gz
pwd
ls -lh
cd iso
echo Removing previously extracted ./boot if exists
rm -rf ./boot
echo "Removing previous $NETBOOT_OUTPUT_FILENAME if exists"
rm -rf $NETBOOT_OUTPUT_FILENAME
# Clean up previous runs
find . -maxdepth 1 -type f -name "*.tar.gz" -mtime +0 # Remove older than today
tar -xvf alpine-zfsnetboot-*.tar.gz
cd ./boot
mkdir patch
zcat initramfs-lts | cpio -D patch --extract --make-directories --preserve-modification-time
cd patch
# Apply the initramfs-lts patch
patch init ../../../PatchFile-init-ping
# Re-package initramfs-lts
find . | cpio --format=newc --create | gzip > initramfs-lts
mv initramfs-lts ../
cd ../
rm -rf patch
echo Re-taring the netbook image for sending to boot server
echo -n patched-init makes reference to the fact init will poll ping to verify network
echo is up before attempting to pull down additional packages over network
tar -cvf $NETBOOT_OUTPUT_FILENAME ./
mv $NETBOOT_OUTPUT_FILENAME ../
cd $WORK_DIR