summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-qcow2-rootfs/module-setup.sh
blob: eb81f34779963d0fa9a622e7287989f162db6c36 (plain) (blame)
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
#!/bin/bash

source "$moddir/scripts/utils.sh"

check() {
    compile_nbd && \
    compile_dnbd3 && \
    compile_systemd_preserve_process_marker &&
}

depends() {
    echo base network bash kernel-modules
}

installkernel() {
    inst "$moddir/binaries/dnbd3/build/dnbd3.ko" \
        /usr/lib/modules/current/extra/dnbd3.ko
    inst "$moddir/binaries/nbd/nbd.ko" \
        /usr/lib/modules/current/extra/nbd.ko

    instmods ext4 btrfs
}

install() {

    # region binaries

    inst "$moddir/binaries/dnbd3/build/dnbd3-client" /usr/bin/dnbd3-client
    inst "$moddir/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker" \
        /usr/bin/systemd-preserve-process-marker

    # endregion

    # region hooks

    inst_hook cmdline 00 "$moddir/hooks/cmdline/enable-sysrq.sh"
    inst_hook cmdline 10 "$moddir/hooks/cmdline/prepare-network-kcl-parameter.sh"
    inst_hook cmdline 90 "$moddir/hooks/cmdline/set-dracut-environment-variables.sh"

    inst_hook pre-udev 00 "$moddir/hooks/pre-udev/load-custom-kernel-modules.sh"
    inst_hook pre-udev 00 "$moddir/hooks/pre-udev/setup-loopback-device.sh"

    # this is the configuration hook where the config stuff is wget'ed
    # TODO
    #inst_hook pre-mount 00 "$moddir/hooks/pre-mount/fetch-config.sh"
    # this is the main hook where all the magic is triggered
    #inst_hook pre-mount 10 "$moddir/hooks/pre-mount/mount-qcow.sh"

    inst_hook pre-mount 10 "$moddir/hooks/pre-mount/prepare-root-partition.sh"

    inst_hook mount 10 "$moddir/hooks/mount/mount-root-device.sh"

    inst_hook pre-pivot 00 "$moddir/hooks/pre-pivot/mount-tmp.sh"

    # endregion

    ## TODO deprecated
    ### SCRIPTS
    # the main magic script containing all the functions needed
    # to prepare the qcow2-based root filesystem
    #inst "$moddir/scripts/setup-qcow2" /sbin/setup-qcow2
    #
    # the script triggered by udev upon finding the right partitions
    #inst "$moddir/scripts/prepare-disks" /sbin/prepare-disks
    ##
    # udev rules detecting 44, 45, 46 partitions and running
    # 'prepare-disks' to do then format/mount/use them
    #inst "$moddir/udev/70-openslx-disk.rules" /etc/udev/rules.d/70-openslx-disk.rules
    ##

    # Debugging Uncomment this version if you need some useful debugging tools
    # in your iniramfs.
    inst_multiple lsblk ping ip ifconfig sshd htop tail head cat vim \
        touch sed lsmod insmod qemu-img sleep route wget find lsof strace \
        chroot switch_root pivot_root qemu-nbd mount nbd-client fdisk mkfs.xfs
    # Production:
    # inst_multiple insmod qemu-img qemu-nbd
}