aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-05-29 17:41:13 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-05-30 10:05:00 -0700
commitd9ac9152b59af5ba7c5696fb62db05b6d1b3425d (patch)
treea76e6ef2020ac53f6b88d2349731e6084c3cc70f
parent7971f2387a64d2c366eba98243faddaaf9946557 (diff)
downloadconsfigurator-d9ac9152b59af5ba7c5696fb62db05b6d1b3425d.tar.gz
add NETWORK:STATIC
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--consfigurator.asd1
-rw-r--r--src/package.lisp6
-rw-r--r--src/property/network.lisp37
3 files changed, 44 insertions, 0 deletions
diff --git a/consfigurator.asd b/consfigurator.asd
index a586cf9..28e9a04 100644
--- a/consfigurator.asd
+++ b/consfigurator.asd
@@ -50,6 +50,7 @@
(:file "src/property/grub")
(:file "src/property/u-boot")
(:file "src/property/hostname")
+ (:file "src/property/network")
(:file "src/property/libvirt")
(:file "src/connection/shell-wrap")
(:file "src/connection/fork")
diff --git a/src/package.lisp b/src/package.lisp
index db916a2..562acc9 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -549,6 +549,12 @@
#:mailname-configured
#:search-configured))
+(defpackage :consfigurator.property.network
+ (:use #:cl #:consfigurator)
+ (:local-nicknames (#:os #:consfigurator.property.os)
+ (#:file #:consfigurator.property.file))
+ (:export #:static))
+
(defpackage :consfigurator.property.libvirt
(:use #:cl #:alexandria #:consfigurator)
(:local-nicknames (#:os #:consfigurator.property.os)
diff --git a/src/property/network.lisp b/src/property/network.lisp
new file mode 100644
index 0000000..59d34b0
--- /dev/null
+++ b/src/property/network.lisp
@@ -0,0 +1,37 @@
+;;; 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.network)
+(named-readtables:in-readtable :consfigurator)
+
+(defprop static :posix (interface address &optional gateway &rest options)
+ "Configures an interface with a static IP address.
+OPTIONS is a list of even length of alternating keys and values."
+ (:desc #?"Static interface ${interface} configured")
+ (:hostattrs (os:required 'os:debianlike))
+ (:apply
+ (when gateway
+ (setq options (list* "gateway" gateway options)))
+ (setq options (list* "address" address options))
+ (file:has-content
+ (merge-pathnames (string->filename interface)
+ #P"/etc/network/interfaces.d/")
+ (list* (strcat "auto " interface)
+ (format nil "iface ~A ~A static"
+ interface (if (find #\. address) "inet" "inet6"))
+ (loop for (k v) on options by #'cddr
+ collect (format nil " ~A ~A" k v))))))