From f6d0cbbeb7c043150d603297710325d2e1433a9a Mon Sep 17 00:00:00 2001 From: Joachim Desroches Date: Mon, 7 Feb 2022 14:15:05 +0100 Subject: [PATCH] __systemd_resolved: initial implementation. --- type/__systemd_resolved/gencode-remote | 21 ++++++++++++ type/__systemd_resolved/man.rst | 47 ++++++++++++++++++++++++++ type/__systemd_resolved/manifest | 42 +++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100755 type/__systemd_resolved/gencode-remote create mode 100644 type/__systemd_resolved/man.rst create mode 100755 type/__systemd_resolved/manifest diff --git a/type/__systemd_resolved/gencode-remote b/type/__systemd_resolved/gencode-remote new file mode 100755 index 0000000..115b99b --- /dev/null +++ b/type/__systemd_resolved/gencode-remote @@ -0,0 +1,21 @@ +#!/bin/sh -e +# +# 2022 Joachim Desroches (joachim.desroches@epfl.ch) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +echo "systemctl enable systemd-resolved" diff --git a/type/__systemd_resolved/man.rst b/type/__systemd_resolved/man.rst new file mode 100644 index 0000000..213c725 --- /dev/null +++ b/type/__systemd_resolved/man.rst @@ -0,0 +1,47 @@ +cdist-type__systemd_resolved(7) +=============================== + +NAME +---- +cdist-type__systemd_resolved - Configure system to use systemd-resolved. + + +DESCRIPTION +----------- +*systemd-resolved* is a systemd service that provides network name resolution +to local applications via a D-Bus interface, the resolve NSS service +(nss-resolve(8)), and a local DNS stub listener on 127.0.0.53. + +This type enables and starts this type, and helps with some minimal +configuration. In particular, systemd-resolved has four modes of handling the +`/etc/resolv.conf` file: stub, static, uplink and foreign. See the +systemd-resolved(8) manpage for details. By default, this type uses stub mode: +if you need another one, please provide an implementation in this type! + + +EXAMPLES +-------- + +.. code-block:: sh + + __systemd_resolved + + +SEE ALSO +-------- +`systemd.network`\ (5) +`systemd-resolved`\ (8) +`nss-resolve`\ (8) + + +AUTHORS +------- +Joachim Desroches + + +COPYING +------- +Copyright \(C) 2022 Joachim Desroches. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/type/__systemd_resolved/manifest b/type/__systemd_resolved/manifest new file mode 100755 index 0000000..3b99592 --- /dev/null +++ b/type/__systemd_resolved/manifest @@ -0,0 +1,42 @@ +#!/bin/sh -e +# +# 2022 Joachim Desroches (joachim.desroches@epfl.ch) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +os=$(cat "${__global:?}/explorer/os") + +case "$os" in +'debian') + : + ;; +*) + printf "Your operating system (%s) is currently not supported by __systemd_resolved\n" "$os" >&2 + printf "Please contribute an implementation for it if you can.\n" >&2 + exit 1 + ;; +esac + +__link /etc/resolv.conf \ + --type symbolic \ + --source ../run/systemd/resolve/stub-resolv.conf + +require=__link/etc/resolv.conf \ + __systemd_service systemd-resolved \ + --state running \ + --action restart \ + --if-required