services: fail2ban: 'stop' returns #f when the dameon is stopped.

* gnu/services/security.scm (fail2ban-shepherd-service): Change
FAIL2BAN-ACTION to return an 'invoke' gexp.
Adjust the shepherd 'start' and 'stop' fields accordingly.  Have 'stop'
return #f on success.
This commit is contained in:
Ludovic Courtès 2022-12-06 17:05:34 +01:00
parent fe563a87ad
commit e45c83c397
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -356,13 +356,12 @@ (define (fail2ban-shepherd-service config)
(config-dir (file-append (config->fail2ban-etc-directory config) (config-dir (file-append (config->fail2ban-etc-directory config)
"/etc/fail2ban")) "/etc/fail2ban"))
(fail2ban-action (lambda args (fail2ban-action (lambda args
#~(lambda _ #~(invoke #$fail2ban-server
(invoke #$fail2ban-server "-c" #$config-dir
"-c" #$config-dir "-p" #$pid-file
"-p" #$pid-file "-s" #$socket-file
"-s" #$socket-file "-b"
"-b" #$@args))))
#$@args)))))
;; TODO: Add 'reload' action. ;; TODO: Add 'reload' action.
(list (shepherd-service (list (shepherd-service
@ -371,8 +370,11 @@ (define (fail2ban-shepherd-service config)
(requirement '(user-processes)) (requirement '(user-processes))
(modules `((ice-9 match) (modules `((ice-9 match)
,@%default-modules)) ,@%default-modules))
(start (fail2ban-action "start")) (start #~(lambda ()
(stop (fail2ban-action "stop"))))))) #$(fail2ban-action "start")))
(stop #~(lambda (_)
#$(fail2ban-action "stop")
#f))))))) ;successfully stopped
(define fail2ban-service-type (define fail2ban-service-type
(service-type (name 'fail2ban) (service-type (name 'fail2ban)