summaryrefslogblamecommitdiffstats
path: root/builder/dnbd3-rootfs/module-setup.sh
blob: f29a71c95839249d17d68cabc6150cd6d1ecf9b2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11


           
                                     

                                     
 



                                                           
             


           
                                         
 

                 





                                                  
 

           
 
                     
 


                                                                                             
 
               
 
                  
 


                                                                                    
 

                                                                                
 
                                                                      

                                                                     
                                                            


                                                                              
 

                                                                 

                                                                 


                      

                                                               
                                                         
                                                                    
                                                             

                                                            
                                                                                      
 

                                                                              

                                                                           
                                                                   
                 
                                            
 
#!/bin/bash

check() {
    source "$moddir/scripts/utils.sh"
    UTILS_STANDARD_OUTPUT=/dev/stdout
    UTILS_ERROR_OUTPUT=/dev/stderr

    utils_compile_nbd "$moddir/binaries/nbd/" && \
    utils_compile_dnbd3 "$moddir/binaries/dnbd3" && \
    utils_compile_systemd_preserve_process_marker \
        "$moddir/binaries/systemd-preserve-process-marker/"
    return $?
}

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
    # 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 fdisk mkfs.xfs
    # Production:
    # inst_multiple insmod qemu-img qemu-nbd
}