Skip to content
Guy Sheffer edited this page Aug 12, 2019 · 25 revisions

One of the main features in CustomPiOS is writing modules. A module is a structured piece of code that adds a function to a distro.

Setting Modules

To set what the distro does, you can add and remove modules. The modules are defined in the MODULES variable set in your distro <distro folder>/src/config file. Modules can be nested, the enables you to provide namespaces or run cleanup functions after other module have run. For example MODULES=base(network(octopi, picamera)), in this example base will start first, and end last, network will start second and end one before last, octopi will start third and end first.

Writing Modules

  • Module are places in folders whose names are small letters and with hyphens.
  • The can be placed either in CustomPiOS/src/modules or <distro folder>/src/modules.

See the example module in the example disro.

Modules are made from 3 parts:

  • start_chroot_script / end_chroot_script
  • filesystem folder
  • config file

Variable names in the config file of a module

In the config file you can set bash variables that would change the configuration of the module. They are automatically exported to the build and you can use them, and also set them in the main config file of a distro. Only variables with the prefix of the module name are exported. So for example the base module variables should start with BASE_. If there is a Hyphen - symbol it would be converted to an underscore. So the module example-hello should be set as EXAMPLE_HELLO_VAR.

List of Standard library modules

auto-hotspot

This is a module that makes your raspberrypi a wifi hotspot if wifi fails to connect to a network. If an ethernet cable is connected it will forward the connection. Originally based on this guide. Has to be inside a disable-services module block.

base

This is the base module you must have in your distro. It sets what image is selected and critical things in the distro

cockpit

Cockpit is a Red Hat sponsored free software project released under the LGPL v2.1+ https://cockpit-project.org/ this module installs it

disable-services

Disables systemd services to start up right after installing them. If your module is installing something, say lighttpd. You should wrap your module with this one. Eg disable-services(lighttpd).

docker

This module installs docker.

ffmpeg

Module builds and installs latest ffmpeg from git

gui

Lets you add a gui that will start on boot, autologin and GPU out of the box.

kernel

Builds and installs a custom kernel. Warning: building a kernel can take as long as 6 hours. And with two it takes 12 hours. If you are building them a lot its recommended to create a base image and build on top of that. See RealtimePi for usage example.

mysql

Installs and configures an mysql mariadb database with default user 'pi' and password 'raspberry'

network

This module is enabled by default, it creates a file in /boot/${DIST_NAME}-network.txt and /boot/${DIST_NAME}-wpa-supplicant.txt that lets you set up the wifi configuration from a text file that is accessable even from a windows machine.

password-for-sudo

Revert Raspbian's "no password for sudo"

raspicam

Enables the pi camera by default

usage-statistics

Module lets you send anonymous statistics to a webserver regarding usage of your distro. Does not store any private information. Currently only reports each time the device boots, using the pi ID with obfuscation.

Clone this wiki locally