mirror of
git://git.savannah.gnu.org/guix/maintenance.git
synced 2023-12-14 03:33:04 +01:00
hydra: services: Add 'goggles-bot' service.
* hydra/modules/sysadmin/services.scm (<goggles-bot-configuration>): New record type. (goggles-bot-program): New variable. (goggles-bot-shepherd-services, goggles-bot-activation): New procedures. (%goggles-bot-accounts, %goggles-bot-log-rotations) (goggles-bot-service-type): New variables. * hydra/bayfront.scm (services): Use it.
This commit is contained in:
parent
2b6e952511
commit
8c365f6904
|
@ -1053,7 +1053,13 @@ add_header Content-Type text/plain;")))
|
|||
(channels #$%hpcguix-web-channels)))))))
|
||||
|
||||
(service certbot-service-type %certbot-configuration)
|
||||
|
||||
(service goggles-service-type)
|
||||
(service goggles-bot-service-type
|
||||
(goggles-bot-configuration
|
||||
(channels '("#guix" "#guix-hpc" "#guile"
|
||||
"#guile-steel" "#hurd"
|
||||
"#bootstrappable"))))
|
||||
|
||||
(service mcron-service-type
|
||||
(mcron-configuration
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; GNU Guix system administration tools.
|
||||
;;;
|
||||
;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021, 2022 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2016-2022 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2017, 2018, 2020 Ricardo Wurmus <rekado@elephly.net>
|
||||
;;;
|
||||
;;; This program is free software: you can redistribute it and/or modify
|
||||
|
@ -23,6 +23,7 @@
|
|||
#:use-module (guix records)
|
||||
#:use-module ((guix self) #:select (make-config.scm))
|
||||
#:use-module ((guix store) #:select (%store-prefix))
|
||||
#:use-module (guix least-authority)
|
||||
#:use-module (gnu services)
|
||||
#:use-module (gnu services admin)
|
||||
#:use-module (gnu services base)
|
||||
|
@ -32,6 +33,8 @@
|
|||
#:use-module (gnu services ssh)
|
||||
#:use-module (gnu services vpn)
|
||||
#:use-module (gnu services web)
|
||||
#:use-module ((gnu system file-systems) #:select (file-system-mapping))
|
||||
#:use-module ((gnu build linux-container) #:select (%namespaces))
|
||||
#:use-module (gnu system shadow)
|
||||
#:use-module (guix packages)
|
||||
#:use-module (gnu packages)
|
||||
|
@ -57,6 +60,8 @@
|
|||
disarchive-configuration
|
||||
disarchive-service-type
|
||||
goggles-service-type
|
||||
goggles-bot-service-type
|
||||
goggles-bot-configuration
|
||||
crash-dump-service-type))
|
||||
|
||||
(define not-config?
|
||||
|
@ -748,6 +753,101 @@ to a selected directory.")
|
|||
(default-value goggles)
|
||||
(description "Run Goggles, the IRC log web interface.")))
|
||||
|
||||
|
||||
;;;
|
||||
;;; Logging IRC channels with goggles-bot.
|
||||
;;;
|
||||
|
||||
(define-record-type* <goggles-bot-configuration>
|
||||
goggles-bot-configuration make-goggles-bot-configuration
|
||||
goggles-bot-configuration?
|
||||
(channels goggles-bot-configuration-channels
|
||||
(default '("#guix")))
|
||||
(log-directory goggles-bot-configuration-log-directory
|
||||
(default %goggles-irc-log-directory)))
|
||||
|
||||
(define goggles-bot-program
|
||||
(with-extensions (list guile-irc guile-gnutls)
|
||||
(program-file "goggles-bot"
|
||||
#~(load #$(local-file "../../goggles-bot.scm")))))
|
||||
|
||||
(define (goggles-bot-shepherd-services config)
|
||||
(define channels
|
||||
(goggles-bot-configuration-channels config))
|
||||
|
||||
(define log-directory
|
||||
(goggles-bot-configuration-log-directory config))
|
||||
|
||||
(define program/wrapped
|
||||
(least-authority-wrapper
|
||||
goggles-bot-program
|
||||
#:name "goggles-bot"
|
||||
#:mappings (list (file-system-mapping
|
||||
(source log-directory)
|
||||
(target log-directory)
|
||||
(writable? #t)))
|
||||
#:namespaces (delq 'net %namespaces)))
|
||||
|
||||
(list (shepherd-service
|
||||
(provision '(goggles-bot))
|
||||
(requirement '(user-processes networking))
|
||||
(start #~(make-forkexec-constructor
|
||||
(list #$program/wrapped
|
||||
#$(string-append "--directory=" log-directory)
|
||||
#$@(map (lambda (channel)
|
||||
(string-append "--channel=" channel))
|
||||
channels))
|
||||
#:user "goggles-bot" #:group "goggles-bot"
|
||||
#:log-file "/var/log/goggles-bot.log"
|
||||
#:environment-variables
|
||||
(list (string-append "GUIX_LOCPATH=" #$glibc-utf8-locales
|
||||
"/lib/locale")
|
||||
"LC_ALL=en_US.utf8")))
|
||||
(stop #~(make-kill-destructor))
|
||||
(documentation "Run Goggles-Bot, the IRC logging robot."))))
|
||||
|
||||
(define %goggles-bot-accounts
|
||||
(list (user-account
|
||||
(name "goggles-bot")
|
||||
(group "goggles-bot")
|
||||
(home-directory "/var/empty")
|
||||
(create-home-directory? #f)
|
||||
(shell (file-append shadow "/sbin/nologin"))
|
||||
(comment "The Goggles IRC logging robot.")
|
||||
(system? #t))
|
||||
(user-group
|
||||
(name "goggles-bot")
|
||||
(system? #t))))
|
||||
|
||||
(define %goggles-bot-log-rotations
|
||||
(list (log-rotation
|
||||
(files (list "/var/log/goggles-bot.log")))))
|
||||
|
||||
(define (goggles-bot-activation config)
|
||||
(let ((log-directory (goggles-bot-configuration-log-directory config)))
|
||||
(with-imported-modules '((guix build utils))
|
||||
#~(begin
|
||||
(use-modules (guix build utils))
|
||||
(let ((user (getpwnam "goggles-bot")))
|
||||
(mkdir-p #$log-directory)
|
||||
(chown #$log-directory
|
||||
(passwd:uid user) (passwd:gid user))
|
||||
(chmod #$log-directory #o755))))))
|
||||
|
||||
(define goggles-bot-service-type
|
||||
(service-type
|
||||
(name 'goggles-bot)
|
||||
(extensions (list (service-extension account-service-type
|
||||
(const %goggles-bot-accounts))
|
||||
(service-extension activation-service-type
|
||||
goggles-bot-activation)
|
||||
(service-extension rottlog-service-type
|
||||
(const %goggles-bot-log-rotations))
|
||||
(service-extension shepherd-root-service-type
|
||||
goggles-bot-shepherd-services)))
|
||||
(default-value (goggles-bot-configuration))
|
||||
(description "Run Goggles-Bot, the IRC logging robot.")))
|
||||
|
||||
|
||||
;;;
|
||||
;;; Crash-dump.
|
||||
|
|
Loading…
Reference in a new issue