From 81164eb0c64328041e608b4024e3d306841f74d6 Mon Sep 17 00:00:00 2001 From: Simon Walter Date: Tue, 7 May 2024 22:26:36 +0200 Subject: [PATCH] email_alias new type --- .../type/__email_alias/explorer/newaliases | 21 +++++++++++ cdist/conf/type/__email_alias/gencode-remote | 23 ++++++++++++ cdist/conf/type/__email_alias/manifest | 37 +++++++++++++++++++ .../type/__email_alias/parameter/required | 1 + 4 files changed, 82 insertions(+) create mode 100755 cdist/conf/type/__email_alias/explorer/newaliases create mode 100755 cdist/conf/type/__email_alias/gencode-remote create mode 100755 cdist/conf/type/__email_alias/manifest create mode 100644 cdist/conf/type/__email_alias/parameter/required diff --git a/cdist/conf/type/__email_alias/explorer/newaliases b/cdist/conf/type/__email_alias/explorer/newaliases new file mode 100755 index 00000000..28ed5952 --- /dev/null +++ b/cdist/conf/type/__email_alias/explorer/newaliases @@ -0,0 +1,21 @@ +#!/bin/sh +# +# 2023 Simon Walter (simon@the-oposite-of-implicit.techonolgy) +# +# 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 . +# + +if $(command -v newaliases); then echo yes; else echo no; fi diff --git a/cdist/conf/type/__email_alias/gencode-remote b/cdist/conf/type/__email_alias/gencode-remote new file mode 100755 index 00000000..624e0344 --- /dev/null +++ b/cdist/conf/type/__email_alias/gencode-remote @@ -0,0 +1,23 @@ +#!/bin/sh +# +# 2023 Simon Walter (simon at explicit dot technology) +# +# 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 . +# + +if [ "$(cat "$__object/explorer/newaliases")" = "yes" ]; then + echo "newaliases" +fi diff --git a/cdist/conf/type/__email_alias/manifest b/cdist/conf/type/__email_alias/manifest new file mode 100755 index 00000000..fbcf1114 --- /dev/null +++ b/cdist/conf/type/__email_alias/manifest @@ -0,0 +1,37 @@ +#!/bin/sh +# +# 2023 Simon Walter (simon at explicit dot technology) +# +# 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|ubuntu|devuan) + if [ "$(cat "$__object/explorer/newaliases")" = "yes" ]; then + for="$(cat "$__object/parameter/for")" + __key_value $__object_id --file /etc/aliases --delimiter ":" --value "$for" + else + echo "'newaliases' command not found. Please install the 'default-mta'\ + pkg or otherwise provide the 'newaliases' command." >&2 + exit 1 + fi + ;; + *) + echo "Don't know how to manage aliases on: $os. Please contribute." >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__email_alias/parameter/required b/cdist/conf/type/__email_alias/parameter/required new file mode 100644 index 00000000..304bf8e8 --- /dev/null +++ b/cdist/conf/type/__email_alias/parameter/required @@ -0,0 +1 @@ +for