<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
  Needs the "littlefedi" project for the descriptor limit:
    projadd -U littlefedi \
      -K 'process.max-file-descriptor=(privileged,65536,deny)' littlefedi
-->
<service_bundle type="manifest" name="littlefedi">
  <service name="site/littlefedi" type="service" version="1">

    <create_default_instance enabled="false"/>
    <single_instance/>

    <dependency name="network" grouping="require_all" restart_on="error"
        type="service">
      <service_fmri value="svc:/milestone/network:default"/>
    </dependency>

    <dependency name="filesystem-local" grouping="require_all"
        restart_on="none" type="service">
      <service_fmri value="svc:/system/filesystem/local:default"/>
    </dependency>

    <exec_method type="method" name="start" timeout_seconds="60"
        exec='/bin/sh -c "umask 077; if [ -r /etc/littlefedi/littlefedi.env ]; then set -a; . /etc/littlefedi/littlefedi.env; set +a; fi; exec /usr/local/bin/littlefedi --config /etc/littlefedi/littlefedi.toml"'>
      <method_context working_directory="/var/littlefedi" project="littlefedi">
        <method_credential user="littlefedi" group="littlefedi"
            privileges="basic,!proc_info,!proc_session,!file_link_any"/>
      </method_context>
    </exec_method>

    <exec_method type="method" name="stop" timeout_seconds="45"
        exec=":kill"/>

    <property_group name="startd" type="framework">
      <propval name="duration" type="astring" value="child"/>
      <propval name="ignore_error" type="astring" value="core,signal"/>
    </property_group>

    <stability value="Evolving"/>

    <template>
      <common_name>
        <loctext xml:lang="C">littleFedi ActivityPub server</loctext>
      </common_name>
      <documentation>
        <doc_link name="littlefedi"
            uri="https://brew.bsd.cafe/littlecomputerpeople/littlefedi"/>
      </documentation>
    </template>

  </service>
</service_bundle>
