From 10146429f96478f8f243727d7cdb23a3fd9e046d Mon Sep 17 00:00:00 2001 From: binary Date: Wed, 2 Dec 2020 18:53:37 +0100 Subject: Add freebsd rc. --- roles/rc/tasks/rc_freebsd.yml | 16 ++++++++++++++++ roles/rc/tasks/rc_openbsd.yml | 4 ++-- roles/rc/templates/rc_bsd.j2 | 15 +++++++++++++++ roles/rc/templates/rc_freebsd.j2 | 21 +++++++++++++++------ 4 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 roles/rc/tasks/rc_freebsd.yml create mode 100644 roles/rc/templates/rc_bsd.j2 (limited to 'roles/rc') diff --git a/roles/rc/tasks/rc_freebsd.yml b/roles/rc/tasks/rc_freebsd.yml new file mode 100644 index 0000000..472c35e --- /dev/null +++ b/roles/rc/tasks/rc_freebsd.yml @@ -0,0 +1,16 @@ + +# openrc ~~ tasks/main.yml + +--- + +- name: Generate rc script for desired service + template: + src: rc_freebsd.j2 + dest: "{{ rc_bsd_dir }}/{{ rc_name }}" + +- file: + path: "{{ rc_bsd_dir }}/{{ rc_name }}" + owner: "{{ user_root }}" + group: "{{ group_root }}" + mode: 0555 + diff --git a/roles/rc/tasks/rc_openbsd.yml b/roles/rc/tasks/rc_openbsd.yml index 2055de0..ca566ba 100644 --- a/roles/rc/tasks/rc_openbsd.yml +++ b/roles/rc/tasks/rc_openbsd.yml @@ -6,10 +6,10 @@ - name: Generate rc script for desired service template: src: rc_openbsd.j2 - dest: "{{ rc_openbsd_dir }}/{{ rc_name }}" + dest: "{{ rc_bsd_dir }}/{{ rc_name }}" - file: - path: "{{ rc_openbsd_dir }}/{{ rc_name }}" + path: "{{ rc_bsd_dir }}/{{ rc_name }}" owner: "{{ user_root }}" group: "{{ group_root }}" mode: 0555 diff --git a/roles/rc/templates/rc_bsd.j2 b/roles/rc/templates/rc_bsd.j2 new file mode 100644 index 0000000..b64181b --- /dev/null +++ b/roles/rc/templates/rc_bsd.j2 @@ -0,0 +1,15 @@ +{% if ansible_distribution == "OpenBSD" %} +#!/bin/ksh +{% else %} +#!/bin/ksh +{% endif %} +# +# managed by Ansible + +daemon="{{ rc_cmd }}" +daemon_flags="{{ rc_args }}" +daemon_user="{{ rc_user }}" + +. /etc/rc.d/rc.subr + +rc_cmd $1 diff --git a/roles/rc/templates/rc_freebsd.j2 b/roles/rc/templates/rc_freebsd.j2 index 30f1c0a..0c4f86f 100644 --- a/roles/rc/templates/rc_freebsd.j2 +++ b/roles/rc/templates/rc_freebsd.j2 @@ -1,11 +1,20 @@ -#!/bin/ksh +#!/bin/sh # # managed by Ansible -daemon="{{ rc_cmd }}" -daemon_flags="{{ rc_args }}" -daemon_user="{{ rc_user }}" +# PROVIDE: wireguard -. /etc/rc.d/rc.subr +. /etc/rc.subr -rc_cmd $1 +name="{{ rc_name | lower }}" +rcvar="${name}_enable" + +start_cmd="{{ rc_cmd }} {{ rc_args }}" + +{{ rc_name | lower }}_start() +{ + echo "Staring ${name} ..." + $(start_cmd) +} + +load_rc_config $name -- cgit v1.2.3