Show notes: The agent is in - Episode 22 - Hackathon: Termux Services

Posted by Nick Anderson
February 23, 2023

Have a burning desire to run sshd or another service on your VR headset?

Cody, Craig and Nick do time-boxed live hackathon working on developing CFEngine services promise type support for Termux. Watch Nick and Craig race to implement basic services support before the timer buzzes.


The video recording is available on YouTube:

At the end of every webinar, we stop the recording for a nice and relaxed, off-the-record chat with attendees. Join the next webinar to not miss this discussion.

Termux services policy

Here is the snippet of policy developed during the episode.

bundle agent __main__
        service_policy => "stopped",
        service_method => termux_services;


bundle agent termux_services(service, policy)
# @brief Manage service state in Termux
# @param service The name of the service to manage, e.g. `sshd`
# @param policy The desired state of the service (`running`|`stopped`)
        expression => regcmp(
          execresult("sv status ${service}", "useshell")

        expression => regcmp(
          execresult("sv status ${service}", "useshell")

        expression => strcmp("${policy}", "running");
        expression => strcmp("${policy}", "stopped");

      "sv up ${service}"
        contain => useshell;

      "sv down ${service}"
        contain => useshell;

body service_method termux_services
  service_bundle => default:termux_services(
    ${this.promiser}, ${this.service_policy});

body contain useshell
  useshell => "useshell";

Note: Further work remains, notably “enabling” the service if it’s not yet been enabled and integrating it into the Masterfiles Policy Framework and the standard_services bundle.