RELEASE-ISO-MODIFICATION(7)

NAME
release-iso-modification - instructions on how to modify release .iso filesystems

DESCRIPTION
This document describes how to modify Sortix .iso releases to meet your custom needs. The bootloader configuration in .iso releases is designed with an extensible hooks system that let's you override it with further configuration and to load additional files of your choice into the live environment. The live environment is configurable through the normal operating system configuration as described in section 5 of the manual.

The release modification procedure lets you customize aspects such as the default bootloader menu option and timeout, the default hostname, the default keyboard layout, the default graphics resolution, adding files of your choice to the live environment, and so on.

  Prerequisites
•   A sortix-x.y-arch.iso release for your architecture.
•   xorriso(1) needs to be installed.

  Overview
The release modification process has three stages:

•   Optionally, creating additional files that will be loaded onto the live environment (the liveconfig).
•   Creating additional bootloader configuration (the bootconfig), which will contain an archived copy of the liveconfig (if any).
•   Adding the bootconfig to the release .iso.

The bootloader menu Install and Upgrade selections will start the live environment and run the sysinstall(8) installer and sysupgrade(8) upgrader respectively and they are thus also customizable by this procedure.

  Convenience Scripts
The release modification can be done manually by hand, or you can use the following convenience scripts that make the release modification easy:

•   tix-iso-liveconfig(8) that generates additional configuration files for the live environment.
•   tix-iso-bootconfig(8) that generates additional bootloader configuration and optionally configures the bootloader to load the liveconfig into the live environment.
•   tix-iso-add(8) that adds the bootconfig (and thus the liveconfig if any) to the release .iso.

These convenience scripts come with the operating system and are installed in the /sbin directory. These scripts are entirely for convenience and you can perform their tasks yourself if they don't meet your needs. The scripts are readable shell scripts and you can learn how they work and extend them with your own features.

If you are not on a Sortix system or on a different version of Sortix than the one you are customizing, you can download the shell scripts matching the latest stable release:

•   https://sortix.org/release/stable/scripts/tix-iso-liveconfig
•   https://sortix.org/release/stable/scripts/tix-iso-bootconfig
•   https://sortix.org/release/stable/scripts/tix-iso-add

If you are not customizing the latest stable release, you can find the matching versions of the scripts in the scripts/ subdirectory of the appropriate release directory, or you can check out the tix directory in the source code from https://sortix.org/source/ matching the release you are currently customizing.

  Additional Live Configuration Configuration
The live environment is a normal instance of the operating system and can be configured by adding additional files or overwriting existing files. Section 5 of the manual documents the system and software configuration files. Additional files can also be added for their own sake.

To do so, create a directory that will contain this additional live environment configuration (liveconfig), whose contents will be extracted on top of the live environment's root filesystem. A compressed archive of this directory will be made in the next subsection and needs to be registered with the bootloader configuration.

The tix-iso-liveconfig(8) convenience script is useful as it offers a lot of commonly useful customizations to the live environment and can populate an initial liveconfig directory for you.

  Additional Bootloader Configuration
The GRUB bootloader configuration of an release .iso is extensible and allows additional configuration to hook into it by writing a /boot/grub/hooks.cfg configuration file as described in release-iso-bootconfig(7).

To do so, create a directory that will contain this additional bootloader configuration (bootconfig), whose contents will be added onto the release .iso. The liveconfig (if any) is normally added to the bootconfig as a compressed archive and the additional bootloader configuration loads it as an initrd onto the live environment. The bootconfig will be overlaid to the release .iso in the next subsection.

The tix-iso-bootconfig(8) convenience script makes it easy to generate common additional bootloader configuration and its documentation has examples of what it can do. It is commonly used with the --liveconfig option to generate the bootloader configuration that loads the additional files from the liveconfig into the live environment.

  Adding Files To The Release
Releases are modified by adding the bootconfig (which contains a compressed copy of the liveconfig, if any) files to the release .iso.

