From 4e511fcfce2c005c615df673836c553f96550b35 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Fri, 1 Jan 2021 13:02:11 +0300 Subject: services: Add keepalived service. * gnu/services/networking.scm (): New record. (keepalived-shepherd-service): New procedure. (keepalived-service-type): New variable. * doc/guix.texi (Networking Services): Document this. --- gnu/services/networking.scm | 47 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'gnu/services') diff --git a/gnu/services/networking.scm b/gnu/services/networking.scm index 9ec0f6a9ca..44754781c1 100644 --- a/gnu/services/networking.scm +++ b/gnu/services/networking.scm @@ -14,6 +14,7 @@ ;;; Copyright © 2019 Sou Bunnbu ;;; Copyright © 2019 Alex Griffin ;;; Copyright © 2020 Brice Waegeneire +;;; Copyright © 2021 Oleg Pykhalov ;;; ;;; This file is part of GNU Guix. ;;; @@ -42,6 +43,7 @@ #:use-module (gnu packages admin) #:use-module (gnu packages base) #:use-module (gnu packages bash) + #:use-module (gnu packages cluster) #:use-module (gnu packages connman) #:use-module (gnu packages freedesktop) #:use-module (gnu packages linux) @@ -192,7 +194,11 @@ yggdrasil-configuration-log-level yggdrasil-configuration-log-to yggdrasil-configuration-json-config - yggdrasil-configuration-package)) + yggdrasil-configuration-package + + keepalived-configuration + keepalived-configuration? + keepalived-service-type)) ;;; Commentary: ;;; @@ -1865,4 +1871,43 @@ See yggdrasil -genconf for config options.") (service-extension profile-service-type (compose list yggdrasil-configuration-package)))))) + +;;; +;;; Keepalived +;;; + +(define-record-type* + keepalived-configuration make-keepalived-configuration + keepalived-configuration? + (keepalived keepalived-configuration-keepalived ; + (default keepalived)) + (config-file keepalived-configuration-config-file ;file-like + (default #f))) + +(define keepalived-shepherd-service + (match-lambda + (($ keepalived config-file) + (list + (shepherd-service + (provision '(keepalived)) + (documentation "Run keepalived.") + (requirement '(loopback)) + (start #~(make-forkexec-constructor + (list (string-append #$keepalived "/sbin/keepalived") + "--dont-fork" "--log-console" "--log-detail" + "--pid=/var/run/keepalived.pid" + (string-append "--use-file=" #$config-file)) + #:pid-file "/var/run/keepalived.pid" + #:log-file "/var/log/keepalived.log")) + (respawn? #f) + (stop #~(make-kill-destructor))))))) + +(define keepalived-service-type + (service-type (name 'keepalived) + (extensions (list (service-extension shepherd-root-service-type + keepalived-shepherd-service))) + (description + "Run @uref{https://www.keepalived.org/, Keepalived} +routing software."))) + ;;; networking.scm ends here -- cgit v1.2.3