diff --git a/cdist/conf/type/__postfix/man.text b/cdist/conf/type/__postfix/man.text new file mode 100644 index 00000000..1a91723a --- /dev/null +++ b/cdist/conf/type/__postfix/man.text @@ -0,0 +1,42 @@ +cdist-type__postfix(7) +====================== +Steven Armstrong + + +NAME +---- +cdist-type__postfix - install postfix + + +DESCRIPTION +----------- +This space intentionally left blank. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__postfix +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__postfix/manifest b/cdist/conf/type/__postfix/manifest new file mode 100755 index 00000000..2dc70ce2 --- /dev/null +++ b/cdist/conf/type/__postfix/manifest @@ -0,0 +1,33 @@ +#!/bin/sh +# +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 + ubuntu|debian|archlinux) + __package postfix --state present + ;; + *) + echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 + echo "Please contribute an implementation for it if you can." >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__postfix/singleton b/cdist/conf/type/__postfix/singleton new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__postfix_master/explorer/entry b/cdist/conf/type/__postfix_master/explorer/entry new file mode 100755 index 00000000..9d6b1514 --- /dev/null +++ b/cdist/conf/type/__postfix_master/explorer/entry @@ -0,0 +1,39 @@ +#!/bin/sh +# +# 2011 - 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 . +# + +config="/etc/postfix/master.cf" + +# no master.cf, nothing we could do +[ -f "$config" ] || exit 0 + +# NOTE: keep variables in sync in manifest,explorer,gencode-* +prefix="#cdist:$__object_name" +suffix="#/cdist:$__object_name" +awk -v prefix="$prefix" -v suffix="$suffix" '{ + if (index($0,prefix)) { + triggered=1 + } + if (triggered) { + if (index($0,suffix)) { + triggered=0 + } + print + } +}' "$config" diff --git a/cdist/conf/type/__postfix_master/gencode-remote b/cdist/conf/type/__postfix_master/gencode-remote new file mode 100755 index 00000000..a4d6462b --- /dev/null +++ b/cdist/conf/type/__postfix_master/gencode-remote @@ -0,0 +1,76 @@ +#!/bin/sh +# +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 . +# + +config="/etc/postfix/master.cf" +entry="$__object/files/entry" +state_should="$(cat "$__object/parameter/state")" +if [ ! -s "$__object/explorer/entry" ]; then + state_is='absent' +else + state_is=$(diff -q "$entry" "$__object/explorer/entry" >/dev/null \ + && echo present \ + || echo changed + ) +fi + +if [ "$state_should" = "$state_is" ]; then + # Nothing to do, move along + exit 0 +fi + + +remove_entry() { + # NOTE: keep variables in sync in manifest/explorer/gencode-* + prefix="#cdist:$__object_name" + suffix="#/cdist:$__object_name" + cat << DONE +tmpfile=\$(mktemp ${config}.cdist.XXXXXXXXXX) +awk -v prefix="$prefix" -v suffix="$suffix" ' +{ + if (index(\$0,prefix)) { + triggered=1 + } + if (triggered) { + if (index(\$0,suffix)) { + triggered=0 + } + } else { + print + } +}' "$config" > "\$tmpfile" +mv -f "\$tmpfile" "$config" +DONE +} + +case "$state_should" in + present) + if [ "$state_is" = "changed" ]; then + remove_entry + fi + cat << DONE +cat >> "$config" << ${__type##*/}_DONE +$(cat "$entry") +${__type##*/}_DONE +DONE + ;; + absent) + remove_entry + ;; +esac diff --git a/cdist/conf/type/__postfix_master/man.text b/cdist/conf/type/__postfix_master/man.text new file mode 100644 index 00000000..0ec78752 --- /dev/null +++ b/cdist/conf/type/__postfix_master/man.text @@ -0,0 +1,73 @@ +cdist-type__postfix_master(7) +============================= +Steven Armstrong + + +NAME +---- +cdist-type__postfix_master - configure postfix master.cf + + +DESCRIPTION +----------- +See master(5) for more information. + + +REQUIRED PARAMETERS +------------------- +type:: + See master(5) +command:: + See master(5) + + +BOOLEAN PARAMETERS +------------------ +noreload:: + don't reload postfix after changes + + +OPTIONAL PARAMETERS +------------------- +state:: + present or absent, defaults to present +service:: +private:: +unpriv:: +chroot:: +wakeup:: +maxproc:: +option:: + Pass an option to a service. Same as using -o in master.cf. + Can be specified multiple times. +comment:: + a textual comment to add with the master.cf entry + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__postfix_master smtp --type inet --command smtpd + +__postfix_master smtp --type inet --chroot y --command smtpd \ + --option smtpd_enforce_tls=yes \ + --option smtpd_sasl_auth_enable=yes \ + --option smtpd_client_restrictions=permit_sasl_authenticated,reject + +__postfix_master submission --type inet --command smtpd \ + --comment "Run alternative smtp on submission port" +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- master(5) + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). + diff --git a/cdist/conf/type/__postfix_master/manifest b/cdist/conf/type/__postfix_master/manifest new file mode 100755 index 00000000..1642e91b --- /dev/null +++ b/cdist/conf/type/__postfix_master/manifest @@ -0,0 +1,81 @@ +#!/bin/sh +# +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 + ubuntu|debian|archlinux) + : + ;; + *) + echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 + echo "Please contribute an implementation for it if you can." >&2 + exit 1 + ;; +esac + + +# Default to object_id +service="$(cat "$__object/parameter/service" 2>/dev/null || echo "$__object_id")" +state="$(cat "$__object/parameter/state")" + +# NOTE: keep variables in sync in manifest,explorer,gencode-* +prefix="#cdist:$__object_name" +suffix="#/cdist:$__object_name" + +# Generate entry for inclusion in master.cf +mkdir "$__object/files" +entry="$__object/files/entry" +( + echo "$prefix" + if [ -f "$__object/parameter/comment" ]; then + echo "# $(cat "$__object/parameter/comment")" + fi + printf "%s " "$service" + printf "%s " "$type" + for parameter in type private unpriv chroot wakeup maxproc; do + printf "%s " "$(cat "$__object/parameter/$parameter")" + done + command="$(cat "$__object/parameter/command")" + # ensure we have a trailing newline + echo "$command" + options="$(cat "$__object/parameter/option" 2>/dev/null || true)" + for option in $options; do + echo " -o $option" + done + echo "$suffix" +) > "$entry" + +# Reload postfix after changes +if [ ! -f "$__object/parameter/noreload" ]; then + state_should="$(cat "$__object/parameter/state")" + if [ ! -s "$__object/explorer/entry" ]; then + state_is='absent' + else + state_is=$(diff -q "$entry" "$__object/explorer/entry" >/dev/null \ + && echo present \ + || echo changed + ) + fi + if [ "$state_is" != "$state_should" ]; then + require="$__object_name" __postfix_reload + fi +fi diff --git a/cdist/conf/type/__postfix_master/parameter/boolean b/cdist/conf/type/__postfix_master/parameter/boolean new file mode 100644 index 00000000..862edc87 --- /dev/null +++ b/cdist/conf/type/__postfix_master/parameter/boolean @@ -0,0 +1 @@ +noreload diff --git a/cdist/conf/type/__postfix_master/parameter/default/chroot b/cdist/conf/type/__postfix_master/parameter/default/chroot new file mode 100644 index 00000000..39cdd0de --- /dev/null +++ b/cdist/conf/type/__postfix_master/parameter/default/chroot @@ -0,0 +1 @@ +- diff --git a/cdist/conf/type/__postfix_master/parameter/default/maxproc b/cdist/conf/type/__postfix_master/parameter/default/maxproc new file mode 100644 index 00000000..39cdd0de --- /dev/null +++ b/cdist/conf/type/__postfix_master/parameter/default/maxproc @@ -0,0 +1 @@ +- diff --git a/cdist/conf/type/__postfix_master/parameter/default/private b/cdist/conf/type/__postfix_master/parameter/default/private new file mode 100644 index 00000000..39cdd0de --- /dev/null +++ b/cdist/conf/type/__postfix_master/parameter/default/private @@ -0,0 +1 @@ +- diff --git a/cdist/conf/type/__postfix_master/parameter/default/state b/cdist/conf/type/__postfix_master/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__postfix_master/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__postfix_master/parameter/default/unpriv b/cdist/conf/type/__postfix_master/parameter/default/unpriv new file mode 100644 index 00000000..39cdd0de --- /dev/null +++ b/cdist/conf/type/__postfix_master/parameter/default/unpriv @@ -0,0 +1 @@ +- diff --git a/cdist/conf/type/__postfix_master/parameter/default/wakeup b/cdist/conf/type/__postfix_master/parameter/default/wakeup new file mode 100644 index 00000000..39cdd0de --- /dev/null +++ b/cdist/conf/type/__postfix_master/parameter/default/wakeup @@ -0,0 +1 @@ +- diff --git a/cdist/conf/type/__postfix_master/parameter/optional b/cdist/conf/type/__postfix_master/parameter/optional new file mode 100644 index 00000000..792b42c5 --- /dev/null +++ b/cdist/conf/type/__postfix_master/parameter/optional @@ -0,0 +1,9 @@ +service +private +unpriv +chroot +wakeup +maxproc +option +comment +state diff --git a/cdist/conf/type/__postfix_master/parameter/required b/cdist/conf/type/__postfix_master/parameter/required new file mode 100644 index 00000000..24c14146 --- /dev/null +++ b/cdist/conf/type/__postfix_master/parameter/required @@ -0,0 +1,2 @@ +type +command diff --git a/cdist/conf/type/__postfix_postconf/explorer/value b/cdist/conf/type/__postfix_postconf/explorer/value new file mode 100755 index 00000000..edf48b48 --- /dev/null +++ b/cdist/conf/type/__postfix_postconf/explorer/value @@ -0,0 +1,37 @@ +#!/bin/sh +# +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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=$("$__explorer/os") + +case "$os" in + ubuntu|debian|archlinux) + : + ;; + *) + echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 + echo "Please contribute an implementation for it if you can." >&2 + exit 1 + ;; +esac + +key="$(cat "$__object/parameter/key" 2>/dev/null || echo "$__object_id")" + +postconf -h "$key" diff --git a/cdist/conf/type/__postfix_postconf/gencode-remote b/cdist/conf/type/__postfix_postconf/gencode-remote new file mode 100755 index 00000000..60143590 --- /dev/null +++ b/cdist/conf/type/__postfix_postconf/gencode-remote @@ -0,0 +1,60 @@ +#!/bin/sh +# +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 + ubuntu|debian|archlinux) + : + ;; + *) + echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 + echo "Please contribute an implementation for it if you can." >&2 + exit 1 + ;; +esac + +state_should="$(cat "$__object/parameter/state")" +if [ ! -s "$__object/explorer/value" ]; then + state_is='absent' +else + state_is=$(diff -q "$__object/parameter/value" "$__object/explorer/value" >/dev/null \ + && echo present \ + || echo changed + ) +fi + +if [ "$state_should" = "$state_is" ]; then + # Nothing to do, move along + exit 0 +fi + +key="$(cat "$__object/parameter/key" 2>/dev/null || echo "$__object_id")" +value="$(cat "$__object/parameter/value")" + +case "$state_should" in + absent) + # revert parameter to its default value + echo "postconf -# $key" + ;; + present) + echo "postconf -e '$key=$value'" + ;; +esac diff --git a/cdist/conf/type/__postfix_postconf/man.text b/cdist/conf/type/__postfix_postconf/man.text new file mode 100644 index 00000000..727637b1 --- /dev/null +++ b/cdist/conf/type/__postfix_postconf/man.text @@ -0,0 +1,51 @@ +cdist-type__postfix_postconf(7) +=============================== +Steven Armstrong + + +NAME +---- +cdist-type__postfix_postconf - configure postfix main.cf + + +DESCRIPTION +----------- +See postconf(5) for possible keys and values. + +Note that this type directly runs the postconf executable. +It does not make changes to /etc/postfix/main.cf itself. + + +REQUIRED PARAMETERS +------------------- +value:: + the value for the postfix parameter + + +OPTIONAL PARAMETERS +------------------- +key:: + the name of the parameter. Defaults to __object_id + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__postfix_postconf mydomain --value somedomain.com + +__postfix_postconf bind-to-special-ip --key smtp_bind_address --value 127.0.0.5 + +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- postconf(5) + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__postfix_postconf/parameter/default/state b/cdist/conf/type/__postfix_postconf/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__postfix_postconf/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__postfix_postconf/parameter/optional b/cdist/conf/type/__postfix_postconf/parameter/optional new file mode 100644 index 00000000..6ada755a --- /dev/null +++ b/cdist/conf/type/__postfix_postconf/parameter/optional @@ -0,0 +1,2 @@ +key +state diff --git a/cdist/conf/type/__postfix_postconf/parameter/required b/cdist/conf/type/__postfix_postconf/parameter/required new file mode 100644 index 00000000..6d4e1507 --- /dev/null +++ b/cdist/conf/type/__postfix_postconf/parameter/required @@ -0,0 +1 @@ +value diff --git a/cdist/conf/type/__postfix_postmap/gencode-remote b/cdist/conf/type/__postfix_postmap/gencode-remote new file mode 100755 index 00000000..1b370001 --- /dev/null +++ b/cdist/conf/type/__postfix_postmap/gencode-remote @@ -0,0 +1,21 @@ +#!/bin/sh +# +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 "postmap /$__object_id" diff --git a/cdist/conf/type/__postfix_postmap/man.text b/cdist/conf/type/__postfix_postmap/man.text new file mode 100644 index 00000000..37060d04 --- /dev/null +++ b/cdist/conf/type/__postfix_postmap/man.text @@ -0,0 +1,42 @@ +cdist-type__postfix_postmap(7) +============================== +Steven Armstrong + + +NAME +---- +cdist-type__postfix_postmap - run postmap on the given file + + +DESCRIPTION +----------- +This space intentionally left blank. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__postfix_postmap /etc/postfix/generic +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__postfix_reload/gencode-remote b/cdist/conf/type/__postfix_reload/gencode-remote new file mode 100755 index 00000000..5822f1e3 --- /dev/null +++ b/cdist/conf/type/__postfix_reload/gencode-remote @@ -0,0 +1,33 @@ +#!/bin/sh +# +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 + ubuntu|debian|archlinux) + echo "postfix reload" + ;; + *) + echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 + echo "Please contribute an implementation for it if you can." >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__postfix_reload/man.text b/cdist/conf/type/__postfix_reload/man.text new file mode 100644 index 00000000..c63356b5 --- /dev/null +++ b/cdist/conf/type/__postfix_reload/man.text @@ -0,0 +1,42 @@ +cdist-type__postfix_reload(7) +============================= +Steven Armstrong + + +NAME +---- +cdist-type__postfix_reload - tell postfix to reload its configuration + + +DESCRIPTION +----------- +This space intentionally left blank. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__postfix_reload +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__postfix_reload/singleton b/cdist/conf/type/__postfix_reload/singleton new file mode 100644 index 00000000..e69de29b