Skip to content

Conversation

@ChuckBorris33
Copy link

This pull request introduces a new module, bootc-hooks, designed to run user-provided scripts at various bootc lifecycle events. It provides a structured way to automate tasks during boot, OS updates, and image switches (rebases).

This new module allows for running scripts in two different contexts:

  • System: Scripts that run as the root user.
  • User: Scripts that run as the logged-in user.

For both system and user contexts, scripts can be configured to run on three specific events:

  • boot: Runs on every boot (for system) or login (for user).
  • update: Runs when the bootc image digest changes, indicating an OS update.
  • switch: Runs when the bootc image name changes, indicating a rebase to a different image.

How It Works

The module installs two systemd services:

  1. system-bootc-hooks.service: A system-wide service that runs as root. It determines the current and previous bootc image status, saves it to /var/lib/bootc-hooks/, and executes the appropriate system-level hooks.
  2. user-bootc-hooks.service: A user-level service that runs after the system service. It reads the version information prepared by the system service to determine which user-level hooks to run, avoiding the need for privileged commands in the user session.

Example Usage

To use the module, users can define which scripts to run for each event in their recipe.yml:

modules:
  - type: bootc-hooks
    system:
      boot:
        - on-boot-as-root.sh
      update:
        - on-update-as-root.sh
    user:
      boot:
        - on-login-as-user.sh

Fixes #119

@gmpinder gmpinder changed the title Add bootc-hooks module for running scripts on bootc events feat(bootc-hooks): Add bootc-hooks module for running scripts on bootc events Nov 21, 2025
@fiftydinar
Copy link
Collaborator

Hello, thanks for the interesting module.

I will test and check how it works, then report back if any of the changes is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

module idea: boot-script

2 participants