The tix-iso-add(8) convenience script makes it easy to add files to a release .iso while taking care to keep the release .iso bootable after the modification. You need xorriso(1) installed to use this script. Alternatively you can add the files to the release .iso by running xorriso(1) yourself:

    xorriso \
      -indev "$input_file" \
      -outdev "$output_file" \
      -boot_image grub keep \
      -pathspecs on \
      -add \
      ="$input_directory"

Your modified release can then be used in place of the original release. See the EXAMPLES section below for inspiration on what customizations to make, as well as the manual pages for the tix-iso-liveconfig(8) and tix-iso-bootconfig(8) convenience scripts.

EXAMPLES
This section contains examples of how one can modify a release .iso.

  No Change
To customize a release with no customizations except for the bootloader to say the release was modified by the current user on the current host:

    tix-iso-bootconfig bootconfig
    tix-iso-add sortix.iso bootconfig

  Add Files to the Live Environment
To customize a release with additional files and directories in the live environment:

    mkdir -p liveconfig
    mkdir -p liveconfig/root
    echo foo > liveconfig/root/foofile
    echo bar > liveconfig/root/barfile
    tix-iso-bootconfig --liveconfig=liveconfig bootconfig
    tix-iso-add sortix.iso bootconfig

  Provide Random Seed
To customize a release with a random seed (/boot/random.seed) (which must be kept confidential and not reused, see the warnings in tix-iso-bootconfig(8)):

    tix-iso-bootconfig --random-seed bootconfig
    tix-iso-add sortix.iso bootconfig
    rm bootconfig/boot/random.seed # When no longer useful.
    rm sortix.iso # When no longer useful.
    # And erase any media made from sortix.iso when no longer useful.

  Hostname, Keyboard Layout, and Graphics Resolution
To customize the live environment of a release with a custom hostname, custom keyboard layout, and custom graphics resolution:

    tix-iso-liveconfig \
      --hostname=dragon \
      --kblayout=dk \
      --videomode=1920x1080x32 \
      liveconfig
    tix-iso-bootconfig --liveconfig=liveconfig bootconfig
    tix-iso-add sortix.iso bootconfig

  Load Only Basic Ports by Default
To customize a release to only loads basic ports by default:

    mkdir -p bootconfig/grub
    cat > bootconfig/grub/hooks.cfg << EOF
    function hook_init {
      select_ports_set_basic
    }
    EOF
    tix-iso-add sortix.iso bootconfig

  Default Bootloader Menu Option and Timeout
To customize a release so the default bootloader menu option is to run the installer (bootloader menu option 1, counting from 0) and to change the bootloader menu timeout to 2 seconds:

    tix-iso-bootconfig --default=1 --timeout=2 bootconfig
    tix-iso-add sortix.iso bootconfig

  Locked Down Multi-User Live Environment
To customize a release so the live environment boots to the login screen by default with the provided database of users and groups ((passwd) 5 and group(5)), password protect the bootloader so only the default live environment option can be chosen by unauthenticated users:

    mkdir -p liveconfig/etc
    # Each user's password is their username hashed with crypt_newhash(3).
    (printf 'root:%s:0:0:root:/root:sh\n' \
            '$2b$10$S/fJmYIJSkRdifk61xDYn.w62y.vNu35tZkznR6xa3Ntg0hsbI8tO' &&
     printf 'alice:%s:1000:1000:alice:/home/alice:sh\n' \
            '$2b$10$4xGAf5FyCYedWoNltWvbmOOreXcI5cH/f4Jz/pkWrWxwZ7TQ/WbRC' &&
     printf 'bob:%s:1001:1001:bob:/home/bob:sh\n' \
            '$2b$10$0.IukhbHNy63te6ozVJ7Pu/EvbCcr892981XbqRQ0w16UPhmDdUqa') |
    cat > liveconfig/etc/passwd
    cat > liveconfig/etc/group << EOF
    root::0:root
    alice::1000:alice
    bob::1001:bob
    EOF
    mkdir -p liveconfig/home
    mkdir -p -m 700 liveconfig/home/alice
    mkdir -p -m 700 liveconfig/home/bob
    grub-mkpasswd-pbkdf2 | # enter bootloader password
    tee /dev/tty |
    tail -n 1 |
    sed 's/PBKDF2 hash of your password is //' > liveconfig/etc/grubpw
    tix-iso-bootconfig --liveconfig=liveconfig bootconfig
    (echo 'insmod password_pbkdf2'
     echo 'set superusers="root"'
     echo "password_pbkdf2 root $(cat liveconfig/etc/grubpw)") |
    cat >> bootconfig/boot/grub/hooks.cfg
    cat > bootconfig/boot/grub/main.cfg << \OF
    menu_title="$base_menu_title"
    hook_menu_pre
    menuentry "Sortix $version" --unrestricted {
      load_sortix -- /sbin/init --target=multi-user
    }
    hook_menu_post
    EOF
    tix-iso-add sortix.iso bootconfig

  Add a new Port
