aboutsummaryrefslogtreecommitdiff
path: root/src/property/postfix.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-06-18 09:21:19 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-06-18 09:23:04 -0700
commit92f58e96e1edc9bc3944cb87d0ee5d3a94157824 (patch)
treedfb90964a44dc92711ebbc40237ad8e6127d7316 /src/property/postfix.lisp
parent5e304508e8708e7085c0dd5aad2f5f6f0ed5fc7b (diff)
downloadconsfigurator-92f58e96e1edc9bc3944cb87d0ee5d3a94157824.tar.gz
add PROPAPPARGS and some Postfix properties
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/postfix.lisp')
-rw-r--r--src/property/postfix.lisp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/property/postfix.lisp b/src/property/postfix.lisp
new file mode 100644
index 0000000..0121a2f
--- /dev/null
+++ b/src/property/postfix.lisp
@@ -0,0 +1,55 @@
+;;; Consfigurator -- Lisp declarative configuration management system
+
+;;; Copyright (C) 2021 Sean Whitton <spwhitton@spwhitton.name>
+
+;;; This file 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, or (at your option)
+;;; any later version.
+
+;;; This file 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+(in-package :consfigurator.property.postfix)
+(named-readtables:in-readtable :consfigurator)
+
+(defproplist installed :posix ()
+ (:desc "Postfix installed")
+ (os:etypecase
+ (debianlike (apt:installed "postfix"))))
+
+(defproplist reloaded :posix ()
+ (:desc "Postfix reloaded")
+ (service:reloaded "postfix"))
+
+(defprop main-configured :posix (&rest pairs)
+ "Set key--value pairs in /etc/postfix/main.cf."
+ (:desc (format nil "Postfix main.cf configured ~{~A=~A~^, ~}" pairs))
+ (:apply
+ (or (eql :no-change
+ (apply #'file:contains-conf-equals "/etc/postfix/main.cf" pairs))
+ (reloaded))))
+
+(define-function-property-combinator mapped-file
+ (propapp &optional (file (car (propappargs propapp))))
+ "Apply PROPAPP, and if it makes a change, run postmap(1) on FILE, which
+defaults to the first argument to propapp."
+ (:retprop :type (propapptype propapp)
+ :desc (get (car propapp) 'desc)
+ :check (get (car propapp) 'check)
+ :hostattrs (get (car propapp) 'hostattrs)
+ :apply (lambda (&rest args)
+ (when-let ((f (get (car propapp) 'papply)))
+ (or (eql :no-change (apply f args))
+ (mrun "postmap" file))))
+ :unapply
+ (lambda (&rest args)
+ (when-let ((f (get (car propapp) 'punapply)))
+ (apply f args))
+ (file:does-not-exist (strcat (unix-namestring file) ".db")))
+ :args (cdr propapp)))