2021-12-01 14:08:45 +01:00
|
|
|
(define-module (glicid services rc-local)
|
|
|
|
#:use-module (gnu services)
|
|
|
|
#:use-module (gnu services shepherd)
|
|
|
|
#:use-module (guix)
|
|
|
|
#:use-module (guix records)
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
#:use-module (gnu packages bash)
|
|
|
|
#:export (
|
|
|
|
%default-rc-local-conf
|
|
|
|
rc-local-configuration
|
|
|
|
rc-local-configuration?
|
|
|
|
rc-local-service
|
|
|
|
rc-local-service-type
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
(define %default-rc-local-conf
|
|
|
|
(plain-file "rc-local" "
|
|
|
|
# Empty file as we do nothing by default
|
|
|
|
")
|
|
|
|
)
|
|
|
|
|
|
|
|
(define-record-type* <rc-local-configuration>
|
|
|
|
rc-local-configuration make-rc-local-configuration
|
|
|
|
rc-local-configuration?
|
2021-12-02 21:30:43 +01:00
|
|
|
(config-file rc-local-config-file
|
2021-12-01 14:26:26 +01:00
|
|
|
(default %default-rc-local-conf)
|
2021-12-01 14:08:45 +01:00
|
|
|
)
|
2021-12-02 21:30:43 +01:00
|
|
|
(log-file rc-local-log-file
|
|
|
|
(default "/var/log/rc-local.log")
|
|
|
|
)
|
2021-12-01 14:08:45 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
(define rc-local-service
|
|
|
|
(match-lambda
|
2021-12-03 08:36:46 +01:00
|
|
|
(($ <rc-local-configuration> config-file log-file)
|
2021-12-01 14:08:45 +01:00
|
|
|
(list
|
|
|
|
(shepherd-service
|
|
|
|
(provision '(rc-local) )
|
|
|
|
(documentation "Run rc-local.")
|
|
|
|
(requirement '(user-processes))
|
|
|
|
(respawn? #f)
|
2021-12-02 21:30:43 +01:00
|
|
|
(one-shot? #t)
|
2021-12-01 14:08:45 +01:00
|
|
|
(start #~(make-forkexec-constructor
|
|
|
|
(list
|
|
|
|
#$(file-append bash "/bin/bash")
|
2021-12-01 15:00:38 +01:00
|
|
|
"-l"
|
2021-12-01 15:08:13 +01:00
|
|
|
#$config-file
|
2021-12-01 14:08:45 +01:00
|
|
|
)
|
2021-12-02 21:30:43 +01:00
|
|
|
#:log-file #$log-file
|
2021-12-01 14:08:45 +01:00
|
|
|
))
|
|
|
|
(stop #~(make-kill-destructor))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
(define rc-local-service-type
|
|
|
|
(service-type (name 'rc-local)
|
|
|
|
(extensions
|
|
|
|
(list (
|
|
|
|
service-extension
|
|
|
|
shepherd-root-service-type
|
|
|
|
rc-local-service
|
|
|
|
))
|
|
|
|
)
|
|
|
|
(description "Run a script in a rc-local like form")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|