To customize a release with a new port foo in the basic and all port sets and fully integrate it with the bootloader menus:

    mkdir -p bootconfig/boot/grub
    cat > bootconfig/boot/grub/hooks.cfg << \EOF
    port_foo=true
    tix_foo=false
    export port_foo
    export tix_foo
    function hook_ports_menu {
      if $port_foo; then
        menuentry "foo = true" {
          port_foo=false
          configfile /boot/grub/ports.cfg
        }
      else
        menuentry "foo = false" {
          port_foo=true
          configfile /boot/grub/ports.cfg
        }
      fi
    }
    function hook_tix_menu {
      if $tix_foo; then
        menuentry "foo = true" {
          tix_foo=false
          configfile /boot/grub/tix.cfg
        }
      else
        menuentry "foo = false" {
          tix_foo=true
          configfile /boot/grub/tix.cfg
        }
      fi
    }
    function hook_ports_set_all {
      port_foo=true
    }
    function hook_tix_set_all {
      tix_foo=true
    }
    function hook_ports_set_basic {
      port_foo=true
    }
    function hook_tix_set_basic {
      tix_foo=true
    }
    function hook_ports_set_minimal {
      port_foo=false
    }
    function hook_tix_set_minimal {
      tix_foo=false
    }
    function hook_ports_set_no {
      port_foo=false
    }
    function hook_tix_set_no {
      tix_foo=false
    }
    function hook_ports_pre {
      if $tix_foo; then
        echo -n "Loading /repository/foo.tix.tar.xz (3.0M) ... "
        module --nounzip /repository/foo.tix.tar.xz \
               --to /repository/foo.tix.tar.xz
        echo done
      fi
      if $port_foo; then
        echo -n "Loading /repository/foo.tix.tar.xz (3.0M) ... "
        module /repository/foo.tix.tar.xz --tix
        echo done
      fi
    }
    EOF
    mkdir -p bootconfig/repository
    cp foo.tix.tar.xz bootconfig/repository/foo.tix.tar.xz
    tix-iso-add sortix.iso bootconfig

  Add a new Ports Set
To customize a release with your own set of ports that are loaded by default and fully integrate it with the bootloader menus:

    mkdir -p bootconfig/boot/grub
    cat > bootconfig/boot/grub/hooks.cfg << \EOF
    function hook_ports_menu_sets {
      menuentry "Load only recommended ports" {
        select_ports_set_recommended
        configfile /boot/grub/ports.cfg
      }
    }
    function hook_tix_menu_sets {
      menuentry "Load only basic binary packages" {
        select_tix_set_recommended
        configfile /boot/grub/tix.cfg
      }
    }
    select_ports_set_recommended {
      # The basic set can be extended by calling select_ports_set_basic here.
      port_foo=false
      port_bar=true
    }
    select_tix_set_recommended {
      # The basic set can be extended by calling select_tix_set_basic here.
      tix_foo=false
      tix_bar=true
    }
    # Load the recommended set of ports by default.
    hook_ports_menu_sets
    EOF
    tix-iso-add sortix.iso bootconfig

SEE ALSO
xorriso(1), development(7), installation(7), release-iso-bootconfig(7), upgrade(7), user-guide(7), tix-iso-add(8), tix-iso-bootconfig(8), tix-iso-liveconfig(8)