#!/usr/bin/env ssm

# One tinc network per service instance.
#
# The service name is expected to look like "tinc-<network>", e.g.
# "tinc-vpn" for the network configured in /etc/tinc/vpn.

var tinc_network = "${service_name#tinc-}"

service_respawn = on-failure
service_command = /usr/bin/tincd -D -n "$tinc_network"

pre_start() {
    if [[ ! -d "/etc/tinc/$tinc_network" ]]; then
        err "tinc network '$tinc_network' has no config directory"
        return 17
    fi
}
