clean up imagesync, fix build
This commit is contained in:
parent
56b783d38d
commit
0d1e53667f
3 changed files with 75 additions and 25 deletions
2
build.sh
2
build.sh
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/sh
|
||||
docker build --no-cache -t initramfs:debian .
|
||||
docker build -t initramfs:debian .
|
||||
docker run --rm -v "$PWD:/artifacts" initramfs:debian sh -c 'cp /boot/vmlinuz-* /artifacts/vmlinuz && cp /tmp/initrd.gz /artifacts'
|
||||
|
|
|
|||
92
imagesync.sh
92
imagesync.sh
|
|
@ -1,30 +1,45 @@
|
|||
#!/bin/sh
|
||||
|
||||
PREREQ=""
|
||||
prereqs()
|
||||
{
|
||||
echo "$PREREQ"
|
||||
. /usr/share/initramfs-tools/hook-functions
|
||||
copy_exec /usr/bin/aria2c
|
||||
copy_exec /sbin/sfdisk
|
||||
copy_exec /sbin/mke2fs
|
||||
}
|
||||
case $1 in
|
||||
# get pre-requisites
|
||||
prereqs)
|
||||
prereqs
|
||||
##
|
||||
# GET EXECUTED WHEN BUILDING INITRAMFS
|
||||
#
|
||||
. /usr/share/initramfs-tools/hook-functions
|
||||
copy_exec /usr/bin/aria2c
|
||||
copy_exec /sbin/sfdisk
|
||||
copy_exec /sbin/mke2fs
|
||||
copy_file cert /etc/ssl/certs/ca-certificates.crt
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
##
|
||||
# FUNCTION DEFINITIONS
|
||||
##
|
||||
|
||||
print_waiting() {
|
||||
echo -en "\033[36m${1}... \033[0m"
|
||||
}
|
||||
|
||||
print_done() {
|
||||
echo -e "\033[32mdone.\033[0m"
|
||||
}
|
||||
|
||||
##
|
||||
# HARDCODED DISK PARAMETERS
|
||||
##
|
||||
|
||||
disk=/dev/sda
|
||||
|
||||
|
||||
size_part_1=$((3072 * 1024 * 1024 / 512))
|
||||
|
||||
sfdisk /dev/sda << PARTTABLE
|
||||
##
|
||||
# PARTITIONING OF DISK
|
||||
##
|
||||
|
||||
print_waiting "Partitioning disk"
|
||||
sfdisk -q /dev/sda << PARTTABLE
|
||||
label: dos
|
||||
label-id: 0xdeadbeef
|
||||
device: /dev/sda
|
||||
|
|
@ -32,20 +47,53 @@ unit: sectors
|
|||
|
||||
/dev/sda1 : start= 2048, size= $size_part_1, type=83
|
||||
PARTTABLE
|
||||
print_done
|
||||
|
||||
mke2fs -F -t ext4 ${disk}1
|
||||
print_waiting "Creating Filesystem"
|
||||
mke2fs -q -F -t ext4 ${disk}1
|
||||
print_done
|
||||
|
||||
mkdir -p /tmp_root
|
||||
mount -t ext4 ${disk}1 /tmp_root
|
||||
ls -lah /dev/sd* /tmp_root
|
||||
|
||||
ip a
|
||||
##
|
||||
# TEMPORARY NETWORK CONFIG (only for qemu)
|
||||
##
|
||||
|
||||
print_waiting "Setting up temporary network config"
|
||||
ip addr add 10.2.2.2/24 dev ens3
|
||||
ip link set ens3 up
|
||||
#ping 10.2.2.1
|
||||
print_done
|
||||
|
||||
aria2c -V --check-certificate=false --seed-ratio=0 'http://10.2.2.1/image.torrent'
|
||||
##
|
||||
# MOUNT TEMPORARY ROOTFS
|
||||
##
|
||||
|
||||
sleep 3600
|
||||
print_waiting "Mounting temporary root filesystem"
|
||||
mkdir -p /tmp_root
|
||||
mount -t ext4 ${disk}1 /tmp_root
|
||||
cd /tmp_root
|
||||
print_done
|
||||
|
||||
##
|
||||
# DOWNLOAD FS IMAGE
|
||||
##
|
||||
|
||||
print_waiting "Downloading root filesystem image"
|
||||
# (DHT error seems normal, because it is aria2c’s first run)
|
||||
|
||||
# --check-integrity: verify downloaded file and do not complain about missing controll file
|
||||
# --seed-time=0: do not wait until ratio 1, we seed when we’re booted
|
||||
# --quiet: no console output
|
||||
aria2c --check-integrity --seed-time=0 --quiet=true 'http://10.2.2.1:8081/image.torrent'
|
||||
print_done
|
||||
|
||||
##
|
||||
# UNMOUNT TEMPORARY ROOTFS
|
||||
##
|
||||
|
||||
print_waiting "Unmounting temporary root filesystem"
|
||||
cd /
|
||||
umount /tmp_root
|
||||
print_done
|
||||
|
||||
print_waiting "Waiting for implementation of more features"
|
||||
|
||||
while sleep 3600;do sleep 3600;done
|
||||
|
|
|
|||
6
qemu.sh
6
qemu.sh
|
|
@ -12,11 +12,13 @@ sudo ip addr add 10.2.2.1/24 dev brtstsync
|
|||
sudo ip link set taptstsync up
|
||||
sudo ip link set brtstsync up
|
||||
|
||||
# -append "root=/dev/sda1 quiet" \
|
||||
|
||||
qemu-system-x86_64 \
|
||||
-kernel vmlinuz \
|
||||
-initrd initrd.gz \
|
||||
-drive format=raw,if=scsi,file=pladde.img \
|
||||
-append root=/dev/sda1 \
|
||||
-drive format=raw,file=pladde.img \
|
||||
-append "root=/dev/sda1" \
|
||||
-m 1G \
|
||||
-net nic \
|
||||
-net tap,ifname=$ifname_tap,script=no,downscript=no
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue