summaryrefslogblamecommitdiffstats
path: root/builder/dnbd3-rootfs/module-setup.sh
blob: 45122afb440c6f462cd1117a1b8bd9246e11532f (plain) (tree)
1
2
3
4
5
6
7


           
                                     

                                     
 










                                                                                                                   


           
                                         
                                                         
 

                 




                                                  















                                                                               
 

           
 
                     
 


                                                                                             
 
               
 
                  
 
                                                                
                                                                                         
                                                                                    
 

                                                                                
 
                                                                    
                                                                              
 

                                                                 

                                                                 
               



                                                       


                                                                                  
 

               




                                                                                     

                                                              

               
 
                

                                                                               
                                                    

                                                                            
                 

                                                                        
 
#!/bin/bash

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

    if [[ ! -f "$moddir/binaries/nbd/nbd.ko" ]]; then
        utils_compile_nbd "$moddir/binaries/nbd/"
    fi
    if [[ ! -f "$moddir/binaries/dnbd3/build/dnbd3.ko" || ! -f "$moddir/binaries/dnbd3/build/dnbd3-client" ]]; then
        utils_compile_dnbd3 "$moddir/binaries/dnbd3/"
    fi
    if [[ ! -f "$moddir/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker" ]]; then
        utils_compile_systemd_preserve_process_marker \
            "$moddir/binaries/systemd-preserve-process-marker/"
    fi
    return 0
}

depends() {
    echo base network bash kernel-modules
    # NOTE: btrfs module should be used if it would work.
}

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

    # Debugging:
    instmods cfg80211 rfkill vboxsf nls_iso8859_1 ppdev nls_cp437 iosf_mbi \
        vfat fat snd_intel8x0 crct10dif_pclmul crc32_pclmul input_leds \
        led_class aesni_intel evdev aes_x86_64 lrw joydev gf128mul \
        snd_ac97_codec glue_helper ablk_helper cryptd psmouse ac97_bus \
        snd_pcm vboxvideo mousedev serio_raw pcspkr mac_hid snd_timer battery \
        video snd ac acpi_cpufreq processor button parport_pc e1000 parport \
        drm intel_agp soundcore intel_gtt vboxguest i2c_piix4 sch_fq_codel \
        ip_tables x_tables hid_generic usbhid hid xor raid6_pq sr_mod \
        cdrom sd_mod ata_generic pata_acpi atkbd libps2 i8042 serio ohci_pci \
        ohci_hcd crc32c_intel usbcore ahci usb_common libahci ata_piix libata \
        scsi_mod \
        ext4 dm_snapshot btrfs crc32c
    # Production:
    # instmods ext4 dm_snapshot btrfs crc32c
    # NOTE: btrfs crc32c should usually be included by the btrfs dracut module.
}

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-kernel-command-line-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"

    inst_hook pre-mount 00 "$moddir/hooks/pre-mount/fetch-config.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

    # region scripts

    inst "$moddir/scripts/utils.sh" "/usr/lib/utils.sh"
    # This script is triggered by udev upon finding the right partitions for
    # persistent sessions.
    inst "$moddir/scripts/prepare-persistent-disks" /sbin/prepare-persistent-disks

    # endregion

    # region configuration files

    # Udev rules detecting 44, 45, 46 partitions and running
    # "prepare-persistent-disks" to prepare persistent partitions.
    inst "$moddir/udev/70-openslx-disk.rules" /etc/udev/rules.d/70-openslx-disk.rules
    # Use terminal readline settings from the template system.
    inst /etc/inputrc /etc/inputrc

    # endregion

    # Debugging:
    inst_multiple lsblk ping ip ifconfig sshd htop tail head vim touch sed \
        lsmod sleep route wget find lsof strace chroot switch_root pivot_root \
        mount fdisk mkfs.xfs env busybox ps agetty \
        insmod qemu-nbd blockdev partx dmsetup sed cut awk insmod qemu-nbd \
        blockdev partx dmsetup cat cut awk losetup dd mkfs.ext4 grep
    # Production:
    # inst_multiple insmod qemu-nbd blockdev partx dmsetup cat cut awk \
    #     losetup dd mkfs.ext4 grep
}