server/fickit-prepare.yml

151 lines
5.0 KiB
YAML
Raw Normal View History

2018-12-10 01:16:07 +00:00
kernel:
2020-01-15 10:02:27 +00:00
image: nemunaire/kernel:4.9.210-edfde5a675ea193ae1cadf790b69d67ca1f520c2-dirty-amd64
2018-12-10 01:16:07 +00:00
cmdline: "console=ttyS0 console=tty0"
init:
- linuxkit/init:c563953a2277eb73a89d89f70e4b6dcdcfebc2d1
- linuxkit/runc:83d0edb4552b1a5df1f0976f05f442829eac38fe
- linuxkit/getty:2eb742cd7a68e14cf50577c02f30147bc406e478
onboot:
- name: net-setup
image: linuxkit/ip:v0.6
command: ["/bin/sh", "-c", "ip a add 10.10.10.5/29 dev eth0; ip link set eth0 up;" ]
- name: format
image: linuxkit/format:v0.6
command: ["/bin/sh", "-c", "cat /etc/fdisk_cmd | fdisk /dev/sda && cat /etc/fdisk_cmd | fdisk /dev/sdb && cat /etc/sfdisk_schema | sfdisk /dev/sda && cat /etc/sfdisk_schema | sfdisk /dev/sdb" ]
binds:
- /dev:/dev
- /etc/fdisk_cmd:/etc/fdisk_cmd:ro
- /etc/sfdisk_schema:/etc/sfdisk_schema:ro
- name: raid-setup
2019-12-16 13:39:39 +00:00
image: nemunaire/mdadm:18de5ca414227f38a5c0619662077ba5fa26176d
command: ["/bin/sh", "-c", "/sbin/mdadm --create /dev/md2 --run --level=1 --metadata=1.0 --raid-devices=2 /dev/sda1 /dev/sdb1; /sbin/mdadm --create /dev/md1 --run --level=1 --metadata=1.1 --raid-devices=2 /dev/sda2 /dev/sdb2; /sbin/mdadm --create /dev/md0 --run --level=1 --metadata=0 --raid-devices=2 /dev/sda3 /dev/sdb3;"]
2018-12-10 01:16:07 +00:00
- name: format
image: linuxkit/format:v0.6
command: ["/bin/sh", "-c", "mkswap /dev/md1; mkfs.ext4 /dev/md0 && sync" ]
2018-12-10 01:16:07 +00:00
binds:
- /dev:/dev
- name: install-syslinux
image: nemunaire/syslinux:4e080937962e68f9f6a962ff6890cb4c62720841
2018-12-10 01:16:07 +00:00
command: ["/bin/sh", "/root/install_syslinux", "/dev/sda" , "/dev/sdb" ]
binds:
- /dev:/dev
- /root/install_grub:/root/install_syslinux:ro
2018-12-10 01:16:07 +00:00
- /root/update_imgs:/root/update_imgs:ro
files:
- path: root/update_imgs
source: configs/update_imgs.sh
mode: "0755"
- path: root/install_syslinux
contents: |
#!/bin/sh
for p; do
mkfs.vfat ${p}
2018-12-10 01:16:07 +00:00
mkdir -p /boot
mount ${p} /boot/
2018-12-10 01:16:07 +00:00
mkdir -p /boot/EFI/boot /boot/imgs
cd /usr/share/syslinux/efi64
cp ldlinux.e64 menu.c32 libcom32.c32 libutil.c32 vesamenu.c32 poweroff.c32 /boot/EFI/boot
cp syslinux.efi /boot/EFI/boot/bootx64.efi
cat <<EOF > /boot/syslinux.cfg
TIMEOUT 30
ONTIMEOUT backend
MENU background #00000000 * *
MENU color title * #FF22BBCC *
MENU color sel * #FFFFFFFF #FF22BBCC *
MENU color hotsel 1;7;37;40 #ffffffff #76a1d0ff *
UI vesamenu.c32
MENU TITLE Server FIC Challenge
LABEL backend
MENU LABEL FIC Backend
LINUX /imgs/fickit-kernel
INITRD /imgs/fickit-boot-initrd.img
APPEND console=ttyS0 console=tty0 root=fickit-backend-squashfs.img
LABEL frontend
MENU LABEL FIC Frontend
LINUX /imgs/fickit-kernel
INITRD /imgs/fickit-boot-initrd.img
APPEND console=ttyS0 console=tty0 root=fickit-frontend-squashfs.img
LABEL update
MENU LABEL Update images
LINUX /imgs/fickit-kernel
INITRD /imgs/fickit-update-initrd.img
APPEND console=ttyS0 console=tty0
MENU SEPARATOR
LABEL poweroff
MENU LABEL ^Shutdown
KERNEL poweroff.c32
EOF
# BIOS part
dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/mbr.bin of=${p}
syslinux --install ${p}
2018-12-10 01:16:07 +00:00
cp /usr/share/syslinux/libcom32.c32 /usr/share/syslinux/libutil.c32 /usr/share/syslinux/poweroff.c32 /usr/share/syslinux/vesamenu.c32 /boot/
# Write images
/root/update_imgs
done
mode: "0550"
- path: root/install_grub
contents: |
#!/bin/sh
for p; do
mkfs.vfat ${p}1
mkdir -p /boot
mount ${p}1 /boot/
mkdir -p /boot/EFI/boot /boot/imgs
grub-mkimage -o "/boot/EFI/boot/bootx64.efi" -p /efi/boot -O x86_64-efi fat iso9660 part_gpt part_msdos normal boot linux configfile loopback chain efifwsetup efi_gop efi_uga ls search search_label search_fs_uuid search_fs_file gfxterm gfxterm_background gfxterm_menu test all_video loadenv exfat ext2
grub-install --boot-directory="/boot/" --target=i386-pc "${p}"
cat <<EOF > /boot/grub/grub.cfg
set timeout=3
menuentry 'FIC Backend' {
set root=(hd0,1)
linux /imgs/fickit-kernel console=ttyS0 console=tty0 root=fickit-backend-squashfs.img
initrd /imgs/fickit-boot-initrd.img
}
menuentry 'FIC Frontend' {
set root=(hd0,1)
linux /imgs/fickit-kernel console=ttyS0 console=tty0 root=fickit-frontend-squashfs.img
initrd /imgs/fickit-boot-initrd.img
}
menuentry 'Update images' {
set root=(hd0,1)
linux /imgs/fickit-kernel console=ttyS0 console=tty0
initrd /imgs/fickit-update-initrd.img
}
EOF
cp "/boot/grub/grub.cfg" "/boot/EFI/boot/grub.cfg"
# Write images
/root/update_imgs
2018-12-10 01:16:07 +00:00
done
mode: "0550"
- path: etc/sfdisk_schema
contents: |
,500M,U,*
,4M,S,-
,+,R,-
mode: "0440"
- path: etc/fdisk_cmd
contents: |
o
w
mode: "0440"