Current section

Files

Jump to
pakman lib pakman bootstrap templates initd.eex
Raw

lib/pakman/bootstrap/templates/initd.eex

#!/sbin/openrc-run
# shellcheck shell=bash
name="<%= configuration["name"] %>"
# shellcheck disable=2034
description="<%= configuration["name"] %> service"
<% commands = configuration["commands"] || [] %>
# shellcheck disable=2034
extra_commands="<%= Enum.join(Enum.map(commands, fn command -> command["name"] end), " ") %>"
# shellcheck disable=2034
supervisor="s6"
# shellcheck disable=2034
s6_service_path="${RC_SVCDIR}/s6-scan/<%= configuration["name"] %>"
<%= Enum.map(commands, fn command -> %>
<%= command["name"] %>() {
<% rendered_command = if command["path"],
do: "#{command["path"]}/#{command["binary"]}",
else: "/var/lib/#{configuration["name"]}/bin/#{command["binary"]}" %>
export HOME=/var/lib/<%= configuration["name"] %>
cd /var/lib/<%= configuration["name"] %>
command=<%= rendered_command %>
/var/lib/<%= configuration["name"] %>/bin/env-exec "${command} <%= command["call"] %>"
}
<% end) %>
depend() {
need net s6-svscan
}
start_pre() {
if [ ! -L "${RC_SVCDIR}/s6-scan/<%= configuration["name"] %>" ]; then
echo "----- Updating Service files -----"
ln -s "/var/lib/<%= configuration["name"] %>/service" "${RC_SVCDIR}/s6-scan/<%= configuration["name"] %>"
fi
}